mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-18 05:28:40 +00:00
fix(core): raise ActionCancelled when cancelling tutorial flow for TR
[no changelog]
This commit is contained in:
parent
de7458dd49
commit
9a4cb1887d
@ -684,10 +684,12 @@ async def tutorial(
|
|||||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Showing users how to interact with the device."""
|
"""Showing users how to interact with the device."""
|
||||||
await interact(
|
await raise_if_not_confirmed(
|
||||||
RustLayout(trezorui2.tutorial()),
|
interact(
|
||||||
"tutorial",
|
RustLayout(trezorui2.tutorial()),
|
||||||
br_code,
|
"tutorial",
|
||||||
|
br_code,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, Generator
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from trezorlib import device
|
from trezorlib import device
|
||||||
|
from trezorlib.exceptions import Cancelled
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..device_handler import BackgroundDeviceHandler
|
from ..device_handler import BackgroundDeviceHandler
|
||||||
@ -32,14 +33,18 @@ pytestmark = [pytest.mark.skip_t1, pytest.mark.skip_t2]
|
|||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def prepare_tutorial_and_cancel_after_it(
|
def prepare_tutorial_and_cancel_after_it(
|
||||||
device_handler: "BackgroundDeviceHandler",
|
device_handler: "BackgroundDeviceHandler", cancelled: bool = False
|
||||||
) -> Generator["DebugLink", None, None]:
|
) -> Generator["DebugLink", None, None]:
|
||||||
debug = device_handler.debuglink()
|
debug = device_handler.debuglink()
|
||||||
device_handler.run(device.show_device_tutorial)
|
device_handler.run(device.show_device_tutorial)
|
||||||
|
|
||||||
yield debug
|
yield debug
|
||||||
|
|
||||||
device_handler.result()
|
try:
|
||||||
|
device_handler.result()
|
||||||
|
except Cancelled:
|
||||||
|
if not cancelled:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def go_through_tutorial(debug: "DebugLink") -> None:
|
def go_through_tutorial(debug: "DebugLink") -> None:
|
||||||
@ -64,7 +69,7 @@ def test_tutorial_finish(device_handler: "BackgroundDeviceHandler"):
|
|||||||
|
|
||||||
@pytest.mark.setup_client(uninitialized=True)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_tutorial_skip(device_handler: "BackgroundDeviceHandler"):
|
def test_tutorial_skip(device_handler: "BackgroundDeviceHandler"):
|
||||||
with prepare_tutorial_and_cancel_after_it(device_handler) as debug:
|
with prepare_tutorial_and_cancel_after_it(device_handler, cancelled=True) as debug:
|
||||||
# SKIP
|
# SKIP
|
||||||
debug.press_left(wait=True)
|
debug.press_left(wait=True)
|
||||||
debug.press_right(wait=True)
|
debug.press_right(wait=True)
|
||||||
@ -72,7 +77,7 @@ def test_tutorial_skip(device_handler: "BackgroundDeviceHandler"):
|
|||||||
|
|
||||||
@pytest.mark.setup_client(uninitialized=True)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_tutorial_again_and_skip(device_handler: "BackgroundDeviceHandler"):
|
def test_tutorial_again_and_skip(device_handler: "BackgroundDeviceHandler"):
|
||||||
with prepare_tutorial_and_cancel_after_it(device_handler) as debug:
|
with prepare_tutorial_and_cancel_after_it(device_handler, cancelled=True) as debug:
|
||||||
# CLICK THROUGH
|
# CLICK THROUGH
|
||||||
go_through_tutorial(debug)
|
go_through_tutorial(debug)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user