mirror of
https://github.com/trezor/trezor-firmware.git
synced 2026-02-20 00:33:30 +01:00
fix: tests
[no changelog]
This commit is contained in:
@@ -1021,7 +1021,9 @@ class DebugUI:
|
||||
else:
|
||||
self._paginate_and_confirm(br.pages)
|
||||
|
||||
def _visit_vertical_menu(self, menu_layout: LayoutContent) -> None:
|
||||
def _visit_vertical_menu(
|
||||
self, menu_layout: LayoutContent, cb: t.Callable[[int], None] | None
|
||||
) -> None:
|
||||
assert self.debuglink.layout_type in (LayoutType.Delizia, LayoutType.Eckhart)
|
||||
assert "VerticalMenu" in menu_layout.all_components()
|
||||
|
||||
@@ -1031,13 +1033,19 @@ class DebugUI:
|
||||
menu_buttons = menu_layout.find_unique_value_by_key(
|
||||
key="buttons", default=None, only_type=list
|
||||
)
|
||||
i = 0
|
||||
for menu_button, item_button in zip(menu_buttons, item_buttons):
|
||||
if menu_button.get("is_cancel"):
|
||||
continue # don't click cancel
|
||||
self.debuglink.click(item_button)
|
||||
if cb:
|
||||
cb(i)
|
||||
self.debuglink.click(close_button)
|
||||
i += 1
|
||||
|
||||
def _visit_scrolled_vertical_menu(self, menu_layout: LayoutContent) -> None:
|
||||
def _visit_scrolled_vertical_menu(
|
||||
self, menu_layout: LayoutContent, cb: t.Callable[[int], None] | None
|
||||
) -> None:
|
||||
assert self.debuglink.layout_type is LayoutType.Delizia
|
||||
assert "ScrolledVerticalMenu" in menu_layout.all_components()
|
||||
|
||||
@@ -1045,6 +1053,7 @@ class DebugUI:
|
||||
close_button = self.debuglink.screen_buttons.menu()
|
||||
|
||||
_prev, next = self.debuglink.screen_buttons.vertical_menu_prev_next()
|
||||
i = 0
|
||||
while True:
|
||||
menu_items = menu_layout.find_unique_value_by_key(
|
||||
key="menu_items", default=None, only_type=dict
|
||||
@@ -1053,14 +1062,19 @@ class DebugUI:
|
||||
if "cancel" in menu_item:
|
||||
continue # don't click cancel
|
||||
self.debuglink.click(item_button)
|
||||
if cb:
|
||||
cb(i)
|
||||
self.debuglink.click(close_button)
|
||||
i += 1
|
||||
if not menu_items["has_next"]:
|
||||
break
|
||||
self.debuglink.click(next)
|
||||
menu_layout = self.debuglink.read_layout()
|
||||
assert "ScrolledVerticalMenu" in menu_layout.all_components()
|
||||
|
||||
def visit_menu_items(self) -> LayoutContent:
|
||||
def visit_menu_items(
|
||||
self, cb: t.Callable[[int], None] | None = None
|
||||
) -> LayoutContent:
|
||||
layout = self.debuglink.read_layout()
|
||||
if (
|
||||
not layout.has_menu()
|
||||
@@ -1082,18 +1096,19 @@ class DebugUI:
|
||||
if self.debuglink.layout_type is LayoutType.Eckhart:
|
||||
menu_layout = self.debuglink.read_layout()
|
||||
if "VerticalMenu" in menu_layout.all_components():
|
||||
self._visit_vertical_menu(menu_layout)
|
||||
self._visit_vertical_menu(menu_layout, cb)
|
||||
else:
|
||||
raise UnexpectedMenuError(menu_layout.json_str)
|
||||
elif self.debuglink.layout_type is LayoutType.Delizia:
|
||||
menu_layout = self.debuglink.read_layout()
|
||||
if "ScrolledVerticalMenu" in menu_layout.all_components():
|
||||
self._visit_scrolled_vertical_menu(menu_layout)
|
||||
self._visit_scrolled_vertical_menu(menu_layout, cb)
|
||||
elif "VerticalMenu" in menu_layout.all_components():
|
||||
self._visit_vertical_menu(menu_layout)
|
||||
self._visit_vertical_menu(menu_layout, cb)
|
||||
else:
|
||||
raise UnexpectedMenuError(menu_layout.json_str)
|
||||
elif self.debuglink.layout_type is LayoutType.Caesar:
|
||||
assert cb is None, "Menu visiting callback not yet supported on Caesar"
|
||||
menu_items_count = self.debuglink.read_layout().page_count()
|
||||
for _ in range(menu_items_count):
|
||||
self.debuglink.press_middle()
|
||||
|
||||
@@ -583,10 +583,12 @@ class EthereumFlow:
|
||||
if go_back_from_summary:
|
||||
# Get back to the address screen
|
||||
self.debug.swipe_down()
|
||||
assert (yield).name == "confirm_output"
|
||||
title = self.debug.read_layout().title()
|
||||
assert TR.words__address in title
|
||||
# Get back to the summary screen
|
||||
self.debug.swipe_up()
|
||||
assert (yield).name == "confirm_total"
|
||||
layout = self.debug.read_layout()
|
||||
assert layout.title() == TR.words__title_summary
|
||||
assert TR.send__maximum_fee in layout.text_content()
|
||||
@@ -632,10 +634,12 @@ class EthereumFlow:
|
||||
if go_back_from_summary:
|
||||
# Get back to the address screen
|
||||
self.debug.click(self.debug.screen_buttons.cancel())
|
||||
assert (yield).name == "confirm_output"
|
||||
title = self.debug.read_layout().title()
|
||||
assert title_exp in title
|
||||
# Get back to the summary screen
|
||||
self.debug.click(self.debug.screen_buttons.ok())
|
||||
assert (yield).name == "confirm_total"
|
||||
layout = self.debug.read_layout()
|
||||
assert layout.title() == title_exp
|
||||
assert TR.send__maximum_fee in layout.text_content()
|
||||
@@ -741,15 +745,15 @@ class EthereumFlow:
|
||||
elif self.client.layout_type is LayoutType.Delizia:
|
||||
# confirm intro
|
||||
if info:
|
||||
self.debug.click(self.debug.screen_buttons.menu())
|
||||
self.debug.synchronize_at("VerticalMenu")
|
||||
self.debug.button_actions.navigate_to_menu_item(0)
|
||||
assert self.debug.read_layout().title() in (
|
||||
TR.ethereum__staking_stake_address,
|
||||
TR.ethereum__staking_claim_address,
|
||||
)
|
||||
self.debug.click(self.debug.screen_buttons.menu())
|
||||
self.debug.click(self.debug.screen_buttons.menu())
|
||||
|
||||
def check_address(i):
|
||||
if i == 0:
|
||||
assert self.debug.read_layout().title() in (
|
||||
TR.ethereum__staking_stake_address,
|
||||
TR.ethereum__staking_claim_address,
|
||||
)
|
||||
|
||||
self.client.ui.visit_menu_items(check_address)
|
||||
|
||||
self.debug.swipe_up()
|
||||
br = yield
|
||||
|
||||
Reference in New Issue
Block a user