From 217dd8c817164fb9d2407dc79aa4f91df1e80fec Mon Sep 17 00:00:00 2001 From: Lukas Bielesch Date: Fri, 29 Nov 2024 19:58:59 +0100 Subject: [PATCH] chore(core): add missing parameter to set_brightness function --- core/.changelog.d/4410.fixed | 1 + core/src/apps/management/set_brightness.py | 4 ++-- tests/device_tests/test_msg_applysettings.py | 23 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 core/.changelog.d/4410.fixed diff --git a/core/.changelog.d/4410.fixed b/core/.changelog.d/4410.fixed new file mode 100644 index 0000000000..aff68581c5 --- /dev/null +++ b/core/.changelog.d/4410.fixed @@ -0,0 +1 @@ +Add optional value parameter in brightness setting flow. diff --git a/core/src/apps/management/set_brightness.py b/core/src/apps/management/set_brightness.py index 0cc7dc34f3..93dbe6e35f 100644 --- a/core/src/apps/management/set_brightness.py +++ b/core/src/apps/management/set_brightness.py @@ -4,7 +4,7 @@ if TYPE_CHECKING: from trezor.messages import SetBrightness, Success -async def set_brightness(_msg: SetBrightness) -> Success: +async def set_brightness(msg: SetBrightness) -> Success: import storage.device as storage_device from trezor.messages import Success from trezor.ui.layouts import set_brightness @@ -13,5 +13,5 @@ async def set_brightness(_msg: SetBrightness) -> Success: if not storage_device.is_initialized(): raise NotInitialized("Device is not initialized") - await set_brightness() + await set_brightness(msg.value) return Success(message="Settings applied") diff --git a/tests/device_tests/test_msg_applysettings.py b/tests/device_tests/test_msg_applysettings.py index 65ea935748..30c8c1c42c 100644 --- a/tests/device_tests/test_msg_applysettings.py +++ b/tests/device_tests/test_msg_applysettings.py @@ -424,13 +424,32 @@ def test_label_too_long(client: Client): @pytest.mark.models(skip=["legacy", "safe3"]) +@pytest.mark.parametrize( + "value", + [ + pytest.param(None, id="none_default"), + pytest.param( + -1, + marks=pytest.mark.xfail(), + id="negative_value", + ), + pytest.param(0, id="0_min_value"), + pytest.param(128, id="128"), + pytest.param(255, id="255_max_value"), + pytest.param( + 256, + marks=pytest.mark.xfail(), + id="256_too_high", + ), + ], +) @pytest.mark.setup_client(pin=None) -def test_set_brightness(client: Client): +def test_set_brightness(client: Client, value: int | None): with client: assert ( device.set_brightness( client, - None, + value, ) == "Settings applied" )