1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-03-06 18:26:11 +00:00

WIP: chore(tests): modularize tests buttons module

This commit is contained in:
Lukas Bielesch 2025-03-05 16:07:08 +01:00
parent f67a506e9c
commit ea142bbdba
21 changed files with 430 additions and 320 deletions

View File

@ -1,85 +1,178 @@
import time
from typing import Iterator, Tuple
from trezorlib.debuglink import LayoutType
Coords = Tuple[int, int]
DISPLAY_WIDTH = 240
DISPLAY_HEIGHT = 240
# display dimensions
def display_height(layout_type):
if layout_type in (LayoutType.Bolt, LayoutType.Delizia):
return 240
else:
raise ValueError("Wrong layout type")
def display_width(layout_type):
if layout_type in (LayoutType.Bolt, LayoutType.Delizia):
return 240
else:
raise ValueError("Wrong layout type")
# grid coordinates
def grid(dim: int, grid_cells: int, cell: int) -> int:
step = dim // grid_cells
ofs = step // 2
return cell * step + ofs
def grid35(x: int, y: int) -> Coords:
return grid(DISPLAY_WIDTH, 3, x), grid(DISPLAY_HEIGHT, 5, y)
def grid35(x: int, y: int, layout_type: LayoutType) -> Coords:
return grid(display_width(layout_type), 3, x), grid(
display_height(layout_type), 5, y
)
def grid34(x: int, y: int) -> Coords:
return grid(DISPLAY_WIDTH, 3, x), grid(DISPLAY_HEIGHT, 4, y)
def grid34(x: int, y: int, layout_type: LayoutType) -> Coords:
assert layout_type in (LayoutType.Bolt, LayoutType.Delizia)
return grid(display_width(layout_type), 3, x), grid(
display_height(layout_type), 4, y
)
def _grid34_from_index(idx: int) -> Coords:
def _grid34_from_index(idx: int, layout_type: LayoutType) -> Coords:
grid_x = idx % 3
grid_y = idx // 3 + 1 # first line is empty
return grid34(grid_x, grid_y)
return grid34(grid_x, grid_y, layout_type)
LEFT = grid(DISPLAY_WIDTH, 3, 0)
MID = grid(DISPLAY_WIDTH, 3, 1)
RIGHT = grid(DISPLAY_WIDTH, 3, 2)
TOP = grid(DISPLAY_HEIGHT, 6, 0)
BOTTOM = grid(DISPLAY_HEIGHT, 6, 5)
OK = (RIGHT, BOTTOM)
CANCEL = (LEFT, BOTTOM)
INFO = (MID, BOTTOM)
RECOVERY_DELETE = (LEFT, TOP)
CORNER_BUTTON = (215, 25)
CONFIRM_WORD = (MID, TOP)
TOP_ROW = (MID, TOP)
YES_UI_DELIZIA = grid34(2, 2)
NO_UI_DELIZIA = grid34(0, 2)
# Horizontal coordinates
def left(layout_type: LayoutType):
return grid(display_width(layout_type), 3, 0)
def reset_minus(model_internal_name: str) -> Coords:
RESET_MINUS_T3T1 = (LEFT, grid(DISPLAY_HEIGHT, 5, 3))
RESET_MINUS = (LEFT, grid(DISPLAY_HEIGHT, 5, 1))
if model_internal_name == "T3T1":
return RESET_MINUS_T3T1
def mid(layout_type: LayoutType):
return grid(display_width(layout_type), 3, 1)
def right(layout_type: LayoutType):
return grid(display_width(layout_type), 3, 2)
# Vertical coordinates
def top(layout_type: LayoutType):
return grid(display_height(layout_type), 6, 0)
def bottom(layout_type: LayoutType):
return grid(display_height(layout_type), 6, 5)
# Buttons
def ok(layout_type: LayoutType) -> Coords:
return (right(layout_type), bottom(layout_type))
def cancel(layout_type: LayoutType) -> Coords:
return (left(layout_type), bottom(layout_type))
def info(layout_type: LayoutType) -> Coords:
return (mid(layout_type), bottom(layout_type))
def recovery_delete(layout_type: LayoutType) -> Coords:
if layout_type in (LayoutType.Bolt, LayoutType.Delizia):
return (left(layout_type), top(layout_type))
else:
return RESET_MINUS
raise ValueError("Wrong layout type")
def reset_plus(model_internal_name: str) -> Coords:
RESET_PLUS_T3T1 = (RIGHT, grid(DISPLAY_HEIGHT, 5, 3))
RESET_PLUS = (RIGHT, grid(DISPLAY_HEIGHT, 5, 1))
if model_internal_name == "T3T1":
return RESET_PLUS_T3T1
def corner_button(layout_type: LayoutType) -> Coords:
if layout_type in (LayoutType.Bolt, LayoutType.Delizia):
return (215, 25)
else:
return RESET_PLUS
raise ValueError("Wrong layout type")
RESET_WORD_CHECK = [
(MID, grid(DISPLAY_HEIGHT, 5, 2)),
(MID, grid(DISPLAY_HEIGHT, 5, 3)),
(MID, grid(DISPLAY_HEIGHT, 5, 4)),
]
def confirm_word(layout_type: LayoutType) -> Coords:
if layout_type in (LayoutType.Bolt, LayoutType.Delizia):
return (mid(layout_type), top(layout_type))
else:
raise ValueError("Wrong layout type")
VERTICAL_MENU = [
(MID, grid(DISPLAY_HEIGHT, 4, 1)),
(MID, grid(DISPLAY_HEIGHT, 4, 2)),
(MID, grid(DISPLAY_HEIGHT, 4, 3)),
]
TAP_TO_CONFIRM = VERTICAL_MENU[1]
# PIN/passphrase input
def input(layout_type: LayoutType) -> Coords:
return (mid(layout_type), top(layout_type))
# Yes/No decision component
def ui_yes(layout_type: LayoutType) -> Coords:
assert layout_type is LayoutType.Delizia
return grid34(2, 2, layout_type)
def ui_no(layout_type: LayoutType) -> Coords:
assert layout_type is LayoutType.Delizia
return grid34(0, 2, layout_type)
# +/- buttons in number input component
def reset_minus(layout_type: LayoutType) -> Coords:
if layout_type is LayoutType.Bolt:
return (left(layout_type), grid(display_height(layout_type), 5, 1))
elif layout_type is LayoutType.Caesar:
# TODO temporary workaround to make the 'set_selection' function work
return (left(layout_type), grid(display_height(layout_type), 5, 1))
elif layout_type is LayoutType.Delizia:
return (left(layout_type), grid(display_height(layout_type), 5, 3))
else:
raise ValueError("Wrong layout type")
def reset_plus(layout_type: LayoutType) -> Coords:
if layout_type is LayoutType.Bolt:
return (right(layout_type), grid(display_height(layout_type), 5, 1))
elif layout_type is LayoutType.Caesar:
# TODO temporary workaround to make the 'set_selection' function work
return (right(layout_type), grid(display_height(layout_type), 5, 1))
elif layout_type is LayoutType.Delizia:
return (right(layout_type), grid(display_height(layout_type), 5, 3))
else:
raise ValueError("Wrong layout type")
# select word component buttons
def reset_word_check(layout_type: LayoutType) -> Coords:
if layout_type in (LayoutType.Bolt, LayoutType.Delizia):
return [
(mid(layout_type), grid(display_height(layout_type), 5, 2)),
(mid(layout_type), grid(display_height(layout_type), 5, 3)),
(mid(layout_type), grid(display_height(layout_type), 5, 4)),
]
else:
raise ValueError("Wrong layout type")
# vertical menu buttons
def vertical_menu(layout_type: LayoutType) -> Coords:
if layout_type in (LayoutType.Bolt, LayoutType.Delizia):
return [
(mid(layout_type), grid(display_height(layout_type), 4, 1)),
(mid(layout_type), grid(display_height(layout_type), 4, 2)),
(mid(layout_type), grid(display_height(layout_type), 4, 3)),
]
else:
raise ValueError("Wrong layout type")
def tap_to_confirm(layout_type: LayoutType) -> Coords:
assert layout_type is LayoutType.Delizia
return vertical_menu(layout_type)[1]
BUTTON_LETTERS_BIP39 = ("abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "yz")
@ -107,43 +200,45 @@ def get_passphrase_choices(char: str) -> tuple[str, ...]:
return PASSPHRASE_SPECIAL
def passphrase(char: str) -> Tuple[Coords, int]:
def passphrase(char: str, layout_type: LayoutType) -> Tuple[Coords, int]:
choices = get_passphrase_choices(char)
idx = next(i for i, letters in enumerate(choices) if char in letters)
click_amount = choices[idx].index(char) + 1
return pin_passphrase_index(idx), click_amount
return pin_passphrase_index(idx, layout_type), click_amount
def pin_passphrase_index(idx: int) -> Coords:
def pin_passphrase_index(idx: int, layout_type: LayoutType) -> Coords:
if idx == 9:
idx = 10 # last digit is in the middle
return pin_passphrase_grid(idx)
return pin_passphrase_grid(idx, layout_type)
def pin_passphrase_grid(idx: int) -> Coords:
def pin_passphrase_grid(idx: int, layout_type: LayoutType) -> Coords:
grid_x = idx % 3
grid_y = idx // 3 + 1 # first line is empty
return grid35(grid_x, grid_y)
return grid35(grid_x, grid_y, layout_type)
def type_word(word: str, is_slip39: bool = False) -> Iterator[Coords]:
def type_word(
word: str, layout_type: LayoutType, is_slip39: bool = False
) -> Iterator[Coords]:
if is_slip39:
yield from _type_word_slip39(word)
yield from _type_word_slip39(word, layout_type)
else:
yield from _type_word_bip39(word)
yield from _type_word_bip39(word, layout_type)
def _type_word_slip39(word: str) -> Iterator[Coords]:
def _type_word_slip39(word: str, layout_type: LayoutType) -> Iterator[Coords]:
for l in word:
idx = next(i for i, letters in enumerate(BUTTON_LETTERS_SLIP39) if l in letters)
yield _grid34_from_index(idx)
yield _grid34_from_index(idx, layout_type)
def _type_word_bip39(word: str) -> Iterator[Coords]:
def _type_word_bip39(word: str, layout_type: LayoutType) -> Iterator[Coords]:
coords_prev: Coords | None = None
for letter in word:
time.sleep(0.1) # not being so quick to miss something
coords, amount = _letter_coords_and_amount(letter)
coords, amount = _letter_coords_and_amount(letter, layout_type)
# If the button is the same as for the previous letter,
# waiting a second before pressing it again.
if coords == coords_prev:
@ -153,7 +248,9 @@ def _type_word_bip39(word: str) -> Iterator[Coords]:
yield coords
def _letter_coords_and_amount(letter: str) -> Tuple[Coords, int]:
def _letter_coords_and_amount(
letter: str, layout_type: LayoutType
) -> Tuple[Coords, int]:
idx = next(i for i, letters in enumerate(BUTTON_LETTERS_BIP39) if letter in letters)
click_amount = BUTTON_LETTERS_BIP39[idx].index(letter) + 1
return _grid34_from_index(idx), click_amount
return _grid34_from_index(idx, layout_type), click_amount

View File

@ -49,7 +49,7 @@ def get_char_category(char: str) -> PassphraseCategory:
def go_next(debug: "DebugLink") -> LayoutContent:
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_right()
elif debug.layout_type is LayoutType.Delizia:
@ -61,7 +61,7 @@ def go_next(debug: "DebugLink") -> LayoutContent:
def go_back(debug: "DebugLink", r_middle: bool = False) -> LayoutContent:
if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia):
debug.click(buttons.CANCEL)
debug.click(buttons.cancel(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
if r_middle:
debug.press_middle()
@ -116,11 +116,11 @@ def _carousel_steps(current_index: int, wanted_index: int, length: int) -> int:
def unlock_gesture(debug: "DebugLink") -> LayoutContent:
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_right()
elif debug.layout_type is LayoutType.Delizia:
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
else:
raise RuntimeError("Unknown model")
return debug.read_layout()

View File

@ -140,14 +140,16 @@ def send_clicks(dest):
DEBUGLINK.input(input_str)
elif key.startswith("g"):
x, y = [int(s) - 1 for s in key[1:].split(",")]
output = f"debug.click(buttons.grid35({x}, {y}))"
DEBUGLINK.click(buttons.grid35(x, y))
output = (
f"debug.click(buttons.grid35({x}, {y}, {DEBUGLINK.layout_type}))"
)
DEBUGLINK.click(buttons.grid35(x, y, DEBUGLINK.layout_type))
elif key == "y":
output = "debug.click(buttons.OK)"
DEBUGLINK.click(buttons.OK)
output = "debug.click(buttons.ok(layout_type))"
DEBUGLINK.click(buttons.ok(DEBUGLINK.layout_type))
elif key == "n":
output = "debug.click(buttons.CANCEL)"
DEBUGLINK.click(buttons.CANCEL)
output = "debug.click(buttons.cancel(layout_type))"
DEBUGLINK.click(buttons.cancel(DEBUGLINK.layout_type))
elif key in "0123456789":
if key == "0":
x, y = 1, 4
@ -155,8 +157,10 @@ def send_clicks(dest):
i = int(key) - 1
x = i % 3
y = 3 - (i // 3) # trust me
output = f"debug.click(buttons.grid35({x}, {y}))"
DEBUGLINK.click(buttons.grid35(x, y))
output = (
f"debug.click(buttons.grid35({x}, {y}, {DEBUGLINK.layout_type}))"
)
DEBUGLINK.click(buttons.grid35(x, y, DEBUGLINK.layout_type))
elif key == "stop":
return
else:

View File

@ -18,12 +18,14 @@ def enter_word(
) -> "LayoutContent":
if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia):
typed_word = word[:4]
for coords in buttons.type_word(typed_word, is_slip39=is_slip39):
for coords in buttons.type_word(
typed_word, debug.layout_type, is_slip39=is_slip39
):
debug.click(coords)
if debug.layout_type is LayoutType.Delizia and not is_slip39 and len(word) > 4:
# T3T1 (delizia) BIP39 keyboard allows to "confirm" only if the word is fully written, you need to click the word to auto-complete
debug.click(buttons.CONFIRM_WORD)
debug.click(buttons.CONFIRM_WORD)
debug.click(buttons.input(debug.layout_type))
debug.click(buttons.input(debug.layout_type))
return debug.read_layout()
elif debug.layout_type is LayoutType.Caesar:
letter_index = 0
@ -55,7 +57,7 @@ def confirm_recovery(debug: "DebugLink", title: str = "recovery__title") -> None
layout = debug.read_layout()
assert TR.translate(title) == layout.title()
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
debug.swipe_up()
elif debug.layout_type is LayoutType.Caesar:
@ -71,9 +73,9 @@ def cancel_select_number_of_words(
assert debug.read_layout().text_content() == TR.recovery__num_of_words
# click the button from ValuePad
if unlock_repeated_backup:
coords = buttons.grid34(0, 2)
coords = buttons.grid34(0, 2, debug.layout_type)
else:
coords = buttons.grid34(0, 3)
coords = buttons.grid34(0, 3, debug.layout_type)
debug.click(coords)
elif debug.layout_type is LayoutType.Caesar:
debug.press_right()
@ -83,11 +85,7 @@ def cancel_select_number_of_words(
debug.press_left()
elif debug.layout_type is LayoutType.Delizia:
# click the button from ValuePad
if unlock_repeated_backup:
coords = buttons.grid34(0, 3)
else:
coords = buttons.grid34(0, 3)
debug.click(coords)
debug.click(buttons.grid34(0, 3, debug.layout_type))
else:
raise ValueError("Unknown model")
@ -103,14 +101,17 @@ def select_number_of_words(
def select_bolt() -> "LayoutContent":
# click the button from ValuePad
if unlock_repeated_backup:
coords_map = {20: buttons.grid34(1, 2), 33: buttons.grid34(2, 2)}
coords_map = {
20: buttons.grid34(1, 2, debug.layout_type),
33: buttons.grid34(2, 2, debug.layout_type),
}
else:
coords_map = {
12: buttons.grid34(0, 2),
18: buttons.grid34(1, 2),
20: buttons.grid34(2, 2),
24: buttons.grid34(1, 3),
33: buttons.grid34(2, 3),
12: buttons.grid34(0, 2, debug.layout_type),
18: buttons.grid34(1, 2, debug.layout_type),
20: buttons.grid34(2, 2, debug.layout_type),
24: buttons.grid34(1, 3, debug.layout_type),
33: buttons.grid34(2, 3, debug.layout_type),
}
coords = coords_map.get(num_of_words)
if coords is None:
@ -130,14 +131,17 @@ def select_number_of_words(
def select_delizia() -> "LayoutContent":
# click the button from ValuePad
if unlock_repeated_backup:
coords_map = {20: buttons.grid34(0, 1), 33: buttons.grid34(2, 1)}
coords_map = {
20: buttons.grid34(0, 1, debug.layout_type),
33: buttons.grid34(2, 1, debug.layout_type),
}
else:
coords_map = {
12: buttons.grid34(0, 1),
18: buttons.grid34(2, 1),
20: buttons.grid34(0, 2),
24: buttons.grid34(2, 2),
33: buttons.grid34(2, 3),
12: buttons.grid34(0, 1, debug.layout_type),
18: buttons.grid34(2, 1, debug.layout_type),
20: buttons.grid34(0, 2, debug.layout_type),
24: buttons.grid34(2, 2, debug.layout_type),
33: buttons.grid34(2, 3, debug.layout_type),
}
coords = coords_map.get(num_of_words)
if coords is None:
@ -197,7 +201,7 @@ def enter_share(
layout = debug.read_layout()
else:
assert TR.translate(before_title) in debug.read_layout().title()
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
layout = debug.read_layout()
assert "MnemonicKeyboard" in layout.all_components()
@ -274,7 +278,7 @@ def enter_seed_previous_correct(
if debug.layout_type is LayoutType.Bolt:
debug.swipe_right()
for _ in range(len(bad_word)):
debug.click(buttons.RECOVERY_DELETE)
debug.click(buttons.recovery_delete(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
layout = debug.read_layout()
@ -291,9 +295,9 @@ def enter_seed_previous_correct(
debug.press_middle()
layout = debug.read_layout()
elif debug.layout_type is LayoutType.Delizia:
debug.click(buttons.RECOVERY_DELETE) # Top-left
debug.click(buttons.recovery_delete(debug.layout_type)) # Top-left
for _ in range(len(bad_word)):
debug.click(buttons.RECOVERY_DELETE)
debug.click(buttons.recovery_delete(debug.layout_type))
continue
if i in bad_indexes:
@ -318,7 +322,7 @@ def prepare_enter_seed(
or TR.translate(layout_text) in debug.read_layout().text_content()
)
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
debug.swipe_up()
debug.swipe_up()
@ -344,10 +348,10 @@ def cancel_recovery(debug: "DebugLink", recovery_type: str = "dry_run") -> None:
assert title in layout.title()
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.CANCEL)
debug.click(buttons.cancel(debug.layout_type))
layout = debug.read_layout()
assert cancel_title in layout.title()
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_left()
layout = debug.read_layout()
@ -356,12 +360,12 @@ def cancel_recovery(debug: "DebugLink", recovery_type: str = "dry_run") -> None:
debug.press_right()
elif debug.layout_type is LayoutType.Delizia:
# go to menu
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
layout = debug.read_layout()
assert (
TR.translate(f"recovery__cancel_{recovery_type}") in layout.text_content()
)
debug.click(buttons.VERTICAL_MENU[0])
debug.click(buttons.vertical_menu(debug.layout_type)[0])
else:
raise ValueError("Unknown model")

View File

@ -15,10 +15,10 @@ if TYPE_CHECKING:
def confirm_new_wallet(debug: "DebugLink") -> None:
assert debug.read_layout().title() == TR.reset__title_create_wallet
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
debug.swipe_up()
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_right()
debug.press_right()
@ -32,7 +32,7 @@ def confirm_new_wallet(debug: "DebugLink") -> None:
def confirm_read(debug: "DebugLink", middle_r: bool = False) -> None:
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
debug.swipe_up()
elif debug.layout_type is LayoutType.Caesar:
@ -50,14 +50,14 @@ def cancel_backup(
debug: "DebugLink", middle_r: bool = False, confirm: bool = False
) -> None:
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.CANCEL)
debug.click(buttons.CANCEL)
debug.click(buttons.cancel(debug.layout_type))
debug.click(buttons.cancel(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.VERTICAL_MENU[0])
debug.click(buttons.corner_button(debug.layout_type))
debug.click(buttons.vertical_menu(debug.layout_type)[0])
if confirm:
debug.swipe_up()
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_left()
debug.press_left()
@ -69,7 +69,7 @@ def set_selection(debug: "DebugLink", button: tuple[int, int], diff: int) -> Non
for _ in range(diff):
debug.click(button)
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
else:
debug.swipe_up()
elif debug.layout_type is LayoutType.Caesar:
@ -82,7 +82,7 @@ def set_selection(debug: "DebugLink", button: tuple[int, int], diff: int) -> Non
debug.press_right()
layout = debug.read_layout()
assert "NumberInput" in layout.all_components()
if button == buttons.reset_minus(debug.model.internal_name):
if button == buttons.reset_minus(debug.layout_type):
for _ in range(diff):
debug.press_left()
else:
@ -115,9 +115,9 @@ def read_words(debug: "DebugLink", do_htc: bool = True) -> list[str]:
# There is hold-to-confirm button
if do_htc:
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK, hold_ms=1500)
debug.click(buttons.ok(debug.layout_type), hold_ms=1500)
elif debug.layout_type is LayoutType.Delizia:
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_right(hold_ms=1200)
else:
@ -149,7 +149,7 @@ def confirm_words(debug: "DebugLink", words: list[str]) -> None:
]
wanted_word = words[word_pos - 1].lower()
button_pos = btn_texts.index(wanted_word)
debug.click(buttons.RESET_WORD_CHECK[button_pos])
debug.click(buttons.reset_word_check(debug.layout_type)[button_pos])
layout = debug.read_layout()
elif debug.layout_type is LayoutType.Delizia:
assert TR.regexp("reset__select_word_x_of_y_template").match(layout.subtitle())
@ -165,7 +165,7 @@ def confirm_words(debug: "DebugLink", words: list[str]) -> None:
]
wanted_word = words[word_pos - 1].lower()
button_pos = btn_texts.index(wanted_word)
debug.click(buttons.VERTICAL_MENU[button_pos])
debug.click(buttons.vertical_menu(debug.layout_type)[button_pos])
layout = debug.read_layout()
elif debug.layout_type is LayoutType.Caesar:
assert TR.reset__select_correct_word in layout.text_content()

View File

@ -16,7 +16,7 @@
import math
import time
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Tuple
import pytest
@ -52,8 +52,9 @@ TXHASH_d5f65e = bytes.fromhex(
PIN4 = "1234"
WORDS_20 = buttons.grid34(2, 2)
CENTER_BUTTON = buttons.grid35(1, 2)
def center_button(layout_type: LayoutType) -> Tuple[int, int]:
return buttons.grid35(1, 2, layout_type)
def set_autolock_delay(device_handler: "BackgroundDeviceHandler", delay_ms: int):
@ -71,7 +72,7 @@ def set_autolock_delay(device_handler: "BackgroundDeviceHandler", delay_ms: int)
layout = go_next(debug)
if debug.layout_type is LayoutType.Delizia:
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
layout = debug.read_layout()
assert layout.main_component() == "Homescreen"
device_handler.result()
@ -106,8 +107,8 @@ def test_autolock_interrupts_signing(device_handler: "BackgroundDeviceHandler"):
)
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
debug.click(buttons.ok(debug.layout_type))
layout = debug.read_layout()
assert TR.send__total_amount in layout.text_content()
assert "0.0039 BTC" in layout.text_content()
@ -161,8 +162,8 @@ def test_autolock_does_not_interrupt_signing(device_handler: "BackgroundDeviceHa
)
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
debug.click(buttons.ok(debug.layout_type))
layout = debug.read_layout()
assert TR.send__total_amount in layout.text_content()
assert "0.0039 BTC" in layout.text_content()
@ -189,9 +190,9 @@ def test_autolock_does_not_interrupt_signing(device_handler: "BackgroundDeviceHa
device_handler.client.set_filter(messages.TxAck, sleepy_filter)
# confirm transaction
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_middle()
@ -221,7 +222,7 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
for _ in range(math.ceil(11 / 1.5)):
if debug.layout_type is LayoutType.Bolt:
# click at "j"
debug.click(CENTER_BUTTON)
debug.click(center_button(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
# click at "j"
debug.click((20, 120))
@ -234,9 +235,9 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
# Send the passphrase to the client (TT has it clicked already, TR needs to input it)
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
elif debug.layout_type is LayoutType.Delizia:
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.input("j" * 8)
@ -262,7 +263,7 @@ def test_autolock_interrupts_passphrase(device_handler: "BackgroundDeviceHandler
# autolock must activate even if we pressed some buttons
for _ in range(math.ceil(6 / 1.5)):
if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia):
debug.click(CENTER_BUTTON)
debug.click(center_button(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
debug.press_middle()
time.sleep(1.5)
@ -358,15 +359,15 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"):
recovery.select_number_of_words(debug, 20)
if debug.layout_type is LayoutType.Bolt:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
layout = debug.read_layout()
assert layout.main_component() == "MnemonicKeyboard"
# type the word OCEAN slowly
for coords in buttons.type_word("ocea", is_slip39=True):
for coords in buttons.type_word("ocea", debug.layout_type, is_slip39=True):
time.sleep(9)
debug.click(coords)
debug.click(buttons.CONFIRM_WORD)
debug.click(buttons.input(debug.layout_type))
layout = debug.read_layout()
# should not have locked, even though we took 9 seconds to type each letter
assert layout.main_component() == "MnemonicKeyboard"
@ -377,10 +378,10 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"):
assert layout.main_component() == "MnemonicKeyboard"
# type the word OCEAN slowly
for coords in buttons.type_word("ocea", is_slip39=True):
for coords in buttons.type_word("ocea", debug.layout_type, is_slip39=True):
time.sleep(9)
debug.click(coords)
debug.click(buttons.CONFIRM_WORD)
debug.click(buttons.input(debug.layout_type))
layout = debug.read_layout()
# should not have locked, even though we took 9 seconds to type each letter
assert layout.main_component() == "MnemonicKeyboard"

View File

@ -81,7 +81,7 @@ def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"):
if debug.layout_type is LayoutType.Caesar:
debug.press_right()
else:
debug.click(buttons.INFO)
debug.click(buttons.info(debug.layout_type))
layout = debug.read_layout()
assert "PinKeyboard" in layout.all_components()
debug.input("1234")

View File

@ -117,7 +117,7 @@ def press_char(debug: "DebugLink", char: str) -> None:
go_to_category(debug, char_category)
coords, amount = buttons.passphrase(char)
coords, amount = buttons.passphrase(char, debug.layout_type)
# If the button is the same as for the previous char,
# waiting a second before pressing it again.
# (not for a space)
@ -141,13 +141,13 @@ def input_passphrase(debug: "DebugLink", passphrase: str, check: bool = True) ->
def enter_passphrase(debug: "DebugLink") -> None:
"""Enter a passphrase"""
coords = buttons.pin_passphrase_grid(11)
coords = buttons.pin_passphrase_grid(11, debug.layout_type)
debug.click(coords)
def delete_char(debug: "DebugLink") -> None:
"""Deletes the last char"""
coords = buttons.pin_passphrase_grid(9)
coords = buttons.pin_passphrase_grid(9, debug.layout_type)
debug.click(coords)
@ -216,7 +216,7 @@ def test_passphrase_loop_all_characters(device_handler: "BackgroundDeviceHandler
go_to_category(debug, category)
enter_passphrase(debug)
coords = buttons.pin_passphrase_grid(11)
coords = buttons.pin_passphrase_grid(11, debug.layout_type)
debug.click(coords)
@ -225,7 +225,7 @@ def test_passphrase_click_same_button_many_times(
device_handler: "BackgroundDeviceHandler",
):
with prepare_passphrase_dialogue(device_handler) as debug:
a_coords, _ = buttons.passphrase("a")
a_coords, _ = buttons.passphrase("a", debug.layout_type)
for _ in range(10):
debug.click(a_coords)

View File

@ -21,6 +21,7 @@ from typing import TYPE_CHECKING, Generator, Optional, Tuple
import pytest
from trezorlib import exceptions
from trezorlib.debuglink import LayoutType
from .. import buttons
from ..common import get_test_address
@ -85,11 +86,11 @@ def get_passphrase_choices(char: str) -> tuple[str, ...]:
return PASSPHRASE_SPECIAL
def passphrase(char: str) -> Tuple[buttons.Coords, int]:
def passphrase(char: str, layout_type: LayoutType) -> Tuple[buttons.Coords, int]:
choices = get_passphrase_choices(char)
idx = next(i for i, letters in enumerate(choices) if char in letters)
click_amount = choices[idx].index(char) + 1
return buttons.pin_passphrase_index(idx), click_amount
return buttons.pin_passphrase_index(idx, layout_type), click_amount
@contextmanager
@ -146,7 +147,7 @@ def press_char(debug: "DebugLink", char: str) -> None:
go_to_category(debug, char_category)
coords, amount = passphrase(char)
coords, amount = passphrase(char, debug.layout_type)
# If the button is the same as for the previous char,
# waiting a second before pressing it again.
if coords == COORDS_PREV:
@ -170,15 +171,15 @@ def input_passphrase(debug: "DebugLink", passphrase: str, check: bool = True) ->
def enter_passphrase(debug: "DebugLink") -> None:
"""Enter a passphrase"""
is_empty: bool = len(debug.read_layout().passphrase()) == 0
coords = buttons.CORNER_BUTTON # top-right corner
coords = buttons.corner_button(debug.layout_type) # top-right corner
debug.click(coords)
if is_empty:
debug.click(buttons.YES_UI_DELIZIA)
debug.click(buttons.ui_yes(debug.layout_type))
def delete_char(debug: "DebugLink") -> None:
"""Deletes the last char"""
coords = buttons.pin_passphrase_grid(9)
coords = buttons.pin_passphrase_grid(9, debug.layout_type)
debug.click(coords)
@ -249,7 +250,7 @@ def test_passphrase_loop_all_characters(device_handler: "BackgroundDeviceHandler
debug.read_layout()
enter_passphrase(debug)
coords = buttons.pin_passphrase_grid(11)
coords = buttons.pin_passphrase_grid(11, debug.layout_type)
debug.click(coords)
@ -258,7 +259,7 @@ def test_passphrase_click_same_button_many_times(
device_handler: "BackgroundDeviceHandler",
):
with prepare_passphrase_dialogue(device_handler) as debug:
a_coords, _ = buttons.passphrase("a")
a_coords, _ = buttons.passphrase("a", debug.layout_type)
for _ in range(10):
debug.click(a_coords)

View File

@ -139,7 +139,7 @@ def prepare(
if debug.layout_type is LayoutType.Delizia and tap:
go_next(debug)
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
else:
go_next(debug)
@ -159,7 +159,7 @@ def _input_pin(debug: "DebugLink", pin: str, check: bool = False) -> None:
digits_order = debug.read_layout().tt_pin_digits_order()
for digit in pin:
digit_index = digits_order.index(digit)
coords = buttons.pin_passphrase_index(digit_index)
coords = buttons.pin_passphrase_index(digit_index, debug.layout_type)
debug.click(coords)
elif debug.layout_type is LayoutType.Caesar:
for digit in pin:
@ -173,7 +173,7 @@ def _input_pin(debug: "DebugLink", pin: str, check: bool = False) -> None:
def _see_pin(debug: "DebugLink") -> None:
"""Navigate to "SHOW" and press it"""
if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia):
debug.click(buttons.TOP_ROW)
debug.click(buttons.input(debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
navigate_to_action_and_press(debug, SHOW, TR_PIN_ACTIONS)
@ -185,7 +185,7 @@ def _delete_pin(debug: "DebugLink", digits_to_delete: int, check: bool = True) -
for _ in range(digits_to_delete):
if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia):
debug.click(buttons.pin_passphrase_grid(9))
debug.click(buttons.pin_passphrase_grid(9, debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
navigate_to_action_and_press(debug, DELETE, TR_PIN_ACTIONS)
@ -197,7 +197,7 @@ def _delete_pin(debug: "DebugLink", digits_to_delete: int, check: bool = True) -
def _delete_all(debug: "DebugLink", check: bool = True) -> None:
"""Navigate to "DELETE" and hold it until all digits are deleted"""
if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia):
debug.click(buttons.pin_passphrase_grid(9), hold_ms=1500)
debug.click(buttons.pin_passphrase_grid(9, debug.layout_type), hold_ms=1500)
elif debug.layout_type is LayoutType.Caesar:
navigate_to_action_and_press(debug, DELETE, TR_PIN_ACTIONS, hold_ms=1000)
@ -221,7 +221,7 @@ def _cancel_pin(debug: "DebugLink") -> None:
def _confirm_pin(debug: "DebugLink") -> None:
"""Navigate to "ENTER" and press it"""
if debug.layout_type in (LayoutType.Bolt, LayoutType.Delizia):
debug.click(buttons.pin_passphrase_grid(11))
debug.click(buttons.pin_passphrase_grid(11, debug.layout_type))
elif debug.layout_type is LayoutType.Caesar:
navigate_to_action_and_press(debug, ENTER, TR_PIN_ACTIONS)

View File

@ -60,17 +60,14 @@ def test_repeated_backup(
# let's make a 1-of-1 backup to start with...
assert debug.model is not None
model_name: str = debug.model.internal_name
# confirm checklist
reset.confirm_read(debug)
# shares=1
reset.set_selection(debug, buttons.reset_minus(model_name), 5 - 1)
reset.set_selection(debug, buttons.reset_minus(debug.layout_type), 5 - 1)
# confirm checklist
reset.confirm_read(debug)
# threshold=1
reset.set_selection(debug, buttons.reset_plus(model_name), 0)
reset.set_selection(debug, buttons.reset_plus(debug.layout_type), 0)
# confirm checklist
reset.confirm_read(debug)
# confirm backup warning
@ -132,11 +129,11 @@ def test_repeated_backup(
# confirm checklist
reset.confirm_read(debug)
# shares=3
reset.set_selection(debug, buttons.reset_minus(model_name), 5 - 3)
reset.set_selection(debug, buttons.reset_minus(debug.layout_type), 5 - 3)
# confirm checklist
reset.confirm_read(debug)
# threshold=2
reset.set_selection(debug, buttons.reset_minus(model_name), 1)
reset.set_selection(debug, buttons.reset_minus(debug.layout_type), 1)
# confirm checklist
reset.confirm_read(debug)
# confirm backup warning

View File

@ -81,12 +81,14 @@ def test_reset_slip39_advanced(
reset.confirm_read(debug)
# set num of groups - default is 5
assert debug.model is not None
model_name: str = debug.model.internal_name
if group_count < 5:
reset.set_selection(debug, buttons.reset_minus(model_name), 5 - group_count)
reset.set_selection(
debug, buttons.reset_minus(debug.layout_type), 5 - group_count
)
else:
reset.set_selection(debug, buttons.reset_plus(model_name), group_count - 5)
reset.set_selection(
debug, buttons.reset_plus(debug.layout_type), group_count - 5
)
# confirm checklist
# TR.assert_in_multiple(
@ -102,9 +104,9 @@ def test_reset_slip39_advanced(
# set group threshold
# TODO: could make it general as well
if group_count == 2 and group_threshold == 2:
reset.set_selection(debug, buttons.reset_plus(model_name), 0)
reset.set_selection(debug, buttons.reset_plus(debug.layout_type), 0)
elif group_count == 16 and group_threshold == 16:
reset.set_selection(debug, buttons.reset_plus(model_name), 11)
reset.set_selection(debug, buttons.reset_plus(debug.layout_type), 11)
else:
raise RuntimeError("not a supported combination")
@ -122,16 +124,20 @@ def test_reset_slip39_advanced(
for _ in range(group_count):
# set num of shares - default is 5
if share_count < 5:
reset.set_selection(debug, buttons.reset_minus(model_name), 5 - share_count)
reset.set_selection(
debug, buttons.reset_minus(debug.layout_type), 5 - share_count
)
else:
reset.set_selection(debug, buttons.reset_plus(model_name), share_count - 5)
reset.set_selection(
debug, buttons.reset_plus(debug.layout_type), share_count - 5
)
# set share threshold
# TODO: could make it general as well
if share_count == 2 and share_threshold == 2:
reset.set_selection(debug, buttons.reset_plus(model_name), 0)
reset.set_selection(debug, buttons.reset_plus(debug.layout_type), 0)
elif share_count == 16 and share_threshold == 16:
reset.set_selection(debug, buttons.reset_plus(model_name), 11)
reset.set_selection(debug, buttons.reset_plus(debug.layout_type), 11)
else:
raise RuntimeError("not a supported combination")

View File

@ -79,12 +79,14 @@ def test_reset_slip39_basic(
reset.confirm_read(debug)
# set num of shares - default is 5
assert debug.model is not None
model_name: str = debug.model.internal_name
if num_of_shares < 5:
reset.set_selection(debug, buttons.reset_minus(model_name), 5 - num_of_shares)
reset.set_selection(
debug, buttons.reset_minus(debug.layout_type), 5 - num_of_shares
)
else:
reset.set_selection(debug, buttons.reset_plus(model_name), num_of_shares - 5)
reset.set_selection(
debug, buttons.reset_plus(debug.layout_type), num_of_shares - 5
)
# confirm checklist
# TR.assert_in(
@ -95,9 +97,9 @@ def test_reset_slip39_basic(
# set threshold
# TODO: could make it general as well
if num_of_shares == 1 and threshold == 1:
reset.set_selection(debug, buttons.reset_plus(model_name), 0)
reset.set_selection(debug, buttons.reset_plus(debug.layout_type), 0)
elif num_of_shares == 16 and threshold == 16:
reset.set_selection(debug, buttons.reset_plus(model_name), 11)
reset.set_selection(debug, buttons.reset_plus(debug.layout_type), 11)
else:
raise RuntimeError("not a supported combination")

View File

@ -39,7 +39,7 @@ def test_tutorial_ignore_menu(device_handler: "BackgroundDeviceHandler"):
device_handler.run(device.show_device_tutorial)
assert debug.read_layout().title() == TR.tutorial__welcome_safe5
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_lets_begin
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_easy_navigation
@ -47,7 +47,7 @@ def test_tutorial_ignore_menu(device_handler: "BackgroundDeviceHandler"):
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_hold
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_well_done
debug.swipe_up()
@ -59,21 +59,21 @@ def test_tutorial_menu_open_close(device_handler: "BackgroundDeviceHandler"):
device_handler.run(device.show_device_tutorial)
assert debug.read_layout().title() == TR.tutorial__welcome_safe5
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_lets_begin
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_easy_navigation
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
assert TR.tutorial__did_you_know in debug.read_layout().text_content()
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_hold
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_well_done
debug.swipe_up()
@ -85,18 +85,18 @@ def test_tutorial_menu_exit(device_handler: "BackgroundDeviceHandler"):
device_handler.run(device.show_device_tutorial)
assert debug.read_layout().title() == TR.tutorial__welcome_safe5
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_lets_begin
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_easy_navigation
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
assert TR.tutorial__did_you_know in debug.read_layout().text_content()
debug.click(buttons.VERTICAL_MENU[2])
debug.click(buttons.vertical_menu(debug.layout_type)[2])
assert TR.instructions__hold_to_exit_tutorial in debug.read_layout().footer()
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_well_done
debug.swipe_up()
@ -108,16 +108,16 @@ def test_tutorial_menu_repeat(device_handler: "BackgroundDeviceHandler"):
device_handler.run(device.show_device_tutorial)
assert debug.read_layout().title() == TR.tutorial__welcome_safe5
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_lets_begin
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_easy_navigation
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
assert TR.tutorial__did_you_know in debug.read_layout().text_content()
debug.click(buttons.VERTICAL_MENU[1])
debug.click(buttons.vertical_menu(debug.layout_type)[1])
assert debug.read_layout().title() == TR.tutorial__title_lets_begin
debug.swipe_up()
@ -126,7 +126,7 @@ def test_tutorial_menu_repeat(device_handler: "BackgroundDeviceHandler"):
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_hold
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_well_done
debug.swipe_up()
@ -138,28 +138,28 @@ def test_tutorial_menu_funfact(device_handler: "BackgroundDeviceHandler"):
device_handler.run(device.show_device_tutorial)
assert debug.read_layout().title() == TR.tutorial__welcome_safe5
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_lets_begin
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_easy_navigation
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
assert TR.tutorial__did_you_know in debug.read_layout().text_content()
debug.click(buttons.VERTICAL_MENU[0])
debug.click(buttons.vertical_menu(debug.layout_type)[0])
assert debug.read_layout().text_content() in TR.tutorial__first_wallet.replace(
"\n", " "
)
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
assert TR.tutorial__did_you_know in debug.read_layout().text_content()
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_handy_menu
debug.swipe_up()
assert debug.read_layout().title() == TR.tutorial__title_hold
debug.click(buttons.TAP_TO_CONFIRM)
debug.click(buttons.tap_to_confirm(debug.layout_type))
assert debug.read_layout().title() == TR.tutorial__title_well_done
debug.swipe_up()

View File

@ -323,12 +323,12 @@ def click_info_button_bolt(debug: "DebugLink") -> Generator[Any, Any, ButtonRequ
def click_info_button_delizia(debug: "DebugLink"):
"""Click Shamir backup info button and return back."""
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.corner_button(debug.layout_type))
layout = debug.read_layout()
assert "VerticalMenu" in layout.all_components()
debug.click(buttons.VERTICAL_MENU[0])
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.CORNER_BUTTON)
debug.click(buttons.vertical_menu(debug.layout_type)[0])
debug.click(buttons.corner_button(debug.layout_type))
debug.click(buttons.corner_button(debug.layout_type))
def check_pin_backoff_time(attempts: int, start: float) -> None:

View File

@ -108,8 +108,6 @@ TXHASH_efaa41 = bytes.fromhex(
"efaa41ff3e67edf508846c1a1ed56894cfd32725c590300108f40c9edc1aac35"
)
CORNER_BUTTON = (215, 25)
def test_one_one_fee(client: Client):
# input tx: 0dac366fd8a67b2a89fbb0d31086e7acded7a5bbf9ef9daa935bc873229ef5b5

View File

@ -42,8 +42,8 @@ def show_details_input_flow(client: Client):
client.debug.press_yes()
elif client.layout_type is LayoutType.Delizia:
# Delizia - "Show all" button from context menu
client.debug.click(buttons.CORNER_BUTTON)
client.debug.click(buttons.VERTICAL_MENU[0])
client.debug.click(buttons.corner_button(client.layout_type))
client.debug.click(buttons.vertical_menu(client.layout_type)[0])
else:
raise NotImplementedError
# reset ui flow to continue "automatically"

View File

@ -188,16 +188,16 @@ def test_pin_menu_cancel_setup(client: Client):
def cancel_pin_setup_input_flow():
yield
# enter context menu
client.debug.click(buttons.CORNER_BUTTON)
client.debug.click(buttons.corner_button(client.layout_type))
client.debug.synchronize_at("VerticalMenu")
# click "Cancel PIN setup"
client.debug.click(buttons.VERTICAL_MENU[0])
client.debug.click(buttons.vertical_menu(client.layout_type)[0])
client.debug.synchronize_at("Paragraphs")
# swipe through info screen
client.debug.swipe_up()
client.debug.synchronize_at("PromptScreen")
# tap to confirm
client.debug.click(buttons.TAP_TO_CONFIRM)
client.debug.click(buttons.tap_to_confirm(client.layout_type))
with client, pytest.raises(Cancelled):
client.set_input_flow(cancel_pin_setup_input_flow)

View File

@ -319,9 +319,9 @@ class InputFlowSignVerifyMessageLong(InputFlowBase):
self.debug.read_layout()
self.debug.press_yes()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
br = yield
self.debug.read_layout()
@ -351,8 +351,8 @@ class InputFlowSignMessageInfo(InputFlowBase):
def input_flow_bolt(self) -> BRGeneratorType:
yield
# signing address/message info
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.corner_button(self.client.layout_type))
# signing address "x"
self.debug.press_no()
self.debug.synchronize_at("IconDialog")
@ -363,10 +363,10 @@ class InputFlowSignMessageInfo(InputFlowBase):
def input_flow_delizia(self) -> BRGeneratorType:
yield
# show address/message info
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.VERTICAL_MENU[1])
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.vertical_menu(self.client.layout_type)[1])
# address mismatch? yes!
self.debug.swipe_up()
yield
@ -378,14 +378,14 @@ class InputFlowShowAddressQRCode(InputFlowBase):
def input_flow_bolt(self) -> BRGeneratorType:
yield
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# synchronize; TODO get rid of this once we have single-global-layout
self.debug.synchronize_at("SimplePage")
self.debug.swipe_left()
self.debug.swipe_right()
self.debug.swipe_left()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.press_no()
self.debug.press_no()
self.debug.press_yes()
@ -413,26 +413,26 @@ class InputFlowShowAddressQRCode(InputFlowBase):
def input_flow_delizia(self) -> BRGeneratorType:
yield
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# synchronize; TODO get rid of this once we have single-global-layout
self.debug.synchronize_at("VerticalMenu")
# menu
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
self.debug.synchronize_at("Qr")
# qr code
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# menu
self.debug.click(buttons.VERTICAL_MENU[1])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[1])
# address details
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# menu
self.debug.click(buttons.VERTICAL_MENU[2])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[2])
# cancel
self.debug.swipe_up()
# really cancel
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# menu
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
layout = self.debug.read_layout()
while "PromptScreen" not in layout.all_components():
@ -440,7 +440,7 @@ class InputFlowShowAddressQRCode(InputFlowBase):
layout = self.debug.read_layout()
self.debug.synchronize_at("PromptScreen")
# tap to confirm
self.debug.click(buttons.TAP_TO_CONFIRM)
self.debug.click(buttons.tap_to_confirm(self.client.layout_type))
class InputFlowShowAddressQRCodeCancel(InputFlowBase):
@ -449,12 +449,12 @@ class InputFlowShowAddressQRCodeCancel(InputFlowBase):
def input_flow_bolt(self) -> BRGeneratorType:
yield
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# synchronize; TODO get rid of this once we have single-global-layout
self.debug.synchronize_at("SimplePage")
self.debug.swipe_left()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.press_no()
self.debug.press_yes()
@ -475,25 +475,25 @@ class InputFlowShowAddressQRCodeCancel(InputFlowBase):
def input_flow_delizia(self) -> BRGeneratorType:
yield
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# synchronize; TODO get rid of this once we have single-global-layout
self.debug.synchronize_at("VerticalMenu")
# menu
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
self.debug.synchronize_at("Qr")
# qr code
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# menu
self.debug.click(buttons.VERTICAL_MENU[1])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[1])
# address details
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# menu
self.debug.click(buttons.VERTICAL_MENU[2])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[2])
# cancel
self.debug.swipe_up()
self.debug.synchronize_at("PromptScreen")
# really cancel
self.debug.click(buttons.TAP_TO_CONFIRM)
self.debug.click(buttons.tap_to_confirm(self.client.layout_type))
class InputFlowShowMultisigXPUBs(InputFlowBase):
@ -521,7 +521,7 @@ class InputFlowShowMultisigXPUBs(InputFlowBase):
assert "(MULTISIG)" in layout.title()
assert layout.text_content().replace(" ", "") == self.address
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
assert "Qr" in self.all_components()
self.debug.swipe_left()
@ -538,7 +538,7 @@ class InputFlowShowMultisigXPUBs(InputFlowBase):
content = layout.text_content().replace(" ", "")
assert self.xpubs[xpub_num] in content
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# show address
self.debug.press_no()
# address mismatch
@ -590,26 +590,26 @@ class InputFlowShowMultisigXPUBs(InputFlowBase):
def input_flow_delizia(self) -> BRGeneratorType:
yield # multisig address warning
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[1])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[1])
yield # show address
layout = self.debug.read_layout()
assert TR.address__title_receive_address in layout.title()
assert layout.text_content().replace(" ", "") == self.address
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
assert "VerticalMenu" in self.all_components()
# menu
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
self.debug.synchronize_at("Qr")
# qr code
assert "Qr" in self.all_components()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# menu
assert "VerticalMenu" in self.all_components()
self.debug.click(buttons.VERTICAL_MENU[1])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[1])
layout = self.debug.synchronize_at("AddressDetails")
# address details
assert "Multisig 2 of 3" in layout.screen_content()
@ -620,17 +620,17 @@ class InputFlowShowMultisigXPUBs(InputFlowBase):
self.debug.swipe_left()
self.debug.swipe_left()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
# menu
self.debug.click(buttons.VERTICAL_MENU[2])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[2])
# cancel
self.debug.swipe_up()
# really cancel
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
# menu
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
layout = self.debug.synchronize_at("Paragraphs")
# address
while "PromptScreen" not in layout.all_components():
@ -659,14 +659,14 @@ class InputFlowShowXpubQRCode(InputFlowBase):
self.debug.press_yes()
br = yield
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# synchronize; TODO get rid of this once we have single-global-layout
self.debug.synchronize_at("SimplePage")
self.debug.swipe_left()
self.debug.swipe_right()
self.debug.swipe_left()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.press_no()
self.debug.press_no()
for _ in range(br.pages - 1):
@ -716,32 +716,32 @@ class InputFlowShowXpubQRCode(InputFlowBase):
assert layout.title() in (TR.address__public_key, "XPUB")
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
assert "VerticalMenu" in self.all_components()
# menu
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
self.debug.synchronize_at("Qr")
# qr code
assert "Qr" in self.all_components()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
# menu
assert "VerticalMenu" in self.all_components()
self.debug.click(buttons.VERTICAL_MENU[1])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[1])
layout = self.debug.synchronize_at("AddressDetails")
# address details
assert TR.address_details__derivation_path in layout.screen_content()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
layout = self.debug.synchronize_at("VerticalMenu")
# menu
self.debug.click(buttons.VERTICAL_MENU[2])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[2])
# cancel
self.debug.swipe_up()
# really cancel
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
layout = self.debug.synchronize_at("VerticalMenu")
# menu
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
layout = self.debug.synchronize_at("Paragraphs")
# address
while "PromptScreen" not in layout.all_components():
@ -868,7 +868,7 @@ def sign_tx_go_to_info(client: Client) -> Generator[None, messages.ButtonRequest
layout = client.debug.read_layout()
content = layout.text_content()
client.debug.click(buttons.CORNER_BUTTON)
client.debug.click(buttons.corner_button(client.layout_type))
return content
@ -890,22 +890,22 @@ def sign_tx_go_to_info_t3t1(
yield # confirm transaction
client.debug.read_layout()
client.debug.click(buttons.CORNER_BUTTON)
client.debug.click(buttons.corner_button(client.layout_type))
client.debug.synchronize_at("VerticalMenu")
client.debug.click(buttons.VERTICAL_MENU[0])
client.debug.click(buttons.vertical_menu(client.layout_type)[0])
layout = client.debug.read_layout()
content = layout.text_content()
client.debug.click(buttons.CORNER_BUTTON)
client.debug.click(buttons.corner_button(client.layout_type))
client.debug.synchronize_at("VerticalMenu")
client.debug.click(buttons.VERTICAL_MENU[1])
client.debug.click(buttons.vertical_menu(client.layout_type)[1])
layout = client.debug.read_layout()
content += " " + layout.text_content()
client.debug.click(buttons.CORNER_BUTTON)
client.debug.click(buttons.CORNER_BUTTON)
client.debug.click(buttons.corner_button(client.layout_type))
client.debug.click(buttons.corner_button(client.layout_type))
return content
@ -1019,10 +1019,10 @@ class InputFlowSignTxInformationCancel(InputFlowBase):
def input_flow_delizia(self) -> BRGeneratorType:
yield from sign_tx_go_to_info_t3t1(self.client)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.VERTICAL_MENU[2])
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.vertical_menu(self.client.layout_type)[2])
self.debug.synchronize_at("PromptScreen")
self.debug.click(buttons.TAP_TO_CONFIRM)
self.debug.click(buttons.tap_to_confirm(self.client.layout_type))
class InputFlowSignTxInformationReplacement(InputFlowBase):
@ -1043,8 +1043,8 @@ class InputFlowSignTxInformationReplacement(InputFlowBase):
self.debug.press_yes()
yield # transaction summary, press info
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.press_yes()
def input_flow_caesar(self) -> BRGeneratorType:
@ -2331,12 +2331,12 @@ class InputFlowResetSkipBackup(InputFlowBase):
assert TR.backup__new_wallet_created in self.text_content()
self.debug.swipe_up()
yield
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
self.debug.swipe_up()
self.debug.synchronize_at("PromptScreen")
self.debug.click(buttons.TAP_TO_CONFIRM)
self.debug.click(buttons.tap_to_confirm(self.client.layout_type))
class InputFlowConfirmAllWarnings(InputFlowBase):
@ -2372,9 +2372,9 @@ class InputFlowConfirmAllWarnings(InputFlowBase):
TR.send__cancel_sign,
)
if any(needle.lower() in text for needle in hi_prio):
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[1])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[1])
elif "PromptScreen" in layout.all_components():
self.debug.press_yes()
elif "SwipeContent" in layout.all_components():
@ -2401,4 +2401,4 @@ class InputFlowFidoConfirm(InputFlowBase):
while True:
yield
self.debug.swipe_up()
self.debug.click(buttons.TAP_TO_CONFIRM)
self.debug.click(buttons.tap_to_confirm(self.client.layout_type))

View File

@ -144,12 +144,12 @@ class RecoveryFlow:
self.debug.press_no()
elif self.client.layout_type is LayoutType.Delizia:
assert TR.recovery__enter_each_word in self._text_content()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
if confirm:
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
else:
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
else:
assert TR.recovery__enter_any_share in self._text_content()
self.debug.press_no()
@ -175,14 +175,14 @@ class RecoveryFlow:
assert TR.regexp("recovery__x_of_y_entered_template").search(
self._text_content()
)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
assert (yield).name == "abort_recovery"
self.debug.swipe_up()
layout = self.debug.read_layout()
assert layout.title() == TR.recovery__title_cancel_recovery
self.debug.click(buttons.TAP_TO_CONFIRM)
self.debug.click(buttons.tap_to_confirm(self.client.layout_type))
else:
assert TR.regexp("recovery__x_of_y_entered_template").search(
self._text_content()
@ -338,15 +338,15 @@ class RecoveryFlow:
def click_info_delizia(self) -> BRGeneratorType:
# Moving through the menu into the show_shares screen
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
br = yield
assert br.name == "show_shares"
assert br.code == B.Other
# Getting back to the homepage
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.corner_button(self.client.layout_type))
class EthereumFlow:
@ -481,17 +481,17 @@ class EthereumFlow:
self.debug.press_yes()
assert (yield).name == "confirm_ethereum_tx"
if info:
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
text = self.debug.read_layout().text_content()
assert TR.ethereum__gas_limit in text
assert TR.ethereum__gas_price in text
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.swipe_up()
self.debug.read_layout()
self.debug.click(buttons.TAP_TO_CONFIRM)
self.debug.click(buttons.tap_to_confirm(self.client.layout_type))
assert (yield).name == "confirm_ethereum_tx"
def confirm_tx(
@ -530,7 +530,7 @@ class EthereumFlow:
# confirm intro
if info:
self.debug.click(
buttons.CORNER_BUTTON,
buttons.corner_button(self.client.layout_type),
)
assert self.debug.read_layout().title() in (
TR.ethereum__staking_stake_address,
@ -554,15 +554,15 @@ class EthereumFlow:
elif self.client.layout_type is LayoutType.Delizia:
# confirm intro
if info:
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
assert self.debug.read_layout().title() in (
TR.ethereum__staking_stake_address,
TR.ethereum__staking_claim_address,
)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.swipe_up()
br = yield
@ -571,13 +571,13 @@ class EthereumFlow:
# confirm summary
if info:
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.synchronize_at("VerticalMenu")
self.debug.click(buttons.VERTICAL_MENU[0])
self.debug.click(buttons.vertical_menu(self.client.layout_type)[0])
assert TR.ethereum__gas_limit in self.debug.read_layout().text_content()
assert TR.ethereum__gas_price in self.debug.read_layout().text_content()
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.CORNER_BUTTON)
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.click(buttons.corner_button(self.client.layout_type))
self.debug.swipe_up()
# br = yield # FIXME: no BR on sign transaction

View File

@ -10,16 +10,16 @@ def _enter_word(
debug: "DebugLink", word: str, is_slip39: bool = False
) -> "LayoutContent":
typed_word = word[:4]
for coords in buttons.type_word(typed_word, is_slip39=is_slip39):
for coords in buttons.type_word(typed_word, debug.layout_type, is_slip39=is_slip39):
debug.click(coords)
debug.read_layout(wait=False)
debug.click(buttons.CONFIRM_WORD)
debug.click(buttons.input(debug.layout_type))
return debug.read_layout(wait=True)
def confirm_recovery(debug: "DebugLink") -> None:
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
debug.read_layout(wait=True)
@ -27,16 +27,16 @@ def select_number_of_words(
debug: "DebugLink", tag_version: tuple | None, num_of_words: int = 20
) -> None:
if "SelectWordCount" not in debug.read_layout().all_components():
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
debug.read_layout(wait=True)
if tag_version is None or tag_version > (2, 8, 8):
# layout changed after adding the cancel button
coords_map = {
12: buttons.grid34(0, 2),
18: buttons.grid34(1, 2),
20: buttons.grid34(2, 2),
24: buttons.grid34(1, 3),
33: buttons.grid34(2, 3),
12: buttons.grid34(0, 2, debug.layout_type),
18: buttons.grid34(1, 2, debug.layout_type),
20: buttons.grid34(2, 2, debug.layout_type),
24: buttons.grid34(1, 3, debug.layout_type),
33: buttons.grid34(2, 3, debug.layout_type),
}
coords = coords_map.get(num_of_words)
else:
@ -45,13 +45,13 @@ def select_number_of_words(
index = word_option_offset + word_options.index(
num_of_words
) # raises if num of words is invalid
coords = buttons.grid34(index % 3, index // 3)
coords = buttons.grid34(index % 3, index // 3, debug.layout_type)
debug.click(coords)
debug.read_layout(wait=True)
def enter_share(debug: "DebugLink", share: str) -> "LayoutContent":
debug.click(buttons.OK)
debug.click(buttons.ok(debug.layout_type))
for word in share.split(" "):
_enter_word(debug, word, is_slip39=True)