diff --git a/core/embed/rust/src/ui/model_tt/component/page.rs b/core/embed/rust/src/ui/model_tt/component/page.rs index e0de300978..45da97e105 100644 --- a/core/embed/rust/src/ui/model_tt/component/page.rs +++ b/core/embed/rust/src/ui/model_tt/component/page.rs @@ -198,8 +198,8 @@ where { fn trace(&self, t: &mut dyn crate::trace::Tracer) { t.open("SwipePage"); - t.field("active_page", &self.scrollbar.active_page); - t.field("page_count", &self.scrollbar.page_count); + t.kw_pair("active_page", &self.scrollbar.active_page); + t.kw_pair("page_count", &self.scrollbar.page_count); t.field("content", &self.content); t.field("buttons", &self.buttons); t.close(); diff --git a/core/src/trezor/ui/layouts/tt_v2/__init__.py b/core/src/trezor/ui/layouts/tt_v2/__init__.py index e573056d7d..f40d91bbe7 100644 --- a/core/src/trezor/ui/layouts/tt_v2/__init__.py +++ b/core/src/trezor/ui/layouts/tt_v2/__init__.py @@ -1169,10 +1169,15 @@ async def confirm_set_new_pin( br_code=br_code, ) + if "wipe_code" in br_type: + title = "WIPE CODE INFO" + else: + title = "PIN INFORMATION" + return await confirm_action( ctx, br_type, - title="PIN INFO", + title=title, description="\n\n".join(information), br_code=br_code, ) diff --git a/python/src/trezorlib/debuglink.py b/python/src/trezorlib/debuglink.py index 24d54e5b0b..a7c408edc6 100644 --- a/python/src/trezorlib/debuglink.py +++ b/python/src/trezorlib/debuglink.py @@ -174,6 +174,17 @@ class LayoutButtons(LayoutBase): return None + def select_word_button_texts(self) -> List[str]: + """Get text of all buttons in the layout. + + Example button: "< Button text : LADYBUG >" + -> ["LADYBUG"] + + Only for TT. + """ + print("self.str_content", self.str_content) + return re.findall(r"< Button +text : +(.*?) +>", self.str_content) + class LayoutContent(LayoutBase): """Stores content of a layout as returned from Trezor. @@ -223,10 +234,6 @@ class LayoutContent(LayoutBase): def text_content(self) -> str: """Getting text that is displayed in the main part of the screen.""" raw = self.raw_content() - # print("self.str_content", self.str_content) - # print("raw", raw) - # replaved = raw.replace("\n", " ") - # print("replaved", replaved) return raw.replace("\n", " ") def raw_content(self) -> str: diff --git a/tests/click_tests/recovery.py b/tests/click_tests/recovery.py index 5374c42084..319dec185d 100644 --- a/tests/click_tests/recovery.py +++ b/tests/click_tests/recovery.py @@ -62,7 +62,7 @@ def enter_share( if legacy_ui: assert layout.str_content == "Slip39Keyboard" else: - assert layout.str_content == "< MnemonicKeyboard >" + assert "MnemonicKeyboard" in layout.str_content for word in share.split(" "): layout = enter_word(debug, word, is_slip39=True) diff --git a/tests/click_tests/reset.py b/tests/click_tests/reset.py index 03796b9df4..896e37540e 100644 --- a/tests/click_tests/reset.py +++ b/tests/click_tests/reset.py @@ -58,13 +58,13 @@ def read_words(debug: "DebugLink", is_advanced: bool = False) -> list[str]: def confirm_words(debug: "DebugLink", words: list[str]) -> None: layout = debug.wait_layout() - assert "Select word" in layout.str_content + assert "Select word" in layout.text_content() for _ in range(3): # "Select word 3 of 20" # ^ word_pos = int(layout.text_content().split()[2]) # Unifying both the buttons and words to lowercase - btn_texts = [text.lower() for text in layout.buttons()] + btn_texts = [text.lower() for text in layout.buttons.select_word_button_texts()] wanted_word = words[word_pos - 1].lower() button_pos = btn_texts.index(wanted_word) layout = debug.click(buttons.RESET_WORD_CHECK[button_pos], wait=True) diff --git a/tests/click_tests/test_autolock.py b/tests/click_tests/test_autolock.py index 1be25fde55..88b7944987 100644 --- a/tests/click_tests/test_autolock.py +++ b/tests/click_tests/test_autolock.py @@ -46,7 +46,7 @@ def set_autolock_delay(device_handler: "BackgroundDeviceHandler", delay_ms: int) device_handler.run(device.apply_settings, auto_lock_delay_ms=delay_ms) layout = debug.wait_layout() - assert layout.str_content == "< PinKeyboard >" + assert "PinKeyboard" in layout.str_content debug.input("1234") layout = debug.wait_layout() @@ -131,7 +131,7 @@ def test_dryrun_locks_at_number_of_words(device_handler: "BackgroundDeviceHandle layout = debug.wait_layout() assert "Do you really want to check the recovery seed?" in layout.text_content() layout = debug.click(buttons.OK, wait=True) - assert layout.str_content == "< PinKeyboard >" + assert "PinKeyboard" in layout.str_content layout = debug.input(PIN4, wait=True) assert "select the number of words " in layout.text_content() @@ -144,7 +144,7 @@ def test_dryrun_locks_at_number_of_words(device_handler: "BackgroundDeviceHandle # unlock layout = debug.click(buttons.OK, wait=True) - assert layout.str_content == "< PinKeyboard >" + assert "PinKeyboard" in layout.str_content layout = debug.input(PIN4, wait=True) # we are back at homescreen @@ -162,7 +162,7 @@ def test_dryrun_locks_at_word_entry(device_handler: "BackgroundDeviceHandler"): layout = debug.wait_layout() assert "Do you really want to check the recovery seed?" in layout.text_content() layout = debug.click(buttons.OK, wait=True) - assert layout.str_content == "< PinKeyboard >" + assert "PinKeyboard" in layout.str_content layout = debug.input(PIN4, wait=True) # select 20 words @@ -170,7 +170,7 @@ def test_dryrun_locks_at_word_entry(device_handler: "BackgroundDeviceHandler"): layout = debug.click(buttons.OK, wait=True) # make sure keyboard locks - assert layout.str_content == "< MnemonicKeyboard >" + assert "MnemonicKeyboard" in layout.str_content time.sleep(10.1) layout = debug.wait_layout() assert layout.str_content.startswith("< Lockscreen") @@ -189,7 +189,7 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"): layout = debug.wait_layout() assert "Do you really want to check the recovery seed?" in layout.text_content() layout = debug.click(buttons.OK, wait=True) - assert layout.str_content == "< PinKeyboard >" + assert "PinKeyboard" in layout.str_content layout = debug.input(PIN4, wait=True) # select 20 words @@ -197,11 +197,11 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"): layout = debug.click(buttons.OK, wait=True) # type the word OCEAN slowly - assert layout.str_content == "< MnemonicKeyboard >" + assert "MnemonicKeyboard" in layout.str_content for coords in buttons.type_word("ocea", is_slip39=True): time.sleep(9) debug.click(coords) layout = debug.click(buttons.CONFIRM_WORD, wait=True) # should not have locked, even though we took 9 seconds to type each letter - assert layout.str_content == "< MnemonicKeyboard >" + assert "MnemonicKeyboard" in layout.str_content device_handler.kill_task() diff --git a/tests/click_tests/test_lock.py b/tests/click_tests/test_lock.py index dda1f17a35..abb88561bb 100644 --- a/tests/click_tests/test_lock.py +++ b/tests/click_tests/test_lock.py @@ -41,7 +41,7 @@ def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"): # unlock with message device_handler.run(common.get_test_address) layout = debug.wait_layout() - assert layout.str_content == "< PinKeyboard >" + assert "PinKeyboard" in layout.str_content debug.input("1234", wait=True) assert device_handler.result() @@ -57,7 +57,7 @@ def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"): # unlock by touching layout = debug.click(buttons.INFO, wait=True) - assert layout.str_content == "< PinKeyboard >" + assert "PinKeyboard" in layout.str_content debug.input("1234", wait=True) assert device_handler.features().unlocked is True diff --git a/tests/click_tests/test_reset_slip39_basic.py b/tests/click_tests/test_reset_slip39_basic.py index 175ac2d625..2426e0af96 100644 --- a/tests/click_tests/test_reset_slip39_basic.py +++ b/tests/click_tests/test_reset_slip39_basic.py @@ -78,6 +78,7 @@ def test_reset_slip39_basic_1of1(device_handler: "BackgroundDeviceHandler"): # read words words = reset.read_words(debug) + print("words", words) # confirm words reset.confirm_words(debug, words) diff --git a/tests/input_flows.py b/tests/input_flows.py index 4dd0726469..153d178403 100644 --- a/tests/input_flows.py +++ b/tests/input_flows.py @@ -74,6 +74,8 @@ class InputFlowSetupDevicePINWIpeCode(InputFlowBase): def input_flow_common(self) -> GeneratorType: yield # do you want to set/change the wipe_code? self.debug.press_yes() + yield # wipe code info + self.debug.press_yes() yield # enter current pin self.debug.input(self.pin) yield # enter new wipe code diff --git a/tests/persistence_tests/test_shamir_persistence.py b/tests/persistence_tests/test_shamir_persistence.py index 9a90d9742e..f91ac48b7b 100644 --- a/tests/persistence_tests/test_shamir_persistence.py +++ b/tests/persistence_tests/test_shamir_persistence.py @@ -53,7 +53,7 @@ def test_abort(emulator: Emulator): assert layout.title() == "RECOVERY MODE" layout = debug.click(buttons.OK, wait=True) - assert "select the number of words" in layout.str_content + assert "select the number of words" in layout.text_content() device_handler.restart(emulator) debug = device_handler.debuglink() @@ -63,7 +63,7 @@ def test_abort(emulator: Emulator): # no waiting for layout because layout doesn't change layout = debug.read_layout() - assert "select the number of words" in layout.str_content + assert "select the number of words" in layout.text_content() layout = debug.click(buttons.CANCEL, wait=True) assert layout.title() == "ABORT RECOVERY" @@ -139,7 +139,7 @@ def test_recovery_on_old_wallet(emulator: Emulator): assert "Enter any share" in layout.str_content debug.press_yes() layout = debug.wait_layout() - assert layout.str_content == "< MnemonicKeyboard >" + assert "MnemonicKeyboard" in layout.str_content # enter first word debug.input(words[0]) @@ -151,7 +151,7 @@ def test_recovery_on_old_wallet(emulator: Emulator): # try entering remaining 19 words for word in words[1:]: - assert layout.str_content == "< MnemonicKeyboard >" + assert "MnemonicKeyboard" in layout.str_content debug.input(word) layout = debug.wait_layout()