Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): add missing parameter to set_brightness function #4411

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/.changelog.d/4410.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add optional value parameter in brightness setting flow.
4 changes: 2 additions & 2 deletions core/src/apps/management/set_brightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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
Expand All @@ -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")
23 changes: 21 additions & 2 deletions tests/device_tests/test_msg_applysettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Loading