60 lines
2.1 KiB
Python
60 lines
2.1 KiB
Python
"""Round 128.
|
|
|
|
- A window shown without being polished first got its native surface before
|
|
the title-bar installer asked for an alpha channel, so the cleared corners
|
|
outside the curve came out black.
|
|
- Importing Shazams: a song that couldn't be imported gets a Copy button
|
|
(right-hand column) that puts "Artist — Title (Album)" on the clipboard,
|
|
to search for it by hand.
|
|
"""
|
|
from datetime import datetime
|
|
|
|
from PyQt6.QtWidgets import QDialog, QToolButton
|
|
|
|
from lintunes.gui import shazam_import as ui
|
|
from lintunes.gui import titlebar
|
|
from lintunes.shazam import ShazamSong
|
|
|
|
|
|
def test_a_window_shown_unpolished_still_gets_alpha(qapp):
|
|
installer = titlebar.install(qapp)
|
|
try:
|
|
dialog = QDialog() # shown at once: created, then polished
|
|
dialog.show()
|
|
qapp.processEvents()
|
|
assert dialog.windowHandle().format().alphaBufferSize() == 8
|
|
dialog.close()
|
|
finally:
|
|
qapp.removeEventFilter(installer)
|
|
|
|
|
|
def _song(rid, **kw):
|
|
return ShazamSong(request_id=rid, when=datetime(2026, 10, 1, 20, 15), **kw)
|
|
|
|
|
|
def _copy_in(window, rid):
|
|
cell = window._tree.itemWidget(window._rows[rid], 2)
|
|
return cell.findChild(QToolButton) if cell is not None else None
|
|
|
|
|
|
def test_songs_that_failed_get_a_copy_button(qapp):
|
|
window = ui.ShazamImportWindow([
|
|
_song("a", title="America Latina"),
|
|
_song("b", title="Ghor Bari", artist="Kalyani Ghosh", album="Songs"),
|
|
_song("c", title="Digital Love", artist="Daft Punk")])
|
|
assert _copy_in(window, "a") is None
|
|
window.failed("a", "nothing found that's just the song")
|
|
window.set_stage("b", "Downloading…")
|
|
window.finish(cancelled=False) # b never landed: Not found
|
|
window.imported("c", object())
|
|
assert _copy_in(window, "c") is None
|
|
|
|
_copy_in(window, "b").click()
|
|
assert qapp.clipboard().text() == "Kalyani Ghosh — Ghor Bari (Songs)"
|
|
_copy_in(window, "a").click()
|
|
assert qapp.clipboard().text() == "America Latina"
|
|
|
|
# A row that recovers loses it again.
|
|
window.set_stage("a", ui.IMPORTING)
|
|
assert _copy_in(window, "a") is None
|