2024-09-02 11:59:59 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012-2023 SatoshiLabs and contributors
|
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# 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>.
|
|
|
|
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from trezorlib import device
|
|
|
|
|
|
|
|
from .. import buttons
|
|
|
|
from .. import translations as TR
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from ..device_handler import BackgroundDeviceHandler
|
|
|
|
|
|
|
|
|
|
|
|
# Trezor Safe 5 only
|
|
|
|
pytestmark = [
|
|
|
|
pytest.mark.models("mercury"),
|
|
|
|
pytest.mark.setup_client(uninitialized=True),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def test_tutorial_ignore_menu(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
device_handler.run(device.show_device_tutorial)
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.read_layout()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__welcome_safe5
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_lets_begin
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_easy_navigation
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_hold
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM, hold_ms=1000)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_well_done
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.swipe_up()
|
2024-09-02 11:59:59 +00:00
|
|
|
|
|
|
|
device_handler.result()
|
|
|
|
|
|
|
|
|
|
|
|
def test_tutorial_menu_open_close(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
device_handler.run(device.show_device_tutorial)
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.read_layout()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__welcome_safe5
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_lets_begin
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_easy_navigation
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.CORNER_BUTTON)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert TR.tutorial__did_you_know in layout.text_content()
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.CORNER_BUTTON)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_hold
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM, hold_ms=1000)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_well_done
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.swipe_up()
|
2024-09-02 11:59:59 +00:00
|
|
|
|
|
|
|
device_handler.result()
|
|
|
|
|
|
|
|
|
|
|
|
def test_tutorial_menu_exit(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
device_handler.run(device.show_device_tutorial)
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.read_layout()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__welcome_safe5
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_lets_begin
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_easy_navigation
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.CORNER_BUTTON)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert TR.tutorial__did_you_know in layout.text_content()
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.VERTICAL_MENU[2])
|
2024-11-14 14:11:03 +00:00
|
|
|
assert TR.instructions__hold_to_exit_tutorial in layout.footer()
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM, hold_ms=1000)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_well_done
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.swipe_up()
|
2024-09-02 11:59:59 +00:00
|
|
|
|
|
|
|
device_handler.result()
|
|
|
|
|
|
|
|
|
|
|
|
def test_tutorial_menu_repeat(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
device_handler.run(device.show_device_tutorial)
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.read_layout()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__welcome_safe5
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_lets_begin
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_easy_navigation
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.CORNER_BUTTON)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert TR.tutorial__did_you_know in layout.text_content()
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.VERTICAL_MENU[1])
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_lets_begin
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_easy_navigation
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_hold
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM, hold_ms=1000)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_well_done
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.swipe_up()
|
2024-09-02 11:59:59 +00:00
|
|
|
|
|
|
|
device_handler.result()
|
|
|
|
|
|
|
|
|
|
|
|
def test_tutorial_menu_funfact(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
device_handler.run(device.show_device_tutorial)
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.read_layout()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__welcome_safe5
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_lets_begin
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_easy_navigation
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.CORNER_BUTTON)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert TR.tutorial__did_you_know in layout.text_content()
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.VERTICAL_MENU[0])
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.text_content() in TR.tutorial__first_wallet.replace("\n", " ")
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.CORNER_BUTTON)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert TR.tutorial__did_you_know in layout.text_content()
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.CORNER_BUTTON)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_handy_menu
|
2024-09-02 11:59:59 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.swipe_up()
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_hold
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = debug.click(buttons.TAP_TO_CONFIRM, hold_ms=1000)
|
2024-11-14 14:11:03 +00:00
|
|
|
assert layout.title() == TR.tutorial__title_well_done
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.swipe_up()
|
2024-09-02 11:59:59 +00:00
|
|
|
|
|
|
|
device_handler.result()
|