fix: sync editor playhead with selection changes

This commit is contained in:
2026-07-04 21:50:18 +02:00
parent a1e90f135f
commit 8f354254b2
2 changed files with 39 additions and 0 deletions
+31
View File
@@ -1158,6 +1158,37 @@ def test_editor_playhead_change_keeps_looping_when_inside_selection(win, tmp_pat
assert stopped["n"] == 0
def test_editor_selection_change_moves_playhead_to_area_start(win, tmp_path):
import main as m
src = tmp_path / "v0.wav"; src.write_bytes(b"")
dlg = m.AudioEditorDialog(str(src), parent=win)
dlg._clip_dur = 6.0
dlg._wave.set_view(0.0, 6.0)
dlg._wave.set_playhead(5.0)
dlg._on_wave_selection_changed(1.5, 3.5)
assert dlg._wave.playhead() == 1.5
def test_editor_selection_change_updates_active_loop_bounds(win, tmp_path, monkeypatch):
import main as m
src = tmp_path / "v0.wav"; src.write_bytes(b"")
dlg = m.AudioEditorDialog(str(src), parent=win)
dlg._clip_dur = 6.0
dlg._wave.set_view(0.0, 6.0)
dlg._wave.set_selection(1.0, 3.0)
dlg._wave.set_playhead(2.0)
dlg._play_proc = object()
dlg._play_loop = True
seen = {}
monkeypatch.setattr(
dlg, "_play_current",
lambda start=None, end=None, loop=False:
seen.update(start=start, end=end, loop=loop))
dlg._on_wave_selection_changed(1.0, 4.0)
assert seen == {"start": 1.0, "end": 4.0, "loop": True}
assert dlg._wave.playhead() == 1.0
def test_editor_has_local_speed_controls(win, tmp_path):
import main as m
from PyQt6.QtWidgets import QPushButton