v0.80.0: Speakers and Identify Track toolbar items (Customize Toolbar, not in the default bar)

This commit is contained in:
2026-10-25 20:45:11 -07:00
parent eba27e7b8c
commit f410fb8ea1
6 changed files with 203 additions and 4 deletions
+85
View File
@@ -109,3 +109,88 @@ def test_cancel_transfer_is_always_a_button(qapp):
button = _CancelSyncButton()
assert not button.isFlat()
assert "border: none" not in button.styleSheet()
# ---- the Speakers and Identify toolbar items ----
def _bar(tmp_path):
from test_round101 import _bar as make
return make(tmp_path)
def test_speakers_and_identify_are_offered_but_not_shown(qapp, tmp_path):
from lintunes.gui import toolbar
rows = toolbar.default_config()
for item in ("speakers", "identify"):
assert toolbar.find(rows, item) is None
assert item in toolbar.palette_ids(rows)
def test_they_can_be_dropped_in(qapp, tmp_path):
from PyQt6.QtWidgets import QApplication
bar, prefs = _bar(tmp_path)
bar.drop_item("speakers", 0, 2)
bar.drop_item("identify", 1, 3)
QApplication.processEvents()
assert bar._speakers_btn.parentWidget().isVisible()
assert bar._identify_btn.parentWidget().isVisible()
clicked = []
bar.identify_clicked.connect(lambda: clicked.append("identify"))
bar.speakers_clicked.connect(lambda button: clicked.append(button))
bar._identify_btn.click()
bar._speakers_btn.click()
assert clicked == ["identify", bar._speakers_btn]
assert not bar._speakers_btn.isChecked() # a click doesn't light it
bar.set_speakers_active(True, "Kitchen")
assert bar._speakers_btn.isChecked()
bar._speakers_btn.click()
assert bar._speakers_btn.isChecked() # nor put it out
bar.set_speakers_active(False)
assert not bar._speakers_btn.isChecked()
def test_identify_takes_the_playing_song_else_the_selection(qapp, tmp_path,
monkeypatch):
from lintunes.gui.main_window import MainWindow
from lintunes.library_manager import LibraryManager
from lintunes.models.library import Library
from lintunes.models.track import Track
from lintunes.preferences import Preferences
library = Library()
for tid in (1, 2):
library.tracks[tid] = Track(track_id=tid, name=f"S{tid}")
asked = []
monkeypatch.setattr(MainWindow, "_identify_tracks",
lambda self, ids: asked.append(ids))
window = MainWindow(LibraryManager(library, tmp_path / "data"),
Preferences(tmp_path / "data"))
try:
table = window._content.currentWidget().table
monkeypatch.setattr(table, "selected_track_ids", lambda: [2])
window._identify_from_toolbar()
window.player._current_track = library.tracks[1]
window._identify_from_toolbar()
assert asked == [[2], [1]]
finally:
window.player._current_track = None
window.close()
def test_the_speaker_menu_lights_the_button(qapp, tmp_path, monkeypatch):
from lintunes.gui.main_window import MainWindow
from lintunes.library_manager import LibraryManager
from lintunes.models.library import Library
from lintunes.preferences import Preferences
window = MainWindow(LibraryManager(Library(), tmp_path / "data"),
Preferences(tmp_path / "data"))
try:
monkeypatch.setattr(window._airplay, "is_connected", lambda: True)
monkeypatch.setattr(window._airplay, "device_name", lambda: "Den")
window._airplay.connected.emit("Den")
assert window._transport._speakers_btn.isChecked()
assert "Den" in window._transport._speakers_btn.toolTip()
monkeypatch.setattr(window._airplay, "is_connected", lambda: False)
window._airplay.disconnected.emit("")
assert not window._transport._speakers_btn.isChecked()
finally:
window.close()