1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-08-01 19:38:33 +00:00

test(core): visit Delizia menu during tests

Currently, only shows the menu (without visiting its children).
Enabled by returning `has_menu=True` via LayoutContent JSON.

Also, reduce the number of `debuglink.read_layout()` calls in tests.

[no changelog]
This commit is contained in:
Roman Zeyde 2025-07-09 12:56:45 +03:00
parent 1676b2aa0f
commit 953b0e23d1
4 changed files with 33 additions and 21 deletions

View File

@ -93,6 +93,7 @@ pub struct Frame<T> {
swipe: SwipeConfig,
horizontal_swipe: HorizontalSwipe,
margin: usize,
has_menu: bool,
}
pub enum FrameMsg<T> {
@ -115,6 +116,7 @@ where
swipe: SwipeConfig::new(),
horizontal_swipe: HorizontalSwipe::new(),
margin: 0,
has_menu: false,
}
}
@ -168,6 +170,14 @@ where
.button_styled(theme::button_danger())
}
// TODO: currently used to gradually introduce multi-item menus (#5189).
// After the migration, this flag should be set in `with_button()`.
pub fn with_external_menu(mut self) -> Self {
// Allow visiting this menu automatically by tests
self.has_menu = true;
self
}
pub fn title_styled(mut self, style: TextStyle) -> Self {
self.header = self.header.styled(style);
self
@ -451,5 +461,7 @@ where
if let Some(footer) = &self.footer {
t.child("footer", footer);
}
t.bool("has_menu", self.has_menu);
}
}

View File

