diff --git a/auto_derby/scenes/single_mode/aoharu_competitor.py b/auto_derby/scenes/single_mode/aoharu_competitor.py index 3e1ac218..0beebffa 100644 --- a/auto_derby/scenes/single_mode/aoharu_competitor.py +++ b/auto_derby/scenes/single_mode/aoharu_competitor.py @@ -1,6 +1,7 @@ # pyright: strict from __future__ import annotations +from auto_derby import template from ... import action, templates @@ -20,7 +21,12 @@ def name(cls): def _enter(cls, ctx: SceneHolder) -> Scene: if ctx.scene.name() == "single-mode-aoharu-battle-confirm": action.wait_tap_image(templates.CANCEL_BUTTON) - action.wait_image(templates.SINGLE_MODE_AOHARU_CHOOSE_COMPETITOR) + action.wait_image( + template.Specification( + templates.SINGLE_MODE_AOHARU_CHOOSE_COMPETITOR, + threshold=0.8, + ), + ) return cls() def choose_competitor(self, index: int) -> None: diff --git a/auto_derby/templates/__snapshots__/single_mode_aoharu_choose_competitor_test/test_recognize_predictions.aoharu_competitor_menu_1.json b/auto_derby/templates/__snapshots__/single_mode_aoharu_choose_competitor_test/test_recognize_predictions.aoharu_competitor_menu_1.json new file mode 100644 index 00000000..e86e0e4b --- /dev/null +++ b/auto_derby/templates/__snapshots__/single_mode_aoharu_choose_competitor_test/test_recognize_predictions.aoharu_competitor_menu_1.json @@ -0,0 +1,6 @@ +[ + [ + 213, + 110 + ] +] \ No newline at end of file diff --git a/auto_derby/templates/__snapshots__/single_mode_aoharu_choose_competitor_test/test_recognize_predictions.aoharu_competitor_menu_issue186.json b/auto_derby/templates/__snapshots__/single_mode_aoharu_choose_competitor_test/test_recognize_predictions.aoharu_competitor_menu_issue186.json new file mode 100644 index 00000000..ed41e0c3 --- /dev/null +++ b/auto_derby/templates/__snapshots__/single_mode_aoharu_choose_competitor_test/test_recognize_predictions.aoharu_competitor_menu_issue186.json @@ -0,0 +1,6 @@ +[ + [ + 426, + 220 + ] +] \ No newline at end of file diff --git a/auto_derby/templates/single_mode_aoharu_choose_competitor_test.py b/auto_derby/templates/single_mode_aoharu_choose_competitor_test.py new file mode 100644 index 00000000..c44caac1 --- /dev/null +++ b/auto_derby/templates/single_mode_aoharu_choose_competitor_test.py @@ -0,0 +1,27 @@ +from typing import Text +from .. import _test, template, templates +import pytest + + +@pytest.mark.parametrize( + "name", + tuple( + i.stem + for i in ( + (_test.DATA_PATH / "single_mode").glob("aoharu_competitor_menu_*.png") + ) + ), +) +def test_recognize_predictions(name: Text): + img, _ = _test.use_screenshot(f"single_mode/{name}.png") + res = tuple( + i[1] + for i in template.match( + img, + template.Specification( + templates.SINGLE_MODE_AOHARU_CHOOSE_COMPETITOR, + threshold=0.8, + ), + ) + ) + _test.snapshot_match(res, name=name) diff --git a/auto_derby/test_data/single_mode/aoharu_competitor_menu.png b/auto_derby/test_data/single_mode/aoharu_competitor_menu_1.png similarity index 100% rename from auto_derby/test_data/single_mode/aoharu_competitor_menu.png rename to auto_derby/test_data/single_mode/aoharu_competitor_menu_1.png diff --git a/auto_derby/test_data/single_mode/aoharu_competitor_menu_issue186.png b/auto_derby/test_data/single_mode/aoharu_competitor_menu_issue186.png new file mode 100644 index 00000000..fb3c0925 Binary files /dev/null and b/auto_derby/test_data/single_mode/aoharu_competitor_menu_issue186.png differ