fix: anchor locked marker review at start

This commit is contained in:
2026-07-04 20:52:27 +02:00
parent 36fc1b9591
commit fe95076195
2 changed files with 81 additions and 17 deletions
+50
View File
@@ -407,6 +407,56 @@ def test_timeline_audio_mode_lock_click_scrubs_playhead_not_region(win):
assert got_seek and abs(got_seek[-1] - 12.0) < 0.1
def test_timeline_lock_mode_paints_playhead_line(win):
from PyQt6.QtGui import QColor, QImage
tl = win._timeline
tl._duration = 20.0
tl._view_start = 0.0
tl._view_span = 20.0
tl.resize(400, 160)
tl.set_audio_mode(False)
tl.set_clip_span(8.0, 8.0, 3.0)
tl.set_cursor(4.0)
tl._locked = True
tl.set_play_position(7.0)
img = QImage(tl.size(), QImage.Format.Format_ARGB32)
img.fill(QColor(0, 0, 0))
tl.render(img)
x = int(tl._time_to_x(7.0))
y = tl._SCROLLBAR_H + tl._RULER_H + 24
px = QColor(img.pixel(x, y))
assert px.green() > 200
assert px.green() > px.red() + 80
def test_locked_marker_click_anchors_start_and_shows_end_playhead(win, monkeypatch):
win._file_path = "/x/video.mp4"
win._timeline._duration = 60.0
win._spn_clip_dur.setValue(8.0)
win._spn_clips.setValue(1)
win._spn_spread.setValue(3.0)
win._timeline.set_clip_span(win._clip_span, win._clip_dur, win._spn_spread.value())
win._btn_lock.setChecked(True)
seeks = []
monkeypatch.setattr(win._mpv, "seek", lambda t: seeks.append(t))
monkeypatch.setattr(win._mpv, "get_duration", lambda: 60.0)
monkeypatch.setattr(
win._db,
"get_by_output_path",
lambda _path: {"clip_count": 3, "clip_duration": 6.0, "spread": 2.0},
)
win._on_marker_clicked(10.0, "/tmp/clip_001.mp4")
assert abs(win._cursor - 10.0) < 0.01
assert abs(win._timeline._cursor - 10.0) < 0.01
assert abs(win._timeline._clip_span - 10.0) < 0.01
assert abs((win._timeline._play_pos or 0.0) - 20.0) < 0.01
assert seeks == [20.0]
def test_timeline_audio_mode_follows_deck(win):
win._control_deck.setCurrentWidget(win._tab_audio)
assert win._timeline._audio_mode is True