Skip to content

Commit

Permalink
fix(single-mode): can not recognize class detail button
Browse files Browse the repository at this point in the history
from adb device

fix #135
  • Loading branch information
NateScarlet committed Aug 7, 2021
1 parent 3dd5573 commit 5422f0b
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 2 deletions.
8 changes: 6 additions & 2 deletions auto_derby/templates/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@


__init__.py: *.png __init__.py.gotmpl
# http://github.com/NateScarlet/gotmpl
ls *.png | jq -nR 'reduce inputs as $$item ([]; . + [$$item]) | { Files: . }' | gotmpl -o $@ __init__.py.gotmpl
py -3.8 -m black -t py38 $@


%.pos.png:
magick convert $@ -depth 1 $@


15 changes: 15 additions & 0 deletions auto_derby/templates/_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from auto_derby import template
from pathlib import Path
from typing import Text

import PIL.Image

from .. import mathtools

DATA_PATH = Path(__file__).parent / "test_data"


def use_screenshot(name: Text):
img = PIL.Image.open(DATA_PATH / name).convert("RGB")
template.g.screenshot_width = img.width
return img, mathtools.ResizeProxy(img.width)
Binary file modified auto_derby/templates/single_mode_class_detail_button.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified auto_derby/templates/single_mode_class_detail_button.pos.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions auto_derby/templates/single_mode_class_detail_button_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from . import _test
from .. import template, templates, action


_EXPECTED_POS = (114, 165)


def test_match():
img, rp = _test.use_screenshot("single_mode_command_scene.png")
res = tuple(template.match(img, templates.SINGLE_MODE_CLASS_DETAIL_BUTTON))
assert len(res) == 1
(match1,) = res
assert match1[1] == rp.vector2(_EXPECTED_POS, 540)


def test_match_issue135():
img, rp = _test.use_screenshot("single_mode_command_scene_issue135.png")
res = tuple(template.match(img, templates.SINGLE_MODE_CLASS_DETAIL_BUTTON))
assert len(res) == 1
(match1,) = res
assert match1[1] == rp.vector2(_EXPECTED_POS, 540)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 5422f0b

Please sign in to comment.