46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""Round 82: album art sits in the same panel, in the same place, as the
|
|
empty art panel: the cover changes what is inside the frame, never the
|
|
frame."""
|
|
from PyQt6.QtGui import QColor, QPixmap
|
|
|
|
from tests.test_round80 import _sidebar
|
|
|
|
|
|
def _show_art(qapp, art, color):
|
|
pixmap = QPixmap(10, 10)
|
|
pixmap.fill(QColor(color))
|
|
art._pixmap = pixmap
|
|
art._fit_height()
|
|
qapp.processEvents()
|
|
|
|
|
|
def test_art_keeps_the_empty_panels_place_and_border(qapp, tmp_path):
|
|
from lintunes.gui.sidebar import NO_ART_GAP
|
|
window, sidebar = _sidebar(qapp, tmp_path)
|
|
art = sidebar.art
|
|
empty_geometry = art.geometry()
|
|
empty = art.grab().toImage()
|
|
_show_art(qapp, art, "white")
|
|
assert art.parentWidget() is sidebar
|
|
assert art.geometry() == empty_geometry
|
|
assert art.height() == art.width() + NO_ART_GAP
|
|
image = art.grab().toImage()
|
|
middle = image.width() // 2
|
|
# the gap and the panel's darker top edge, unchanged
|
|
for y in range(NO_ART_GAP + 1):
|
|
assert image.pixelColor(middle, y) == empty.pixelColor(middle, y)
|
|
# ...and the cover just inside it
|
|
assert image.pixelColor(middle, NO_ART_GAP + 2) == QColor("white")
|
|
assert image.pixelColor(middle, image.height() // 2) == QColor("white")
|
|
window.close()
|
|
|
|
|
|
def test_art_changes_no_layout(qapp, tmp_path):
|
|
window, sidebar = _sidebar(qapp, tmp_path)
|
|
list_geometry = sidebar.list_area.geometry()
|
|
_show_art(qapp, sidebar.art, "red")
|
|
sidebar.art.has_art_changed.emit(True)
|
|
qapp.processEvents()
|
|
assert sidebar.list_area.geometry() == list_geometry
|
|
window.close()
|