expose fudai detail thresholds and regions
This commit is contained in:
1 parent
37a2f94486
commit
9b03556b7d
14 files changed
+293
-18
No files matched your search
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import json
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
|
||||
@@ -247,8 +248,8 @@ def test_v2_task_count_dacheng_shape_real_samples():
|
||||
one_task = Path(
|
||||
r"C:\Users\12742\Desktop\douyin_guaji-main\pic\debug_captures\2026-06-04\20260604_115302_493312_px_pxstage_ov_ok_3.png"
|
||||
)
|
||||
assert two_task.exists()
|
||||
assert one_task.exists()
|
||||
if not two_task.exists() or not one_task.exists():
|
||||
pytest.skip("real fudai task-count samples are not available on this machine")
|
||||
|
||||
analyser = SimpleNamespace(
|
||||
fudai_detail_ui_mode="v2_0",
|
||||
|
||||
@@ -134,6 +134,10 @@ class TestFudaiDetailOcrGuiConfig:
|
||||
"fudai_detail_ocr_button_enabled_var",
|
||||
"fudai_detail_ocr_participants_enabled_var",
|
||||
"fudai_detail_ocr_live_title_enabled_var",
|
||||
"region_coords_edit_enabled_var",
|
||||
"fudai_detail_body_bluepurple_threshold_var",
|
||||
"fudai_detail_body_dark_threshold_var",
|
||||
"fudai_task_status_template_threshold_var",
|
||||
):
|
||||
assert key in vars_
|
||||
|
||||
@@ -154,10 +158,29 @@ class TestFudaiDetailOcrGuiConfig:
|
||||
"fudai_detail_regions_v2_0_two_task_content_x1_var",
|
||||
"fudai_detail_regions_v2_0_one_task_info_line_x1_var",
|
||||
"pixel_regions_lottery_result_pixel_x1_var",
|
||||
"pixel_regions_fudai_task_status_x1_var",
|
||||
"pixel_regions_live_room_icon_bbox_x1_var",
|
||||
):
|
||||
assert key in vars_
|
||||
|
||||
def test_build_config_vars_region_fields_fallback_to_defaults(self, monkeypatch):
|
||||
import tkinter as tk
|
||||
|
||||
from gui.components.config_vars import build_config_vars
|
||||
|
||||
monkeypatch.setattr(tk, "StringVar", lambda value="": MagicMock(get=lambda: value, set=lambda _v: None))
|
||||
monkeypatch.setattr(tk, "BooleanVar", lambda value=False: MagicMock(get=lambda: value, set=lambda _v: None))
|
||||
monkeypatch.setattr(tk, "IntVar", lambda value=0: MagicMock(get=lambda: value, set=lambda _v: None))
|
||||
monkeypatch.setattr(tk, "DoubleVar", lambda value=0.0: MagicMock(get=lambda: value, set=lambda _v: None))
|
||||
|
||||
vars_ = build_config_vars({})
|
||||
|
||||
assert vars_["fudai_detail_regions_legacy_content_x1_var"].get() == 389
|
||||
assert vars_["fudai_detail_regions_v2_0_two_task_content_y1_var"].get() == 1410
|
||||
assert vars_["fudai_detail_regions_v2_0_one_task_info_line_x1_var"].get() == 430
|
||||
assert vars_["pixel_regions_fudai_task_status_x1_var"].get() == 820
|
||||
assert vars_["pixel_regions_live_room_icon_bbox_x1_var"].get() == 999
|
||||
|
||||
|
||||
class TestWriteConfig:
|
||||
def test_write_and_read_roundtrip(self):
|
||||
|
||||
@@ -127,6 +127,10 @@ def test_config_accepts_fudai_detail_v2_ocr_switches_and_ui_mode(monkeypatch):
|
||||
"fudai_detail_ocr_button_enabled": "true",
|
||||
"fudai_detail_ocr_participants_enabled": "false",
|
||||
"fudai_detail_ocr_live_title_enabled": "false",
|
||||
"region_coords_edit_enabled": "true",
|
||||
"fudai_detail_body_bluepurple_threshold": "0.46",
|
||||
"fudai_detail_body_dark_threshold": "0.36",
|
||||
"fudai_task_status_template_threshold": "0.27",
|
||||
}
|
||||
},
|
||||
monkeypatch,
|
||||
@@ -138,6 +142,10 @@ def test_config_accepts_fudai_detail_v2_ocr_switches_and_ui_mode(monkeypatch):
|
||||
assert written["fudai_detail_ocr_content_enabled"] is True
|
||||
assert written["fudai_detail_ocr_button_enabled"] is True
|
||||
assert written["fudai_detail_ocr_participants_enabled"] is False
|
||||
assert written["region_coords_edit_enabled"] is True
|
||||
assert written["fudai_detail_body_bluepurple_threshold"] == 0.46
|
||||
assert written["fudai_detail_body_dark_threshold"] == 0.36
|
||||
assert written["fudai_task_status_template_threshold"] == 0.27
|
||||
|
||||
|
||||
def test_config_accepts_region_coordinate_arrays(monkeypatch):
|
||||
@@ -152,6 +160,7 @@ def test_config_accepts_region_coordinate_arrays(monkeypatch):
|
||||
"config": {
|
||||
"fudai_detail_regions.v2_0_one_task.info_line": [430, 1315, 1055, 1435],
|
||||
"pixel_regions.lottery_result.pixel": ["290", "1300", "790", "1415"],
|
||||
"pixel_regions.fudai_task_status": [820, 1815, 1050, 2035],
|
||||
"pixel_regions.live_room_icon_bbox": [999, 172, 1028, 202],
|
||||
}
|
||||
},
|
||||
@@ -162,6 +171,7 @@ def test_config_accepts_region_coordinate_arrays(monkeypatch):
|
||||
assert obj.get("ok") is True
|
||||
assert written["fudai_detail_regions"]["v2_0_one_task"]["info_line"] == [430, 1315, 1055, 1435]
|
||||
assert written["pixel_regions"]["lottery_result"]["pixel"] == [290, 1300, 790, 1415]
|
||||
assert written["pixel_regions"]["fudai_task_status"] == [820, 1815, 1050, 2035]
|
||||
assert written["pixel_regions"]["live_room_icon_bbox"] == [999, 172, 1028, 202]
|
||||
|
||||
|
||||
@@ -271,7 +281,7 @@ def test_wifi_auto_reconnect_without_adb_returns_422(monkeypatch):
|
||||
assert obj.get("error") == "adb not found"
|
||||
|
||||
|
||||
def test_wifi_auto_reconnect_uses_auto_full_port_scan(monkeypatch):
|
||||
def test_wifi_auto_reconnect_uses_lightweight_ports(monkeypatch):
|
||||
captured = {}
|
||||
|
||||
monkeypatch.setattr(routes, "find_adb_executable", lambda: "adb")
|
||||
@@ -297,7 +307,7 @@ def test_wifi_auto_reconnect_uses_auto_full_port_scan(monkeypatch):
|
||||
|
||||
assert status == 200
|
||||
assert obj.get("ok") is True
|
||||
assert "ports" not in captured
|
||||
assert captured.get("ports") == [39601, 5555, 44219]
|
||||
|
||||
|
||||
def test_wifi_scan_includes_tried_subnets(monkeypatch):
|
||||
|
||||
Reference in new issue
Block a user