Files
soundcraft/crates/engine/tests/recording.rs
grovebit 62cb92c4df Never replace or quit a session while it records
Opening, creating, closing or reverting a session in the middle of a
take dropped the recorder: the take was written to disk but never added
to any session. Quitting mid-take did the same, and on_exit didn't
finish the take either.

New, Open, Close, Revert and Quit now wait for the take: the engine
refuses them with "stop recording first", and their menu items are
greyed out while recording, as is Recover in the recovery window. Any
exit that still happens mid-take (closing the window, the system
quitting the app, a remote quit) finishes the take first and keeps the
session, take included, in the autosave folder for the next launch.
2026-10-12 23:33:48 +01:00

22 lines
815 B
Rust

//! A take being recorded is never replaced or quit away from.
use serde_json::json;
use soundcraft_engine::{Engine, EngineError};
#[test]
fn nothing_replaces_or_quits_a_session_while_it_records() {
let mut e = Engine::default();
e.transport.recording = true;
for (id, params) in [
("session.new", json!({})),
("session.open", json!({"path": "Song.scraft"})),
("session.close", json!({})),
("session.revert", json!({})),
("app.quit", json!({})),
] {
assert!(matches!(e.execute(id, &params), Err(EngineError::Disabled(_, why)) if why == "stop recording first"), "{id}");
}
assert!(e.execute("track.new", &json!({})).is_ok(), "editing goes on");
e.transport.recording = false;
assert!(e.execute("session.close", &json!({})).is_ok());
}