feat: add heal cut editor action

This commit is contained in:
2026-07-04 20:17:15 +02:00
parent b52b3e19be
commit 9838a4fcfd
2 changed files with 41 additions and 5 deletions
+24 -2
View File
@@ -795,8 +795,8 @@ def test_audio_editor_dialog_scaffold(win):
assert dlg._current() == "/nonexistent.wav"
# widgets present
assert dlg._wave is not None
for name in ("_btn_delete", "_btn_silence", "_btn_reverse", "_btn_trim",
"_btn_undo", "_btn_redo", "_btn_save_as"):
for name in ("_btn_heal_cut", "_btn_delete", "_btn_silence", "_btn_reverse",
"_btn_trim", "_btn_undo", "_btn_redo", "_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()
@@ -821,6 +821,28 @@ def test_editor_delete_builds_command(win, tmp_path, monkeypatch):
assert seen["inp"] == str(src) and seen["s"] == 1.0 and seen["e"] == 3.0
def test_editor_heal_cut_builds_command(win, tmp_path, monkeypatch):
import main as m, pytest
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(2.0, 3.0)
seen = {}
class _Stop(Exception):
pass
def fake(inp, s, e, out):
seen.update(inp=inp, s=s, e=e, out=out)
raise _Stop
monkeypatch.setattr(m, "build_audio_heal_delete_command", fake)
with pytest.raises(_Stop):
dlg._on_heal_cut()
assert seen["inp"] == str(src)
assert seen["s"] == 2.0 and seen["e"] == 3.0
assert seen["out"].endswith(".wav")
def test_editor_op_no_region_is_safe(win, tmp_path, monkeypatch):
import main as m
src = tmp_path / "v0.wav"; src.write_bytes(b"")