From 26ab041f47a502bb89f782a517598189181dbf07 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Thu, 6 Feb 2025 19:05:59 +0200 Subject: [PATCH] fixup! test(core): don't fetch `DebugLinkState` by default --- tests/click_tests/common.py | 12 ------------ tests/click_tests/test_autolock.py | 5 +++-- tests/click_tests/test_pin.py | 4 ++++ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/click_tests/common.py b/tests/click_tests/common.py index a5e330e2ff..fff7d47f9d 100644 --- a/tests/click_tests/common.py +++ b/tests/click_tests/common.py @@ -59,18 +59,6 @@ def go_next(debug: "DebugLink") -> LayoutContent: return debug.read_layout() -def tap_to_confirm(debug: "DebugLink") -> LayoutContent: - if debug.layout_type is LayoutType.Bolt: - return debug.read_layout() - elif debug.layout_type is LayoutType.Caesar: - return debug.read_layout() - elif debug.layout_type is LayoutType.Delizia: - debug.click(buttons.TAP_TO_CONFIRM) - return debug.read_layout() - else: - raise RuntimeError("Unknown model") - - def go_back(debug: "DebugLink", r_middle: bool = False) -> LayoutContent: if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia): debug.click(buttons.CANCEL) diff --git a/tests/click_tests/test_autolock.py b/tests/click_tests/test_autolock.py index 17f2d6a9b9..78ef5c9e13 100644 --- a/tests/click_tests/test_autolock.py +++ b/tests/click_tests/test_autolock.py @@ -30,7 +30,7 @@ from .. import translations as TR from ..device_tests.bitcoin.payment_req import make_coinjoin_request from ..tx_cache import TxCache from . import recovery -from .common import go_next, tap_to_confirm, unlock_gesture +from .common import go_next, unlock_gesture if TYPE_CHECKING: from trezorlib.debuglink import DebugLink, LayoutContent @@ -71,7 +71,8 @@ def set_autolock_delay(device_handler: "BackgroundDeviceHandler", delay_ms: int) layout = go_next(debug) if debug.layout_type is LayoutType.Delizia: - layout = tap_to_confirm(debug) + debug.click(buttons.TAP_TO_CONFIRM) + layout = debug.read_layout() assert layout.main_component() == "Homescreen" device_handler.result() diff --git a/tests/click_tests/test_pin.py b/tests/click_tests/test_pin.py index e1256f1a27..d810910dc8 100644 --- a/tests/click_tests/test_pin.py +++ b/tests/click_tests/test_pin.py @@ -211,6 +211,10 @@ def _cancel_pin(debug: "DebugLink") -> None: # It is the same button as DELETE # TODO: implement cancel PIN for TR? _delete_pin(debug, 1, check=False) + + # Note: `prepare()` context manager will send a tap after PIN cancellation, + # so we make sure the lockscreen is already up to receive it -- otherwise + # the input event may get lost in the loop restart. assert debug.read_layout().main_component() != "PinKeyboard"