feat: preview healed joins and save editor clips to library
This commit is contained in:
@@ -796,7 +796,8 @@ def test_audio_editor_dialog_scaffold(win):
|
||||
# widgets present
|
||||
assert dlg._wave is not None
|
||||
for name in ("_btn_heal_cut", "_btn_delete", "_btn_silence", "_btn_reverse",
|
||||
"_btn_trim", "_btn_undo", "_btn_redo", "_btn_save_as"):
|
||||
"_btn_trim", "_btn_undo", "_btn_redo", "_btn_loop_join",
|
||||
"_btn_save_library", "_btn_save_as"):
|
||||
assert isinstance(getattr(dlg, name), QPushButton)
|
||||
# undo disabled at the base version, redo disabled with no forward history
|
||||
assert not dlg._btn_undo.isEnabled()
|
||||
@@ -907,6 +908,49 @@ def test_editor_play_stop_safe(win, tmp_path):
|
||||
assert dlg._btn_play.text() == "▶ Play"
|
||||
|
||||
|
||||
def test_editor_loop_join_plays_preview_range(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._join_preview = (1.0, 3.0)
|
||||
seen = {}
|
||||
monkeypatch.setattr(
|
||||
dlg, "_play_current",
|
||||
lambda start=None, end=None: seen.update(start=start, end=end))
|
||||
dlg._on_loop_join()
|
||||
assert seen == {"start": 1.0, "end": 3.0}
|
||||
|
||||
|
||||
def test_editor_save_to_library_adds_current_version(win, tmp_path, monkeypatch):
|
||||
import main as m
|
||||
src = tmp_path / "v0.wav"
|
||||
src.write_bytes(b"")
|
||||
out_dir = tmp_path / "library"
|
||||
win._settings.setValue("audio_library_dir", str(out_dir))
|
||||
dlg = m.AudioEditorDialog(str(src), parent=win)
|
||||
dlg._clip_dur = 2.0
|
||||
saved = []
|
||||
monkeypatch.setattr(
|
||||
m, "build_audio_clip_command",
|
||||
lambda inp, start, dur, out: ["ffmpeg", out])
|
||||
|
||||
def fake_run(cmd, capture_output=True, timeout=300):
|
||||
target = cmd[-1]
|
||||
os.makedirs(os.path.dirname(target), exist_ok=True)
|
||||
with open(target, "wb") as f:
|
||||
f.write(b"x")
|
||||
class Proc:
|
||||
returncode = 0
|
||||
return Proc()
|
||||
|
||||
monkeypatch.setattr(m.subprocess, "run", fake_run)
|
||||
win._scan_panel._library.add_clip = lambda p: saved.append(p)
|
||||
dlg._on_save_to_library()
|
||||
assert saved
|
||||
assert saved[0].startswith(str(out_dir))
|
||||
|
||||
|
||||
def test_editor_close_cleans_temps(win, tmp_path):
|
||||
import main as m
|
||||
src = tmp_path / "v0.wav"; src.write_bytes(b"")
|
||||
|
||||
Reference in New Issue
Block a user