v0.67.3: the rating column is never narrower than five stars
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Round 100: the rating column is never narrower than five stars."""
|
||||
from PyQt6.QtGui import QFontMetrics
|
||||
|
||||
from lintunes.gui.track_table import TrackTableView, rating_min_width
|
||||
from lintunes.models.playlist import PlaylistSettings
|
||||
|
||||
|
||||
def _view(widths):
|
||||
view = TrackTableView(playlist_mode=False)
|
||||
view.apply_settings(PlaylistSettings(
|
||||
visible_columns=["name", "rating", "date_added"], sort_column="name",
|
||||
column_widths=widths))
|
||||
return view
|
||||
|
||||
|
||||
def test_saved_narrow_width_is_widened(qapp):
|
||||
view = _view({"rating": 20})
|
||||
least = rating_min_width(QFontMetrics(view.font()))
|
||||
assert view.columnWidth(view.model_.fields.index("rating")) == least
|
||||
|
||||
|
||||
def test_dragging_narrower_snaps_back_and_saves_the_minimum(qapp):
|
||||
view = _view({})
|
||||
col = view.model_.fields.index("rating")
|
||||
saved = []
|
||||
view.column_width_changed.connect(lambda f, w: saved.append((f, w)))
|
||||
view.horizontalHeader().resizeSection(col, 10)
|
||||
least = rating_min_width(QFontMetrics(view.font()))
|
||||
assert view.columnWidth(col) == least
|
||||
assert saved == [("rating", least)]
|
||||
|
||||
|
||||
def test_wider_widths_are_left_alone(qapp):
|
||||
view = _view({"rating": 200})
|
||||
assert view.columnWidth(view.model_.fields.index("rating")) == 200
|
||||
Reference in New Issue
Block a user