1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-27 07:40:59 +00:00

tests: fix wait_layout() behavior

This commit is contained in:
matejcik 2020-05-25 12:50:30 +02:00 committed by matejcik
parent 01832d5ae9
commit 3c128cde38
4 changed files with 15 additions and 5 deletions

View File

@ -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:

View File

@ -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()

View File

@ -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

View File

@ -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])