1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-24 07:18:09 +00:00

core: fix artifacts in click-based UI tests

This commit is contained in:
matejcik 2020-05-26 12:55:22 +02:00 committed by matejcik
parent a9d8fd3992
commit 70f67883c5
5 changed files with 27 additions and 6 deletions

View File

@ -49,6 +49,13 @@ class Lockscreen(HomescreenBase):
# and paint it.
ui.display.clear()
self.on_render()
if __debug__ and self.should_notify_layout_change:
from apps.debug import notify_layout_change
self.should_notify_layout_change = False
notify_layout_change(self)
ui.refresh()
ui.backlight_fade(ui.BACKLIGHT_LOW)
# long sleep

View File

@ -310,6 +310,12 @@ class Layout(Component):
Run the layout and wait until it completes. Returns the result value.
Usually not overridden.
"""
if __debug__:
# we want to call notify_layout_change() when the rendering is done;
# but only the first time the layout is awaited. Here we indicate that we
# are being awaited, and in handle_rendering() we send the appropriate event
self.should_notify_layout_change = True
value = None
try:
# If any other layout is running (waiting on the layout channel),
@ -322,8 +328,6 @@ class Layout(Component):
# layout channel. This allows other layouts to cancel us, and the
# layout tasks to trigger restart by exiting (new tasks are created
# and we continue, because we are in a loop).
if __debug__:
notify_layout_change(self)
while True:
await loop.race(layout_chan.take(), *self.create_tasks())
except Result as result:
@ -365,6 +369,14 @@ class Layout(Component):
display.clear()
self.dispatch(REPAINT, 0, 0)
self.dispatch(RENDER, 0, 0)
if __debug__ and self.should_notify_layout_change:
# notify about change and do not notify again until next await.
# (handle_rendering might be called multiple times in a single await,
# because of the endless loop in __iter__)
self.should_notify_layout_change = False
notify_layout_change(self)
# Display is usually refreshed after every loop step, but here we are
# rendering everything synchronously, so refresh it manually and turn
# the brightness on again.

View File

@ -48,7 +48,7 @@ def test_reset_slip39_advanced_2of2groups_2of2shares(device_handler):
reset.confirm_wait(debug, "Create new wallet")
# confirm back up
reset.confirm_wait(debug, "Success")
reset.confirm_read(debug, "Success")
# confirm checklist
reset.confirm_read(debug, "Checklist")
@ -130,7 +130,7 @@ def test_reset_slip39_advanced_16of16groups_16of16shares(device_handler):
reset.confirm_wait(debug, "Create new wallet")
# confirm back up
reset.confirm_wait(debug, "Success")
reset.confirm_read(debug, "Success")
# confirm checklist
reset.confirm_read(debug, "Checklist")

View File

@ -48,7 +48,7 @@ def test_reset_slip39_basic_1of1(device_handler):
reset.confirm_wait(debug, "Create new wallet")
# confirm back up
reset.confirm_wait(debug, "Success")
reset.confirm_read(debug, "Success")
# confirm checklist
reset.confirm_read(debug, "Checklist")
@ -120,7 +120,7 @@ def test_reset_slip39_basic_16of16(device_handler):
reset.confirm_wait(debug, "Create new wallet")
# confirm back up
reset.confirm_wait(debug, "Success")
reset.confirm_read(debug, "Success")
# confirm checklist
reset.confirm_read(debug, "Checklist")

View File

@ -73,9 +73,11 @@ def do_recover_core(client, mnemonic, **kwargs):
yield
for word in mnemonic:
client.debug.wait_layout()
client.debug.input(word)
yield
client.debug.wait_layout()
client.debug.click(buttons.OK)
with client: