mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
fixup! chore(core): show the last passphrase character for a while
This commit is contained in:
parent
09c628388f
commit
e674efc501
@ -27,6 +27,8 @@ class CommonPass:
|
||||
|
||||
EMPTY_ADDRESS = "mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q"
|
||||
|
||||
MULTI_CATEGORY = "as12 *&_N"
|
||||
|
||||
|
||||
class PassphraseCategory(Enum):
|
||||
MENU = "MENU"
|
||||
|
@ -70,6 +70,9 @@ DA_51_ADDRESS = DA_50_ADDRESS
|
||||
assert len(DA_51) == 51
|
||||
assert DA_51_ADDRESS == DA_50_ADDRESS
|
||||
|
||||
# pending + entered character is shown for 1 + 1 seconds, so the delay must be grater
|
||||
DELAY_S = 2.1
|
||||
|
||||
|
||||
def get_passphrase_choices(char: str) -> tuple[str, ...]:
|
||||
if char in " *#":
|
||||
@ -176,6 +179,11 @@ def enter_passphrase(debug: "DebugLink") -> None:
|
||||
debug.click(buttons.MERCURY_YES)
|
||||
|
||||
|
||||
def show_passphrase(debug: "DebugLink") -> None:
|
||||
"""See the passphrase"""
|
||||
debug.click(buttons.TOP_ROW)
|
||||
|
||||
|
||||
def delete_char(debug: "DebugLink") -> None:
|
||||
"""Deletes the last char"""
|
||||
coords = buttons.pin_passphrase_grid(9)
|
||||
@ -329,3 +337,16 @@ def test_cycle_through_last_character(
|
||||
passphrase = DA_49 + "i" # for i we need to cycle through "ghi" three times
|
||||
input_passphrase(debug, passphrase)
|
||||
enter_passphrase(debug)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(passphrase=True)
|
||||
def test_last_char_timeout(device_handler: "BackgroundDeviceHandler"):
|
||||
with prepare_passphrase_dialogue(device_handler) as debug:
|
||||
for character in CommonPass.MULTI_CATEGORY:
|
||||
# insert a digit
|
||||
input_passphrase(debug, character)
|
||||
# wait until the last digit is hidden
|
||||
time.sleep(DELAY_S)
|
||||
# show the entire PIN
|
||||
show_passphrase(debug)
|
||||
enter_passphrase(debug)
|
||||
|
@ -14,6 +14,7 @@
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from typing import TYPE_CHECKING, Generator, Optional
|
||||
|
||||
@ -54,6 +55,9 @@ AAA_51_ADDRESS = "miPeCUxf1Ufh5DtV3AuBopNM8YEDvnQZMh"
|
||||
assert len(AAA_51) == 51
|
||||
assert AAA_51_ADDRESS == AAA_50_ADDRESS
|
||||
|
||||
# entered character is shown for 1 second, so the delay must be grater
|
||||
DELAY_S = 1.1
|
||||
|
||||
|
||||
BACK = "inputs__back"
|
||||
SHOW = "inputs__show"
|
||||
@ -264,3 +268,16 @@ def test_passphrase_loop_all_characters(device_handler: "BackgroundDeviceHandler
|
||||
go_to_category(debug, PassphraseCategory.MENU, use_carousel=False)
|
||||
|
||||
enter_passphrase(debug)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(passphrase=True)
|
||||
def test_last_char_timeout(device_handler: "BackgroundDeviceHandler"):
|
||||
with prepare_passphrase_dialogue(device_handler) as debug:
|
||||
for character in CommonPass.MULTI_CATEGORY:
|
||||
# insert a digit
|
||||
input_passphrase(debug, character)
|
||||
# wait until the last digit is hidden
|
||||
time.sleep(DELAY_S)
|
||||
# show the entire PIN
|
||||
show_passphrase(debug)
|
||||
enter_passphrase(debug)
|
||||
|
@ -63,6 +63,9 @@ DA_51_ADDRESS = DA_50_ADDRESS
|
||||
assert len(DA_51) == 51
|
||||
assert DA_51_ADDRESS == DA_50_ADDRESS
|
||||
|
||||
# pending + entered character is shown for 1 + 1 seconds, so the delay must be grater
|
||||
DELAY_S = 2.1
|
||||
|
||||
|
||||
@contextmanager
|
||||
def prepare_passphrase_dialogue(
|
||||
@ -145,6 +148,11 @@ def enter_passphrase(debug: "DebugLink") -> None:
|
||||
debug.click(coords)
|
||||
|
||||
|
||||
def show_passphrase(debug: "DebugLink") -> None:
|
||||
"""See the passphrase"""
|
||||
debug.click(buttons.TOP_ROW)
|
||||
|
||||
|
||||
def delete_char(debug: "DebugLink") -> None:
|
||||
"""Deletes the last char"""
|
||||
coords = buttons.pin_passphrase_grid(9)
|
||||
@ -296,3 +304,16 @@ def test_cycle_through_last_character(
|
||||
passphrase = DA_49 + "i" # for i we need to cycle through "ghi" three times
|
||||
input_passphrase(debug, passphrase)
|
||||
enter_passphrase(debug)
|
||||
|
||||
|
||||
@pytest.mark.setup_client(passphrase=True)
|
||||
def test_last_char_timeout(device_handler: "BackgroundDeviceHandler"):
|
||||
with prepare_passphrase_dialogue(device_handler) as debug:
|
||||
for character in CommonPass.MULTI_CATEGORY:
|
||||
# insert a digit
|
||||
input_passphrase(debug, character)
|
||||
# wait until the last digit is hidden
|
||||
time.sleep(DELAY_S)
|
||||
# show the entire PIN
|
||||
show_passphrase(debug)
|
||||
enter_passphrase(debug)
|
||||
|
Loading…
Reference in New Issue
Block a user