54 lines
2.0 KiB
Python
54 lines
2.0 KiB
Python
"""Round 111: the visualizer page's sliders are tall and jump where clicked;
|
||
the radial dot size reads as a share of the spacing between dots."""
|
||
from unittest.mock import MagicMock
|
||
|
||
from PyQt6.QtCore import QPoint, Qt
|
||
from PyQt6.QtTest import QTest
|
||
|
||
from lintunes.gui import preferences_dialog as pd
|
||
from lintunes.gui.preferences_dialog import PreferencesDialog
|
||
from lintunes.gui.transport import ClickJumpSlider
|
||
from lintunes.preferences import Preferences
|
||
|
||
|
||
def _dialog(tmp_path):
|
||
dialog = PreferencesDialog(Preferences(tmp_path), MagicMock())
|
||
dialog.resize(900, 700)
|
||
dialog.pages_list.setCurrentRow(2)
|
||
dialog._viz_radios["radial"].setChecked(True)
|
||
dialog.show()
|
||
QTest.qWait(20)
|
||
return dialog
|
||
|
||
|
||
def test_visualizer_sliders_are_tall_click_jump_sliders(qapp, tmp_path):
|
||
dialog = _dialog(tmp_path)
|
||
sliders = [dialog._radial_dot_slider, dialog._fade_slider,
|
||
dialog._sync_sliders["radial"], dialog._dot_slider]
|
||
for slider in sliders:
|
||
assert isinstance(slider, ClickJumpSlider)
|
||
assert slider.property("tall")
|
||
dialog.close()
|
||
|
||
|
||
def test_a_click_puts_the_handle_where_it_lands(qapp, tmp_path):
|
||
dialog = _dialog(tmp_path)
|
||
slider = dialog._radial_dot_slider
|
||
y = slider.height() // 2
|
||
QTest.mouseClick(slider, Qt.MouseButton.LeftButton, pos=QPoint(0, y))
|
||
assert slider.value() == slider.minimum()
|
||
QTest.mouseClick(slider, Qt.MouseButton.LeftButton,
|
||
pos=QPoint(slider.width() - 1, y))
|
||
assert slider.value() == slider.maximum()
|
||
QTest.mouseClick(slider, Qt.MouseButton.LeftButton,
|
||
pos=QPoint(slider.width() // 2, y))
|
||
middle = (slider.minimum() + slider.maximum()) / 2
|
||
assert abs(slider.value() - middle) <= 2 # not one page step from the end
|
||
dialog.close()
|
||
|
||
|
||
def test_dot_size_is_a_share_of_the_spacing():
|
||
# The automatic size (1×) is 70% of the gap; dots touch at 100%.
|
||
assert pd._dot_text(1.0) == "70%"
|
||
assert pd._dot_text(1 / 0.7) == "100%"
|