Skip to content

Commit

Permalink
fix(single-mode): template can not match
Browse files Browse the repository at this point in the history
for adb device

fix #186
  • Loading branch information
NateScarlet committed Sep 8, 2021
1 parent c442a93 commit a71e820
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
8 changes: 7 additions & 1 deletion auto_derby/scenes/single_mode/aoharu_competitor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pyright: strict

from __future__ import annotations
from auto_derby import template


from ... import action, templates
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
[
213,
110
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
[
426,
220
]
]
27 changes: 27 additions & 0 deletions auto_derby/templates/single_mode_aoharu_choose_competitor_test.py
Original file line number Diff line number Diff line change
@@ -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)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a71e820

Please sign in to comment.