From 3c128cde389e3693d4593f29e66399d93d6ea2ec Mon Sep 17 00:00:00 2001 From: matejcik Date: Mon, 25 May 2020 12:50:30 +0200 Subject: [PATCH] tests: fix wait_layout() behavior --- tests/device_handler.py | 13 ++++++++----- tests/device_tests/test_msg_getaddress_show.py | 3 +++ .../test_msg_recoverydevice_bip39_dryrun.py | 2 ++ tests/upgrade_tests/test_firmware_upgrades.py | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/device_handler.py b/tests/device_handler.py index 495fbfcdc8..f7788955a6 100644 --- a/tests/device_handler.py +++ b/tests/device_handler.py @@ -12,20 +12,24 @@ class NullUI: @staticmethod def get_pin(code=None): - raise NotImplementedError("Should not be used with T1") + raise NotImplementedError("NullUI should not be used with T1") @staticmethod def get_passphrase(): - raise NotImplementedError("Should not be used with T1") + raise NotImplementedError("NullUI should not be used with T1") class BackgroundDeviceHandler: _pool = ThreadPoolExecutor() def __init__(self, client): + self._configure_client(client) + self.task = None + + def _configure_client(self, client): self.client = client self.client.ui = NullUI - self.task = None + self.client.watch_layout(True) def run(self, function, *args, **kwargs): if self.task is not None: @@ -49,8 +53,7 @@ class BackgroundDeviceHandler: # TODO handle actual restart as well self.kill_task() emulator.restart() - self.client = emulator.client - self.client.ui = NullUI + self._configure_client(emulator.client) def result(self): if self.task is None: diff --git a/tests/device_tests/test_msg_getaddress_show.py b/tests/device_tests/test_msg_getaddress_show.py index e7549538ea..8df3d4e393 100644 --- a/tests/device_tests/test_msg_getaddress_show.py +++ b/tests/device_tests/test_msg_getaddress_show.py @@ -118,6 +118,7 @@ def test_show_multisig_xpubs(client): assert lines[1:] == xpubs[0] # just for UI test client.debug.swipe_up() + client.debug.wait_layout() client.debug.press_no() yield # show XPUB#2 @@ -126,6 +127,7 @@ def test_show_multisig_xpubs(client): assert lines[1:] == xpubs[1] # just for UI test client.debug.swipe_up() + client.debug.wait_layout() client.debug.press_no() yield # show XPUB#3 @@ -134,6 +136,7 @@ def test_show_multisig_xpubs(client): assert lines[1:] == xpubs[2] # just for UI test client.debug.swipe_up() + client.debug.wait_layout() client.debug.press_yes() diff --git a/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py b/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py index 36054b8ea7..20d5da52b2 100644 --- a/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py +++ b/tests/device_tests/test_msg_recoverydevice_bip39_dryrun.py @@ -136,6 +136,8 @@ def test_invalid_seed_core(client): yield for _ in range(12): + layout = client.debug.wait_layout() + assert layout.text == "Bip39Keyboard" client.debug.input("stick") code = yield diff --git a/tests/upgrade_tests/test_firmware_upgrades.py b/tests/upgrade_tests/test_firmware_upgrades.py index 5cc9286915..8dd171d950 100644 --- a/tests/upgrade_tests/test_firmware_upgrades.py +++ b/tests/upgrade_tests/test_firmware_upgrades.py @@ -174,6 +174,7 @@ def test_upgrade_shamir_recovery(gen, tag): emu.client ) as device_handler: assert emu.client.features.recovery_mode is False + emu.client.watch_layout(True) debug = device_handler.debuglink() device_handler.run(device.recover, pin_protection=False) @@ -191,6 +192,7 @@ def test_upgrade_shamir_recovery(gen, tag): assert device_id == emu.client.features.device_id assert emu.client.features.recovery_mode debug = emu.client.debug + emu.client.watch_layout(True) # second share layout = recovery.enter_share(debug, MNEMONIC_SLIP39_BASIC_20_3of6[2])