-
Notifications
You must be signed in to change notification settings - Fork 28
Visualizer follow-up fixes #264
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d24e4cf
fix: refresh the visualizer while only peaks are active
maximmaxim345 fc53f0e
docs: correct the visualizer row and playhead glyph docs
maximmaxim345 e48ef26
fix: hide the visualizer when the server lacks visualizer@v1
maximmaxim345 fc509a9
test: cover hiding the visualizer when visualizer@v1 is inactive
maximmaxim345 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
|
|
||
| from aiosendspin.models.core import ServerHelloPayload | ||
| from aiosendspin.models.types import ConnectionReason, Roles | ||
|
|
||
| from sendspin.settings import ClientSettings | ||
| from sendspin.tui.app import AppArgs, SendspinApp | ||
|
|
||
|
|
||
| class _FakeUI: | ||
| def __init__(self) -> None: | ||
| self.visualizer_enabled_calls: list[bool] = [] | ||
|
|
||
| def set_visualizer_enabled(self, enabled: bool) -> None: | ||
| self.visualizer_enabled_calls.append(enabled) | ||
|
|
||
|
|
||
| def _make_app(tmp_path: Path) -> SendspinApp: | ||
| args = AppArgs( | ||
| audio_device=SimpleNamespace(index=0, name="Fake Device"), | ||
| client_id="test-client", | ||
| client_name="Test Client", | ||
| settings=ClientSettings(_settings_file=tmp_path / "settings.json"), | ||
| use_mpris=False, | ||
| ) | ||
| return SendspinApp(args) | ||
|
|
||
|
|
||
| def _payload(active_roles: list[str]) -> ServerHelloPayload: | ||
| return ServerHelloPayload( | ||
| server_id="srv", | ||
| name="srv", | ||
| version=1, | ||
| active_roles=active_roles, | ||
| connection_reason=ConnectionReason.DISCOVERY, | ||
| ) | ||
|
|
||
|
|
||
| def test_server_hello_without_visualizer_role_hides_panel(tmp_path: Path) -> None: | ||
| app = _make_app(tmp_path) | ||
| app._visualizer_enabled = True | ||
| app._ui = _FakeUI() | ||
|
|
||
| app._handle_server_hello(_payload(active_roles=["player@v1", "controller@v1"])) | ||
|
|
||
| assert app._ui.visualizer_enabled_calls == [False] | ||
|
|
||
|
|
||
| def test_server_hello_with_visualizer_role_leaves_panel(tmp_path: Path) -> None: | ||
| app = _make_app(tmp_path) | ||
| app._visualizer_enabled = True | ||
| app._ui = _FakeUI() | ||
|
|
||
| app._handle_server_hello(_payload(active_roles=[Roles.VISUALIZER.value, "player@v1"])) | ||
|
|
||
| assert app._ui.visualizer_enabled_calls == [] | ||
|
|
||
|
|
||
| def test_server_hello_ignored_when_visualizer_disabled(tmp_path: Path) -> None: | ||
| app = _make_app(tmp_path) | ||
| app._visualizer_enabled = False | ||
| app._ui = _FakeUI() | ||
|
|
||
| app._handle_server_hello(_payload(active_roles=["player@v1"])) | ||
|
|
||
| assert app._ui.visualizer_enabled_calls == [] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.