diff options
Diffstat (limited to 'tools/tests')
| -rw-r--r-- | tools/tests/test_check_budgets.py | 2 | ||||
| -rw-r--r-- | tools/tests/test_ui_flow.py | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tools/tests/test_check_budgets.py b/tools/tests/test_check_budgets.py index 2262a0b..28ba710 100644 --- a/tools/tests/test_check_budgets.py +++ b/tools/tests/test_check_budgets.py @@ -29,6 +29,8 @@ def test_measure_perf_and_memory() -> None: assert cb.measure("perf", events) == {"startup_ms": 12.0, "first_frame_wall_ms": 2310.0} assert cb.measure("mem", events) == {"mem_used_fraction": 100000 / 524288} assert cb.measure("perf", {}) == {} + with_glance = cb.read_events(f"DIAG glance mem_used=16384 mem_total=65536\n{FRAME}") + assert cb.measure("mem", with_glance) == {"mem_used_fraction": 100000 / 524288, "glance_mem_used_fraction": 0.25} def run(tmp_path: Path, kind: str, log_text: str, budgets: Mapping[str, Mapping[str, float]]) -> int: diff --git a/tools/tests/test_ui_flow.py b/tools/tests/test_ui_flow.py index 7e0d336..d98b4c2 100644 --- a/tools/tests/test_ui_flow.py +++ b/tools/tests/test_ui_flow.py @@ -1,5 +1,5 @@ # Author: cirakg & claude ai -# Summary: Tests for the UI flow driver's pure parts: device key layout, JSON lookup and the app-log reader. +# Summary: Tests for the UI flow driver's pure parts: key layout, JSON lookup, the app-log reader, barcode reading. from __future__ import annotations import json @@ -8,7 +8,9 @@ import time from pathlib import Path import pytest +import segno import ui_flow +from PIL import Image def write_sim(tmp_path: Path, config: dict[str, object]) -> Path: @@ -71,3 +73,11 @@ def test_app_log_latest_returns_the_last_match(tmp_path: Path) -> None: match = ui_flow.AppLog(log_path).latest(r"DIAG list_focus y=(\d+)") assert match is not None and match.group(1) == "42" assert ui_flow.AppLog(tmp_path / "missing.log").latest("x") is None + + +def test_barcodes_on_reads_a_drawn_code(tmp_path: Path) -> None: + path = tmp_path / "qr.png" + segno.make("OTPW stress", error="m").save(str(path), scale=4, border=4) + screen = Image.open(path).convert("RGB") + assert ui_flow.barcodes_on(screen) == ["OTPW stress"] + assert ui_flow.barcodes_on(Image.new("RGB", (100, 100), "white")) == [] |
