mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-08-01 19:38:33 +00:00
test(core): visit Delizia menu items in UI tests
[no changelog]
This commit is contained in:
parent
7efdc607ec
commit
b0cc29cbae
@ -1926,7 +1926,7 @@ pub static mp_module_trezorui_api: Module = obj_module! {
|
||||
/// title: str,
|
||||
/// value: list[tuple[str, str]] | str,
|
||||
/// ) -> LayoutObj[None]:
|
||||
/// """Show a list of key-value pairs, or a chunkified string."""
|
||||
/// """Show a list of key-value pairs, or a monospace string."""
|
||||
Qstr::MP_QSTR_show_properties => obj_fn_kw!(0, new_show_properties).as_obj(),
|
||||
|
||||
/// def show_remaining_shares(
|
||||
|
@ -340,6 +340,20 @@ impl VerticalMenuItem {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ui_debug")]
|
||||
impl crate::trace::Trace for VerticalMenuItem {
|
||||
fn trace(&self, t: &mut dyn crate::trace::Tracer) {
|
||||
match self {
|
||||
VerticalMenuItem::Item(text) => {
|
||||
t.string("item", *text);
|
||||
}
|
||||
VerticalMenuItem::Cancel(text) => {
|
||||
t.string("cancel", *text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ScrolledVerticalMenu {
|
||||
active: VerticalMenu,
|
||||
items: VerticalMenuItems,
|
||||
@ -463,6 +477,20 @@ impl Component for ScrolledVerticalMenu {
|
||||
impl crate::trace::Trace for ScrolledVerticalMenu {
|
||||
fn trace(&self, t: &mut dyn crate::trace::Tracer) {
|
||||
self.active.trace(t);
|
||||
|
||||
let chunks_to_skip = self.pager.current().into();
|
||||
let mut chunks = self.items.chunks(self.menu_capacity).skip(chunks_to_skip);
|
||||
let current_chunk = unwrap!(chunks.next());
|
||||
|
||||
t.in_child("menu_items", &|t| {
|
||||
t.in_list("current", &|t| {
|
||||
for item in current_chunk {
|
||||
t.in_child(&|t| item.trace(t));
|
||||
}
|
||||
});
|
||||
t.bool("has_next", self.pager.has_next());
|
||||
t.bool("has_prev", self.pager.has_prev());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1138,7 +1138,6 @@ impl FirmwareUI for UIDelizia {
|
||||
if Obj::is_str(value) {
|
||||
let confirm = ConfirmValue::new(title, value, None)
|
||||
.with_cancel_button()
|
||||
// .with_chunkify(true)
|
||||
.with_text_mono(true);
|
||||
let layout = confirm.into_layout()?;
|
||||
return flow::util::single_page(layout.map(|_| Some(FlowMsg::Confirmed)));
|
||||
|
@ -708,7 +708,7 @@ def show_properties(
|
||||
title: str,
|
||||
value: list[tuple[str, str]] | str,
|
||||
) -> LayoutObj[None]:
|
||||
"""Show a list of key-value pairs, or a chunkified string."""
|
||||
"""Show a list of key-value pairs, or a monospace string."""
|
||||
|
||||
|
||||
# rust/src/ui/api/firmware_micropython.rs
|
||||
|
@ -724,36 +724,32 @@ def confirm_value(
|
||||
is_data: bool = True,
|
||||
chunkify: bool = False,
|
||||
info_items: Iterable[tuple[str, str]] | None = None,
|
||||
info_title: str | None = None,
|
||||
chunkify_info: bool = False,
|
||||
cancel: bool = False,
|
||||
) -> Awaitable[None]:
|
||||
"""General confirmation dialog, used by many other confirm_* functions."""
|
||||
|
||||
info_items = info_items or []
|
||||
info_layout = trezorui_api.show_info_with_cancel(
|
||||
title=info_title if info_title else TR.words__title_information,
|
||||
items=info_items,
|
||||
chunkify=chunkify_info,
|
||||
from trezor.ui.layouts.menu import Menu, confirm_with_menu
|
||||
|
||||
main = trezorui_api.confirm_value(
|
||||
title=title,
|
||||
value=value,
|
||||
is_data=is_data,
|
||||
description=description,
|
||||
subtitle=subtitle,
|
||||
verb=verb,
|
||||
info=bool(info_items),
|
||||
hold=hold,
|
||||
chunkify=chunkify,
|
||||
cancel=cancel,
|
||||
external_menu=True,
|
||||
)
|
||||
|
||||
return with_info(
|
||||
trezorui_api.confirm_value(
|
||||
title=title,
|
||||
value=value,
|
||||
is_data=is_data,
|
||||
description=description,
|
||||
subtitle=subtitle,
|
||||
verb=verb,
|
||||
info=bool(info_items),
|
||||
hold=hold,
|
||||
chunkify=chunkify,
|
||||
cancel=cancel,
|
||||
),
|
||||
info_layout,
|
||||
br_name,
|
||||
br_code,
|
||||
info_items = info_items or []
|
||||
menu = Menu.root(
|
||||
(create_details(name, value) for name, value in info_items),
|
||||
cancel=TR.buttons__cancel,
|
||||
)
|
||||
return confirm_with_menu(main, menu, br_name, br_code)
|
||||
|
||||
|
||||
def confirm_properties(
|
||||
|
@ -982,6 +982,24 @@ class DebugUI:
|
||||
self.debuglink.press_info()
|
||||
|
||||
# TODO: support all core models
|
||||
if self.debuglink.model is models.T3T1:
|
||||
item_buttons = self.debuglink.screen_buttons.vertical_menu_items()
|
||||
close_button = self.debuglink.screen_buttons.menu()
|
||||
_prev, next = self.debuglink.screen_buttons.vertical_menu_prev_next()
|
||||
while True:
|
||||
menu_layout = self.debuglink.read_layout()
|
||||
menu_items = menu_layout.find_unique_value_by_key(
|
||||
key="menu_items", default=None, only_type=dict
|
||||
)
|
||||
for menu_item, item_button in zip(menu_items["current"], item_buttons):
|
||||
if "cancel" in menu_item:
|
||||
continue # skip cancellation by default
|
||||
self.debuglink.click(item_button)
|
||||
self.debuglink.click(close_button)
|
||||
if not menu_items["has_next"]:
|
||||
break
|
||||
self.debuglink.click(next)
|
||||
|
||||
if self.debuglink.model in (models.T2B1, models.T3B1):
|
||||
menu_items_count = self.debuglink.read_layout().page_count()
|
||||
for _ in range(menu_items_count):
|
||||
@ -1831,6 +1849,16 @@ class ScreenButtons:
|
||||
else:
|
||||
raise ValueError("Wrong layout type")
|
||||
|
||||
# vertical menu buttons
|
||||
def vertical_menu_prev_next(self) -> "list[Coords]":
|
||||
if self.layout_type is LayoutType.Delizia:
|
||||
return [
|
||||
(self._left(), self._grid(self._height(), 4, 3)),
|
||||
(self._right(), self._grid(self._height(), 4, 3)),
|
||||
]
|
||||
else:
|
||||
raise ValueError("Wrong layout type")
|
||||
|
||||
# Pin/passphrase keyboards
|
||||
def pin_passphrase_index(self, idx: int) -> Coords:
|
||||
assert idx < 10
|
||||
|
@ -2932,7 +2932,10 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
|
||||
if br.pages is not None:
|
||||
for _ in range(br.pages - 1):
|
||||
self.debug.swipe_up()
|
||||
layout = self.debug.read_layout()
|
||||
|
||||
# Visit info menus (if exist)
|
||||
layout = self.client.ui._visit_menu_items()
|
||||
|
||||
text = layout.footer().lower()
|
||||
# hi priority warning
|
||||
hi_prio = (
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user