Files
soundcraft/crates/ui-egui/tests/mix_separate.rs
Brandon ThomasandClaude Opus 5.5 33a6c3dfbc Test Mix in a separate window: the toggle and closing it
window.mix_separate toggles (and takes a value), Toggle Mix/Edit keeps Edit
in the main window while Mix is separate, a few frames draw both, and
closing the Mix window brings Mix back into the main one. The close handling
moves into mix_window::separate_closed so the test can reach it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 04:38:59 -04:00

38 lines
1.4 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Window › Mix in Separate Window: Edit stays in the main window, and closing the Mix window
//! brings Mix back into it.
use egui::vec2;
use egui_kittest::Harness;
use serde_json::json;
use soundcraft_ui_egui::{MainWindow, Services, SoundApp, mix_window};
#[test]
fn mix_in_a_separate_window_toggles_and_closing_it_returns_to_the_main_window() {
let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default());
assert!(!app.ui.mix_separate);
app.run("window.mix_separate", json!({})).unwrap();
assert!(app.ui.mix_separate);
app.run("window.toggle_mix_edit", json!({})).unwrap();
assert_eq!(app.ui.window, MainWindow::Edit, "Mix is already on screen: the main window keeps Edit");
let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state(
|ui, app: &mut SoundApp| {
app.logic(&ui.ctx().clone());
app.ui(ui);
},
app,
);
h.run_steps(3);
let app = h.state_mut();
assert!(app.ui.mix_separate, "drawing both windows keeps them both");
mix_window::separate_closed(app);
assert!(!app.ui.mix_separate);
assert_eq!(app.ui.window, MainWindow::Mix, "closing the Mix window shows Mix in the main one");
h.run_steps(3);
let app = h.state_mut();
app.run("window.mix_separate", json!({"value": true})).unwrap();
app.run("window.mix_separate", json!({"value": false})).unwrap();
assert!(!app.ui.mix_separate);
}