65 lines
2.6 KiB
Python
65 lines
2.6 KiB
Python
"""Round 118: brought in line with the shared design page — every slider
|
|
tall and click-to-jump, the Colors page's Light | Dark as folder tabs, and
|
|
the album art saying it's clickable (finger, tooltip, keyboard focus)."""
|
|
from PyQt6.QtCore import QPointF, Qt
|
|
from PyQt6.QtGui import QMouseEvent
|
|
from PyQt6.QtWidgets import QSlider, QStyle
|
|
|
|
from lintunes.gui.mac_tabs import MacTab
|
|
from lintunes.gui.track_table import ClickToJumpScrollStyle
|
|
from tests.test_round101 import _dialog
|
|
|
|
|
|
def _press(slider, x):
|
|
y = slider.height() / 2
|
|
for kind in (QMouseEvent.Type.MouseButtonPress, QMouseEvent.Type.MouseButtonRelease):
|
|
event = QMouseEvent(kind, QPointF(x, y), slider.mapToGlobal(QPointF(x, y)),
|
|
Qt.MouseButton.LeftButton, Qt.MouseButton.LeftButton,
|
|
Qt.KeyboardModifier.NoModifier)
|
|
(slider.mousePressEvent if kind == QMouseEvent.Type.MouseButtonPress
|
|
else slider.mouseReleaseEvent)(event)
|
|
|
|
|
|
def test_a_plain_slider_is_tall_and_jumps(qapp):
|
|
style = ClickToJumpScrollStyle()
|
|
plain, opted_out = QSlider(Qt.Orientation.Horizontal), QSlider(Qt.Orientation.Horizontal)
|
|
opted_out.setProperty("tall", False)
|
|
for s in (plain, opted_out):
|
|
s.setStyle(style)
|
|
metric = QStyle.PixelMetric.PM_SliderThickness
|
|
assert style.pixelMetric(metric, None, plain) == \
|
|
2 * style.pixelMetric(metric, None, opted_out)
|
|
|
|
plain.setRange(0, 100)
|
|
plain.resize(300, plain.sizeHint().height())
|
|
plain.show()
|
|
_press(plain, 290) # far right, in one click
|
|
assert plain.value() > 90
|
|
plain.close()
|
|
|
|
|
|
def test_light_and_dark_are_folder_tabs(qapp, tmp_path):
|
|
prefs, dialog = _dialog(tmp_path)
|
|
tabs = dialog._color_mode_buttons
|
|
assert all(isinstance(t, MacTab) for t in tabs.values())
|
|
tabs["dark"].setChecked(True)
|
|
assert not tabs["light"].isChecked()
|
|
dialog.deleteLater()
|
|
|
|
|
|
def test_album_art_says_it_is_clickable(qapp):
|
|
from PyQt6.QtGui import QKeyEvent, QPixmap
|
|
from tests.test_round61 import _art, _track
|
|
art, requested = _art()
|
|
assert art.focusPolicy() == Qt.FocusPolicy.TabFocus
|
|
art.set_track(_track(42)) # no art: a button, no finger
|
|
assert art.cursor().shape() == Qt.CursorShape.ArrowCursor
|
|
art.keyPressEvent(QKeyEvent(QKeyEvent.Type.KeyPress, Qt.Key.Key_Space,
|
|
Qt.KeyboardModifier.NoModifier))
|
|
assert requested == [42] # the keyboard reaches it too
|
|
pixmap = QPixmap(8, 8)
|
|
pixmap.fill(Qt.GlobalColor.red)
|
|
art._pixmap = pixmap
|
|
art._update_cursor()
|
|
assert art.cursor().shape() == Qt.CursorShape.PointingHandCursor
|