@ -84,6 +84,7 @@ pub fn new_set_brightness(brightness: Option<u8>) -> Result<SwipeFlow, Error> {
)
.with_subtitle(TR::homescreen__settings_subtitle.into())
.with_menu_button()
.with_external_menu()
.with_swipe(Direction::Up, SwipeSettings::default())
.with_footer(
TR::instructions__swipe_horizontally.into(),

View File

@ -936,26 +936,27 @@ class DebugUI:
else:
self._paginate_and_confirm(br.pages)
def _visit_menu_items(self) -> None:
def _visit_menu_items(self) -> LayoutContent:
layout = self.debuglink.read_layout()
if not layout.has_menu():
return
# FIXME: currently supports only Caesar
assert self.debuglink.model in (models.T2B1, models.T3B1)
return layout
# enter info menu layout and paginate through its items
self.debuglink.press_info()
menu_items_count = self.debuglink.read_layout().page_count()
for _ in range(menu_items_count):
self.debuglink.press_middle()
# paginate through all properties and confirm
self._paginate_and_confirm(None)
# paginate to next menu item
self.debuglink.press_right()
# TODO: support all core models
if self.debuglink.model in (models.T2B1, models.T3B1):
menu_items_count = self.debuglink.read_layout().page_count()
for _ in range(menu_items_count):
self.debuglink.press_middle()
# paginate through all properties and confirm
self._paginate_and_confirm(None)
# paginate to next menu item
self.debuglink.press_right()
# confirm info menu layout
self.debuglink.press_yes()
return layout
def _paginate_and_confirm(self, pages: int | None) -> None:
if pages is None:
@ -969,11 +970,10 @@ class DebugUI:
self.debuglink.swipe_up()
# Visit info menus (if exist)
self._visit_menu_items()
layout = self._visit_menu_items()
# Confirm current layout
if self.debuglink.model is models.T3T1:
layout = self.debuglink.read_layout()
if "PromptScreen" in layout.all_components():
self.debuglink.press_yes()
elif "SwipeContent" in layout.all_components():
@ -981,7 +981,6 @@ class DebugUI:
else:
self.debuglink.press_yes()
elif self.debuglink.model is models.T3W1:
layout = self.debuglink.read_layout()
if "TextScreen" in layout.all_components():
self.debuglink.click(self.debuglink.screen_buttons.ok())
else:

View File

@ -20576,7 +20576,7 @@
"T3T1_cs_test_msg_applysettings.py::test_experimental_features": "8ce0a4117096530ef20a269c386810b653b41bd9df5fb825f42c88a162eee78f",
"T3T1_cs_test_msg_applysettings.py::test_label_too_long": "592adf9c06f8f39132298b46037dd524fac99e58237a0c023197bf47df67d632",
"T3T1_cs_test_msg_applysettings.py::test_safety_checks": "cd150c7a633843533fba556d446d0b5fe691adbf2da639a9d10584a8118fef87",
"T3T1_cs_test_msg_applysettings.py::test_set_brightness": "038eeb78649595da2d07af0171fffaa04677725e8c4bfceda5ccfc1e2abb4c5e",
"T3T1_cs_test_msg_applysettings.py::test_set_brightness": "bf49a942d4f32f519dad3bb76abfe1f81f003043501a9571fbed8bc44af526ce",
"T3T1_cs_test_msg_backup_device.py::test_backup_bip39": "8f3d3e673925da0665037606123a1db3ea06fc2468262e8219862f7a0bb6d220",
"T3T1_cs_test_msg_backup_device.py::test_backup_slip39_advanced[click_info]": "c585537bffda6867427f2485845a2b6c92cca1f0a41da2eec07266d722eca4e3",
"T3T1_cs_test_msg_backup_device.py::test_backup_slip39_advanced[no_click_info]": "d66ed6c5095dee75dd5d257024d24cbf01fa0f532f2018227a22d17678349aae",
@ -22017,7 +22017,7 @@
"T3T1_de_test_msg_applysettings.py::test_experimental_features": "178456e000fdcc986c4f13d54f983cbea1cb090684e51f448a0e211f4fbf958d",
"T3T1_de_test_msg_applysettings.py::test_label_too_long": "f2fcbbd7ad83aff9adc0ee97fe98e7272d8bcfcc4a023798e2ab1c9895fda70f",
"T3T1_de_test_msg_applysettings.py::test_safety_checks": "efe381b2aeaee488ce8684bf9af18d2f6b261101a757eb430c2794497d569a28",
"T3T1_de_test_msg_applysettings.py::test_set_brightness": "9c633724f551c94e18318d26a4f3bcbf65a9e38e48560ad7d8ec11fe94b47d51",
"T3T1_de_test_msg_applysettings.py::test_set_brightness": "f211b0712f7c089c2af3556277b13050e9dbdb9750b6ddce9b985d04ee4fb90e",
"T3T1_de_test_msg_backup_device.py::test_backup_bip39": "f817695806b178b66bc1a563ec0fcc464e26982b3b6f58ba99d04444fed39613",
"T3T1_de_test_msg_backup_device.py::test_backup_slip39_advanced[click_info]": "f58947a0bd5a1e16e24fe6c7f150d3bf7e338fc595f3f0b4634ab6863072aa79",
"T3T1_de_test_msg_backup_device.py::test_backup_slip39_advanced[no_click_info]": "9738d2eed42137232f38d3b18141ac3b16dd4b2fc194047aa4546bc72d08797b",
@ -23458,7 +23458,7 @@
"T3T1_en_test_msg_applysettings.py::test_experimental_features": "9d8bfbaeabca9b46c5382386fa9277cdae0168f3466248a91b69d27678e02de5",
"T3T1_en_test_msg_applysettings.py::test_label_too_long": "cb8641952bec9e793e7d19f281a85a0ca1be2c3397ca5c0cf4ee7ad905429984",
"T3T1_en_test_msg_applysettings.py::test_safety_checks": "8dc9b3dc4fde1441eedaac795d917ff4e6eb45c326d4fbb2e51b1c4ba6af5680",
"T3T1_en_test_msg_applysettings.py::test_set_brightness": "5e0830b1607b041f82dbcc813ff85c0492e8e0e13172d1f9606ad03be7e49f79",
"T3T1_en_test_msg_applysettings.py::test_set_brightness": "e84279ef2bee2a79878015d56e80ea17ef88eb8974b81c350e37d676085b4e23",
"T3T1_en_test_msg_backup_device.py::test_backup_bip39": "74ee624757d2f85e728c384e3af2760a9edb3866cb5778b0e833836581f78430",
"T3T1_en_test_msg_backup_device.py::test_backup_slip39_advanced[click_info]": "77e0226698b6c403c18bf13b0bd79b6226af7dabc60adc3eeaa9fb02ee27879a",
"T3T1_en_test_msg_backup_device.py::test_backup_slip39_advanced[no_click_info]": "b2274378d42a3627eefe2b0a01de1a4e9dbadcd0749f48291fcaa7570c6c13f4",
@ -24899,7 +24899,7 @@
"T3T1_es_test_msg_applysettings.py::test_experimental_features": "b4585199c4630b82d945964adb654c0338c3a18392f3c259f3fad9af5e660d20",
"T3T1_es_test_msg_applysettings.py::test_label_too_long": "c568b82943d9f63ad6b29b7dee6f5ed9dca78fc9610d4fa7f12bb8a061a6882a",
"T3T1_es_test_msg_applysettings.py::test_safety_checks": "a8426a364cdc1b7e3483dcaae47fc6601601a316d9d40fba6f3a8d5a28874560",
"T3T1_es_test_msg_applysettings.py::test_set_brightness": "8d49d35ebeba647730c76656647696dce1338b27169860d541a1256f5c1fb21a",
"T3T1_es_test_msg_applysettings.py::test_set_brightness": "3ba918195931a9e678142a30571e595df9c988a78c1d3d1ab398ee3933c3f193",
"T3T1_es_test_msg_backup_device.py::test_backup_bip39": "3ee1b35753e4f57e74378d780b93ea71382764b6c292f67e9b69802871df9187",
"T3T1_es_test_msg_backup_device.py::test_backup_slip39_advanced[click_info]": "df54f287cdf879ba3ca2e80db20846074b8a30ed85181fe9d50a992c5b3e8475",
"T3T1_es_test_msg_backup_device.py::test_backup_slip39_advanced[no_click_info]": "52e818e0c91efdaee0f6b82d169118b85af37361c01aef4ffa51422a43cd05df",
@ -26340,7 +26340,7 @@
"T3T1_fr_test_msg_applysettings.py::test_experimental_features": "637fb6b09ad63757230f4ca8f705e6659b7ce5b593d70574f21431beb0d551b7",
"T3T1_fr_test_msg_applysettings.py::test_label_too_long": "c4dffa9195d175f9bc4a23e9e0f80b92f7c6687128918a5a70c14b4a6e7e3694",
"T3T1_fr_test_msg_applysettings.py::test_safety_checks": "ce4dacd82f22bea641c7326189dd63d17ee90086c2f8155be5bc51e50d869013",
"T3T1_fr_test_msg_applysettings.py::test_set_brightness": "26e5392f5d41d5a9a949ccade61060af01a0997eac4aa8769562ad0faa1ea4b2",
"T3T1_fr_test_msg_applysettings.py::test_set_brightness": "5915f197f6856b118806470f1cd12eddef9c1457f79ad01c0b71aaa6abd8f166",
"T3T1_fr_test_msg_backup_device.py::test_backup_bip39": "673cfe3b736e5c76a01853af202ec8e9b6d4ba499e60021e4a06f1932ac1c0a7",
"T3T1_fr_test_msg_backup_device.py::test_backup_slip39_advanced[click_info]": "a0c04866ce70d5f9f69570d33d6011ebafd15e41fc45d3f8fcb03262e418eea4",
"T3T1_fr_test_msg_backup_device.py::test_backup_slip39_advanced[no_click_info]": "7de768c9c17f68a33e6f30ef4079a42a529431bf9aa3e192a660db305ec57be9",
@ -27781,7 +27781,7 @@
"T3T1_pt_test_msg_applysettings.py::test_experimental_features": "5a2ea23020bcde2585fa002d0322acfef06472ec1937531a4f174edb524c3c10",
"T3T1_pt_test_msg_applysettings.py::test_label_too_long": "c15216b8aa033bd81f0a8fb6415c6728320b0c30fe3150eeb8a1749ae0a1a83c",
"T3T1_pt_test_msg_applysettings.py::test_safety_checks": "0130f103254b9a9cc742a6f8df628bb860ccda6b31d1fda84643f17dfc084225",
"T3T1_pt_test_msg_applysettings.py::test_set_brightness": "878d8319e0d6a09d8c3310276c0ffebc6c468ddb38cc06792351004b7bc00031",
"T3T1_pt_test_msg_applysettings.py::test_set_brightness": "c5caca9e73fe94d3291d68508b50d8bd34c3857ab748b384721d0d74043d9b9c",
"T3T1_pt_test_msg_backup_device.py::test_backup_bip39": "2d3758273b1723e8fa129398809bf0e3a181a083018993ce996913129b98e793",
"T3T1_pt_test_msg_backup_device.py::test_backup_slip39_advanced[click_info]": "759e167564702620c3d7736b54b3402c9606063779287441374366bab4ef8e4a",
"T3T1_pt_test_msg_backup_device.py::test_backup_slip39_advanced[no_click_info]": "c609f89722fb5ff8c0a591545e0bb6e9fb09681ab5eb23363ad6ab31fa50bacc",