From 55078b0f236ccbaef8f4f3da3003b658db29a6aa Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 23 Nov 2026 22:26:48 +0000 Subject: [PATCH] Tests on next: runtime installed in the UI harnesses, dock tests on commands and the model, renderer gesture tests removed --- crates/ui-egui/src/control/tests.rs | 22 +++ crates/ui-egui/src/dialogs/new_tracks.rs | 2 +- crates/ui-egui/src/edit_window/tests.rs | 3 +- crates/ui-egui/src/mix_window/output.rs | 2 +- crates/ui-egui/src/preferences.rs | 6 +- crates/ui-egui/src/tests.rs | 18 +++ crates/ui-egui/src/theme.rs | 2 + crates/ui-egui/tests/delete_key.rs | 2 +- crates/ui-egui/tests/edit_io_readout.rs | 2 +- crates/ui-egui/tests/grid_lines.rs | 3 + crates/ui-egui/tests/it/appearance.rs | 2 +- crates/ui-egui/tests/it/auto_rename.rs | 2 +- crates/ui-egui/tests/it/bounce.rs | 2 +- crates/ui-egui/tests/it/bounce_dialog.rs | 2 +- crates/ui-egui/tests/it/clip_gain_fader.rs | 1 + crates/ui-egui/tests/it/clip_looping.rs | 2 +- crates/ui-egui/tests/it/clip_menu.rs | 2 +- crates/ui-egui/tests/it/docking_columns.rs | 147 ++++++------------ crates/ui-egui/tests/it/docking_workflows.rs | 143 ++++++----------- crates/ui-egui/tests/it/edit_modes.rs | 3 +- .../ui-egui/tests/it/edit_window_headers.rs | 2 +- .../tests/it/focused_dialog_buttons.rs | 8 +- crates/ui-egui/tests/it/group_dialog.rs | 4 +- crates/ui-egui/tests/it/idle.rs | 1 + crates/ui-egui/tests/it/import_browse.rs | 2 +- crates/ui-egui/tests/it/long_menu_scroll.rs | 2 +- crates/ui-egui/tests/it/marker_rename.rs | 1 + crates/ui-egui/tests/it/menu_search.rs | 2 +- crates/ui-egui/tests/it/midi_double_click.rs | 1 + crates/ui-egui/tests/it/midi_editor_keys.rs | 2 +- crates/ui-egui/tests/it/midi_inputs.rs | 2 +- crates/ui-egui/tests/it/midi_panel.rs | 132 +--------------- crates/ui-egui/tests/it/midi_quantize.rs | 2 +- crates/ui-egui/tests/it/mix_narrow_headers.rs | 2 +- crates/ui-egui/tests/it/mix_separate.rs | 2 +- crates/ui-egui/tests/it/new_midi_clip.rs | 1 + crates/ui-egui/tests/it/new_tracks.rs | 2 +- crates/ui-egui/tests/it/open_on_insert.rs | 2 +- .../ui-egui/tests/it/plugin_default_reset.rs | 2 +- .../ui-egui/tests/it/plugin_fine_sliders.rs | 2 +- crates/ui-egui/tests/it/plugin_window.rs | 2 +- crates/ui-egui/tests/it/pro_tools_keys.rs | 2 + crates/ui-egui/tests/it/record_hint.rs | 2 +- crates/ui-egui/tests/it/rename_dialog.rs | 2 +- crates/ui-egui/tests/it/rtp_window.rs | 2 +- crates/ui-egui/tests/it/sampler_window.rs | 2 +- crates/ui-egui/tests/it/save_as_replace.rs | 2 +- crates/ui-egui/tests/it/save_changes.rs | 2 +- crates/ui-egui/tests/it/scroll_into_view.rs | 2 +- crates/ui-egui/tests/it/send_window.rs | 2 +- crates/ui-egui/tests/it/shared_controls.rs | 6 +- crates/ui-egui/tests/it/shortcuts.rs | 6 +- crates/ui-egui/tests/it/side_lists_access.rs | 2 +- crates/ui-egui/tests/it/side_lists_text.rs | 2 +- .../ui-egui/tests/it/strip_silence_dialog.rs | 2 +- .../tests/it/strip_silence_rectangles.rs | 2 +- .../ui-egui/tests/it/strip_silence_rename.rs | 2 +- .../ui-egui/tests/it/strip_silence_sliders.rs | 2 +- crates/ui-egui/tests/it/sub_counter.rs | 1 + crates/ui-egui/tests/it/toolbar_scroll.rs | 2 +- crates/ui-egui/tests/it/toolbar_tempo.rs | 1 + crates/ui-egui/tests/it/track_height.rs | 1 + crates/ui-egui/tests/it/track_list.rs | 1 + crates/ui-egui/tests/it/track_name_menu.rs | 2 +- crates/ui-egui/tests/it/trackpad.rs | 1 + crates/ui-egui/tests/it/tracks_scroll_bar.rs | 2 +- crates/ui-egui/tests/it/waveform.rs | 2 + crates/ui-egui/tests/it/zoom_toggle.rs | 4 +- .../ui-egui/tests/mix_instrument_contrast.rs | 5 +- crates/ui-egui/tests/mix_strip_layout.rs | 2 +- crates/ui-egui/tests/recovery.rs | 4 +- crates/ui-egui/tests/theme_docking.rs | 2 +- 72 files changed, 234 insertions(+), 382 deletions(-) diff --git a/crates/ui-egui/src/control/tests.rs b/crates/ui-egui/src/control/tests.rs index e12545ff1..93501bd72 100644 --- a/crates/ui-egui/src/control/tests.rs +++ b/crates/ui-egui/src/control/tests.rs @@ -93,6 +93,7 @@ fn tmp(name: &str) -> PathBuf { #[test] fn a_screenshot_completes_once_and_writes_one_file() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let path = tmp("success"); let _ = std::fs::remove_file(&path); @@ -114,6 +115,7 @@ fn a_screenshot_completes_once_and_writes_one_file() { #[test] fn a_callback_after_the_deadline_times_out_without_writing() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let path = tmp("late"); let reply = request(&mut a, Some(&path)); @@ -132,6 +134,7 @@ fn a_callback_after_the_deadline_times_out_without_writing() { #[test] fn a_session_change_cancels_the_request_and_releases_its_pixels() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let path = tmp("document"); let reply = request(&mut a, Some(&path)); @@ -150,6 +153,7 @@ fn a_session_change_cancels_the_request_and_releases_its_pixels() { #[test] fn admission_rejects_more_than_eight_pending_requests() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); for i in 0..MAX_PENDING_SHOTS { let (req, _reply) = ControlRequest::new("ui.screenshot", json!({})); @@ -165,6 +169,7 @@ fn admission_rejects_more_than_eight_pending_requests() { #[test] fn admission_rejects_an_image_over_the_per_image_and_aggregate_budgets() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); let mut big = raw_input(5000.0, 5000.0, 8192); a.raw_input_hook(&ctx, &mut big); let (req, _reply) = ControlRequest::new("ui.screenshot", json!({})); @@ -190,6 +195,7 @@ fn admission_rejects_an_image_over_the_per_image_and_aggregate_budgets() { #[test] fn a_changed_window_retries_once_instead_of_writing_stale_pixels() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let path = tmp("retry"); let reply = request(&mut a, Some(&path)); @@ -248,6 +254,7 @@ fn a_missing_max_texture_side_uses_the_last_known_limit() { #[test] fn a_window_without_geometry_reports_no_capturable_size() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.host_geometry = Some(CaptureGeometry { points: egui::Vec2::ZERO, pixels_per_point: 1.0, max_texture_side: 8192, focused: true }); let (req, _reply) = ControlRequest::new("ui.screenshot", json!({})); let e = admit(&mut a, &ctx, &req).expect_err("no capturable size"); @@ -259,6 +266,7 @@ fn a_window_without_geometry_reports_no_capturable_size() { #[test] fn a_document_replaced_outside_run_cancels_a_pending_capture() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let reply = request(&mut a, None); let out = frame(&mut a, &ctx, raw_input(800.0, 600.0, 8192)); @@ -278,6 +286,7 @@ fn a_document_replaced_outside_run_cancels_a_pending_capture() { #[test] fn a_queued_click_is_applied_before_a_following_inspect_and_screenshot() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let kick = a.engine.session().track_by_name("Kick").expect("demo has Kick").id; assert!(!a.engine.session().track(kick).expect("kick").mixer.mute); @@ -338,6 +347,7 @@ fn a_queued_click_is_applied_before_a_following_inspect_and_screenshot() { #[test] fn a_capture_slot_is_bounded_by_its_own_reservation() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let (tx, rx) = channel(); let (req, first) = ControlRequest::new("ui.screenshot", json!({})); @@ -379,6 +389,7 @@ fn png_bytes_checks_its_dimensions_and_allocation() { #[test] fn control_input_queues_and_text_are_bounded() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.synthetic = (0..MAX_SYNTHETIC_EVENTS).map(|_| egui::Event::PointerMoved(egui::pos2(0.0, 0.0))).collect(); let (req, _reply) = ControlRequest::new("ui.move", json!({"x": 1.0, "y": 2.0})); let v = handle(&mut a, &ctx, &req).expect("the refusal replies immediately"); @@ -405,6 +416,7 @@ fn control_input_queues_and_text_are_bounded() { #[test] fn a_very_long_screenshot_path_is_refused_before_it_is_retained() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let path = "x".repeat(MAX_SHOT_PATH_BYTES + 1); let (req, _reply) = ControlRequest::new("ui.screenshot", json!({"path": path})); @@ -418,6 +430,7 @@ fn a_very_long_screenshot_path_is_refused_before_it_is_retained() { #[test] fn an_undelivered_gesture_is_canceled_without_wedging_the_next_request() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); let (req, reply) = ControlRequest::new("ui.click", json!({"x": 10.0, "y": 10.0})); assert!(handle(&mut a, &ctx, &req).is_none(), "the click waits for a UI pass"); a.advance_test_clock(Duration::from_secs(16)); @@ -440,6 +453,7 @@ fn an_undelivered_gesture_is_canceled_without_wedging_the_next_request() { fn a_timed_out_consumed_press_cancels_without_clicking_and_the_next_click_works() { for expires_after_hook in [false, true] { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); let kick = a.engine.session().track_by_name("Kick").unwrap().id; @@ -491,6 +505,7 @@ fn a_timed_out_consumed_press_cancels_without_clicking_and_the_next_click_works( #[test] fn a_timed_out_scripted_key_after_the_hook_does_not_run_and_the_next_key_works() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); a.run("track.new", json!({"count": 1, "format": "stereo"})).unwrap(); @@ -573,6 +588,7 @@ fn host_line_wheel(dy: f32) -> egui::Event { #[test] fn a_timed_out_scripted_scroll_after_the_hook_does_not_scroll_or_keep_smoothing() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); // Make the track area overflow so a real wheel would actually move the view. @@ -649,6 +665,7 @@ fn a_timed_out_scripted_scroll_after_the_hook_does_not_scroll_or_keep_smoothing( #[test] fn a_timed_out_scripted_zoom_after_the_hook_does_not_zoom_and_the_next_zoom_works_once() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); let at = timeline_center(&a); @@ -710,6 +727,7 @@ fn a_timed_out_scripted_zoom_after_the_hook_does_not_zoom_and_the_next_zoom_work #[test] fn a_fresh_identical_host_wheel_after_a_drawn_expiry_is_not_swallowed() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); a.run("track.new", json!({"count": 20, "format": "stereo"})).unwrap(); @@ -749,6 +767,7 @@ fn a_fresh_identical_host_wheel_after_a_drawn_expiry_is_not_swallowed() { #[test] fn a_host_key_held_across_passes_survives_a_replayed_scroll_cancel() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); a.run("track.new", json!({"count": 20, "format": "stereo"})).unwrap(); @@ -790,6 +809,7 @@ fn a_host_key_held_across_passes_survives_a_replayed_scroll_cancel() { #[test] fn an_expiry_in_a_discarded_pass_does_not_replay_host_events() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); a.run("track.new", json!({"count": 1, "format": "stereo"})).unwrap(); @@ -842,6 +862,7 @@ fn an_expiry_in_a_discarded_pass_does_not_replay_host_events() { #[test] fn a_timed_out_track_drag_cancels_without_dropping_and_the_next_drag_works() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); a.advance_test_clock(Duration::ZERO); warm(&mut a, &ctx); let before: Vec<_> = a.engine.session().tracks.iter().map(|track| track.id).collect(); @@ -882,6 +903,7 @@ fn a_timed_out_track_drag_cancels_without_dropping_and_the_next_drag_works() { #[test] fn scroll_reports_the_wheel_and_trackpad_sources_after_delivery() { let (mut a, ctx) = (app(), egui::Context::default()); + crate::framework::install_headless(&ctx); warm(&mut a, &ctx); let (req, reply) = ControlRequest::new("ui.scroll", json!({"x": 10.0, "y": 10.0, "dy": -30.0, "unit": "line", "steps": 2})); assert!(handle(&mut a, &ctx, &req).is_none(), "the reply waits for delivery"); diff --git a/crates/ui-egui/src/dialogs/new_tracks.rs b/crates/ui-egui/src/dialogs/new_tracks.rs index 86f54526b..89c2b8081 100644 --- a/crates/ui-egui/src/dialogs/new_tracks.rs +++ b/crates/ui-egui/src/dialogs/new_tracks.rs @@ -360,7 +360,7 @@ mod tests { fn harness() -> Harness<'static, SoundApp> { let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); assert!(app.dialogs.open_for_command(&app.engine, "track.new")); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/edit_window/tests.rs b/crates/ui-egui/src/edit_window/tests.rs index 4a2ac4d1c..1f2255252 100644 --- a/crates/ui-egui/src/edit_window/tests.rs +++ b/crates/ui-egui/src/edit_window/tests.rs @@ -283,7 +283,8 @@ fn harness(n: usize) -> Harness<'static, SoundApp> { fn harness_with(engine: soundcraft_engine::Engine) -> Harness<'static, SoundApp> { let app = SoundApp::new(engine, None, crate::Services::default()); - let builder = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0); + let builder = + Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).with_context_setup(crate::framework::install_headless); let builder = if std::env::var_os("SOUNDCRAFT_FADE_SHOTS").is_some() { builder.wgpu() } else { builder }; let mut h = builder.build_ui_state( |ui, app: &mut SoundApp| { diff --git a/crates/ui-egui/src/mix_window/output.rs b/crates/ui-egui/src/mix_window/output.rs index 70cf8247f..2851be19f 100644 --- a/crates/ui-egui/src/mix_window/output.rs +++ b/crates/ui-egui/src/mix_window/output.rs @@ -147,7 +147,7 @@ mod tests { app.run("view.edit_io", json!({})).unwrap(); app.run("track.height", json!({"tracks": ["Kick"], "height": "medium"})).unwrap(); let kick = app.engine.session().track_by_name("Kick").unwrap().id; - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/src/preferences.rs b/crates/ui-egui/src/preferences.rs index e65addd99..cd6963f7c 100644 --- a/crates/ui-egui/src/preferences.rs +++ b/crates/ui-egui/src/preferences.rs @@ -1107,7 +1107,7 @@ mod tests { fn preferences_harness(size: egui::Vec2) -> Harness<'static, SoundApp> { let mut app = SoundApp::new(Engine::default(), None, crate::Services::default()); app.ui.show_preferences = true; - Harness::builder().with_size(size).build_ui_state( + Harness::builder().with_context_setup(crate::framework::install_headless).with_size(size).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); @@ -1395,7 +1395,7 @@ mod tests { #[test] fn soundcraft_menu_opens_preferences_through_the_same_command() { let app = SoundApp::new(Engine::default(), None, crate::Services::default()); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( + let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); @@ -1415,7 +1415,7 @@ mod tests { fn soundcraft_menu_disables_preferences_during_playback() { let mut app = SoundApp::new(Engine::default(), None, crate::Services::default()); app.engine.transport.playing = true; - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( + let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 8efe94374..1702ae06e 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -527,6 +527,7 @@ fn ordinary_play_after_stop_is_full_speed() { #[test] fn one_synthetic_batch_survives_hidden_ticks_and_applies_once() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let raw = |w: f32| { let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(w, 900.0)); @@ -588,6 +589,7 @@ impl egui::DroppedFile for TestDrop { #[test] fn a_drop_before_fonts_are_ready_is_imported_once_after_layout() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::Engine::default(), None, super::Services::default()); let mut first = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0))), ..Default::default() }; @@ -617,6 +619,7 @@ fn a_drop_before_fonts_are_ready_is_imported_once_after_layout() { #[test] fn a_retained_host_input_holds_one_copy_of_a_pending_batch() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let hidden = egui::ViewportInfo { minimized: Some(true), ..Default::default() }; @@ -697,6 +700,7 @@ fn a_pending_synthetic_batch_asks_a_hidden_window_for_a_paint() { #[test] fn frame_time_counts_a_multi_pass_frame_once() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -731,6 +735,7 @@ fn frame_time_counts_a_multi_pass_frame_once() { #[test] fn a_synthetic_pass_does_not_publish_os_clipboard_commands() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -782,6 +787,7 @@ fn a_synthetic_pass_does_not_publish_os_clipboard_commands() { #[test] fn a_held_key_does_not_turn_a_scripted_press_into_a_repeat() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -855,6 +861,7 @@ fn key_pass(ctx: &egui::Context, app: &mut SoundApp, events: Vec) { /// The demo app after a few idle passes, ready for keyboard input. fn app_for_keys() -> (egui::Context, SoundApp) { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); for _ in 0..4 { key_pass(&ctx, &mut app, Vec::new()); @@ -917,6 +924,7 @@ fn holding_cmd_z_or_enter_still_runs_once() { #[test] fn a_fresh_host_press_and_a_scripted_press_both_run() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -955,6 +963,7 @@ fn a_fresh_host_press_and_a_scripted_press_both_run() { #[test] fn a_hidden_logic_tick_after_the_hook_keeps_the_held_key_and_pending_batch() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let visible = egui::ViewportInfo { inner_rect: Some(rect), ..Default::default() }; @@ -1023,6 +1032,7 @@ fn a_hidden_logic_tick_after_the_hook_keeps_the_held_key_and_pending_batch() { #[test] fn a_multi_pass_frame_keeps_the_held_key_and_applies_the_scripted_press_once() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -1080,6 +1090,7 @@ fn a_multi_pass_frame_keeps_the_held_key_and_applies_the_scripted_press_once() { #[test] fn a_focus_loss_clears_a_held_key_with_a_pending_scripted_press() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -1138,6 +1149,7 @@ fn a_focus_loss_clears_a_held_key_with_a_pending_scripted_press() { #[test] fn a_host_key_with_the_same_signature_does_not_acknowledge_the_batch() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -1223,6 +1235,7 @@ fn synthetic_key_acknowledgement_ignores_only_the_rewritten_repeat_flag() { #[test] fn a_discarded_pass_acknowledges_the_synthetic_batch_it_received() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -1287,6 +1300,7 @@ fn real_widgets_apply_a_scripted_edit_navigation_and_cut_once_despite_consuming_ let mut engine = soundcraft_engine::Engine::default(); engine.execute("track.new", &json!({})).unwrap(); let mut rig = Self { ctx: egui::Context::default(), app: SoundApp::new(engine, None, Services::default()), shapes: Vec::new() }; + crate::framework::install_headless(&rig.ctx); rig.frames(4); rig } @@ -1417,6 +1431,7 @@ fn real_widgets_apply_a_scripted_edit_navigation_and_cut_once_despite_consuming_ #[test] fn a_hidden_tick_does_not_write_automation_from_the_last_pass_pointer() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let kick = app.engine.session().track_by_name("Kick").unwrap().id; app.run("mix.automation_mode", json!({"tracks": ["Kick"], "mode": "touch"})).unwrap(); @@ -1459,6 +1474,7 @@ fn a_hidden_tick_does_not_write_automation_from_the_last_pass_pointer() { #[test] fn a_font_gated_pass_does_not_ack_the_pending_synthetic_batch() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -1500,6 +1516,7 @@ fn a_font_gated_pass_does_not_ack_the_pending_synthetic_batch() { #[test] fn a_settled_pass_that_did_not_receive_the_batch_does_not_ack_it() { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = super::SoundApp::new(soundcraft_engine::demo::demo_engine(), None, super::Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; @@ -1611,6 +1628,7 @@ fn editor_gesture_polling_survives_discarded_and_hidden_host_iterations() { use std::rc::Rc; let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 900.0)); let raw = || egui::RawInput { screen_rect: Some(rect), ..Default::default() }; diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 609144722..4fcfc6186 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -656,12 +656,14 @@ mod tests { let appearances = [Some(egui::Theme::Light), Some(egui::Theme::Dark), Some(egui::Theme::Light), None]; for initial in [Some(egui::Theme::Light), Some(egui::Theme::Dark), None] { let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); app.ui = serde_json::from_value(json!({"theme": "system"})).unwrap(); frame(&mut app, &ctx, initial, initial == Some(egui::Theme::Light)); } let ctx = egui::Context::default(); + crate::framework::install_headless(&ctx); let mut engine = soundcraft_engine::demo::demo_engine(); let track = engine.session_mut().tracks.first_mut().unwrap(); track.color = [19, 83, 147]; diff --git a/crates/ui-egui/tests/delete_key.rs b/crates/ui-egui/tests/delete_key.rs index 247a13174..7085c4683 100644 --- a/crates/ui-egui/tests/delete_key.rs +++ b/crates/ui-egui/tests/delete_key.rs @@ -65,7 +65,7 @@ fn the_midi_editor_keeps_the_key_for_its_selected_notes() { let end: i64 = 48_000 * 600; app.run("edit.select", json!({"tracks": ["Keys"], "start": 0, "end": end})).unwrap(); let clips_before = clips(&app, "Keys"); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/edit_io_readout.rs b/crates/ui-egui/tests/edit_io_readout.rs index fe7b1068d..1fb4a72dc 100644 --- a/crates/ui-egui/tests/edit_io_readout.rs +++ b/crates/ui-egui/tests/edit_io_readout.rs @@ -22,7 +22,7 @@ fn the_io_columns_vol_and_pan_readout_is_readable_in_both_themes() { app.run("view.edit_io", json!({})).unwrap(); app.run("track.height", json!({"tracks": ["Kick"], "height": "medium"})).unwrap(); app.run("ui.theme", json!({"mode": mode.id()})).unwrap(); - let mut harness = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut harness = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/tests/grid_lines.rs b/crates/ui-egui/tests/grid_lines.rs index 6b0301d45..15659309d 100644 --- a/crates/ui-egui/tests/grid_lines.rs +++ b/crates/ui-egui/tests/grid_lines.rs @@ -28,6 +28,7 @@ fn near(a: [i32; 3], b: Color32) -> bool { fn grid_lines_are_drawn_over_clips_while_shown() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); for theme in ["dark", "light"] { for shown in [true, false] { app.run("ui.theme", json!({"mode": theme})).unwrap(); @@ -76,6 +77,7 @@ fn grid_lines_are_drawn_over_clips_while_shown() { fn clips_markers_grid_draws_a_line_at_a_memory_location() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); let kick = app.engine.session().track_by_name("Kick").unwrap(); let clip = &kick.clips()[0]; let marker = clip.start + clip.length / 3; @@ -133,6 +135,7 @@ fn clips_markers_lines_refresh_across_lanes_and_hidden_open_folders() { s.edit.grid_lines = true; let mut app = SoundApp::new(engine, None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); for (start, marker, scroll, zoom) in [(1_200, 9_000, 0, 20.0), (3_000, 11_000, 0, 20.0), (3_000, 11_000, 1_000, 40.0)] { let s = app.engine.session_mut(); diff --git a/crates/ui-egui/tests/it/appearance.rs b/crates/ui-egui/tests/it/appearance.rs index 87145a855..e032279e6 100644 --- a/crates/ui-egui/tests/it/appearance.rs +++ b/crates/ui-egui/tests/it/appearance.rs @@ -21,7 +21,7 @@ fn frame(h: &mut Harness<'_, SoundApp>, px: Pos2, pressed: Option) { fn interface_scale_slider_follows_the_pointer() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); app.extra.show_ui_customization = true; - let mut h = Harness::builder().with_size(WINDOW_PX).with_pixels_per_point(1.0).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(WINDOW_PX).with_pixels_per_point(1.0).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/auto_rename.rs b/crates/ui-egui/tests/it/auto_rename.rs index 3dfd675cb..7929a5b40 100644 --- a/crates/ui-egui/tests/it/auto_rename.rs +++ b/crates/ui-egui/tests/it/auto_rename.rs @@ -15,7 +15,7 @@ fn auto_rename_dialog() -> (Harness<'static, SoundApp>, TrackId, ClipId) { app.run("edit.select", json!({"clips": [clip.0]})).unwrap(); menus::invoke_menu(&mut app, "clip.auto_rename", ""); assert_eq!(app.dialogs.open_name(), Some("auto_rename")); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/bounce.rs b/crates/ui-egui/tests/it/bounce.rs index 9675b214d..bf00188ef 100644 --- a/crates/ui-egui/tests/it/bounce.rs +++ b/crates/ui-egui/tests/it/bounce.rs @@ -8,7 +8,7 @@ use std::path::{Path, PathBuf}; fn harness() -> Harness<'static, SoundApp> { let app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); - let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_max_steps(1_000).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 900.0)).with_max_steps(1_000).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/bounce_dialog.rs b/crates/ui-egui/tests/it/bounce_dialog.rs index df95281d2..632f9e98f 100644 --- a/crates/ui-egui/tests/it/bounce_dialog.rs +++ b/crates/ui-egui/tests/it/bounce_dialog.rs @@ -19,7 +19,7 @@ fn bounce_starts_in_the_session_folder_and_browse_picks_the_file_and_format() { engine.path = Some("/Songs/Midnight Groove/Midnight Groove.scraft".into()); let mut app = SoundApp::new(engine, None, Services { pick_save: Some(pick_save), ..Default::default() }); assert!(app.dialogs.open_for_command(&app.engine, "file.bounce_mix")); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/clip_gain_fader.rs b/crates/ui-egui/tests/it/clip_gain_fader.rs index 2d456b3ee..afafbea45 100644 --- a/crates/ui-egui/tests/it/clip_gain_fader.rs +++ b/crates/ui-egui/tests/it/clip_gain_fader.rs @@ -21,6 +21,7 @@ fn the_clip_gain_icon_drags_with_the_pointer_in_one_undo_step() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); app.engine.execute("view.clip_gain_info", &json!({"value": true})).unwrap(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); frame(&ctx, &mut app, vec![]); frame(&ctx, &mut app, vec![]); let s = app.engine.session().clone(); diff --git a/crates/ui-egui/tests/it/clip_looping.rs b/crates/ui-egui/tests/it/clip_looping.rs index 310859e3c..8a78fe61d 100644 --- a/crates/ui-egui/tests/it/clip_looping.rs +++ b/crates/ui-egui/tests/it/clip_looping.rs @@ -23,7 +23,7 @@ fn clip_looping_fills_up_to_the_next_clip() { assert_eq!(app.dialogs.open_name(), Some("clip_looping")); assert_eq!(app.engine.session().track(track).unwrap().clips().len(), before); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/clip_menu.rs b/crates/ui-egui/tests/it/clip_menu.rs index bfac15b61..0f62703be 100644 --- a/crates/ui-egui/tests/it/clip_menu.rs +++ b/crates/ui-egui/tests/it/clip_menu.rs @@ -37,7 +37,7 @@ fn kick_clip_count(h: &Harness<'_, SoundApp>) -> usize { fn demo() -> Harness<'static, SoundApp> { let engine = soundcraft_engine::demo::demo_engine(); let app = SoundApp::new(engine, None, Services::default()); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).with_pixels_per_point(2.0).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).with_pixels_per_point(2.0).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/docking_columns.rs b/crates/ui-egui/tests/it/docking_columns.rs index 32ccbe000..9c30da434 100644 --- a/crates/ui-egui/tests/it/docking_columns.rs +++ b/crates/ui-egui/tests/it/docking_columns.rs @@ -1,63 +1,67 @@ -//! The side lists in dock columns: the default shapes, saved layouts, drops into a column and -//! panels reopening in their dock. -use craft_behavior::dock::{Column, DockEdge, Group, Node}; -use craft_ui::docking::{Divider, DockArea, Hit}; -use craft_behavior::dock::SplitSize; +//! The side lists in dock columns: the default shapes, saved layouts and panels reopening in +//! their dock. +use craft_behavior::DockSide; +use craft_behavior::dock::{Column, DockEdge, Group, Node, SplitSize}; use craft_behavior::flow::Axis; -use egui::{Rect, accesskit::Role}; +use egui::{Rect, accesskit::Role, pos2, vec2}; use egui_kittest::kittest::Queryable; use serde_json::json; use soundcraft_ui_egui::docking::{self, CLIPS_WIDTH, MIDI_HEIGHT, Panel, TRACKS_WIDTH}; -use soundcraft_ui_egui::{MainWindow, Services, SoundApp, UiState}; +use soundcraft_ui_egui::{Services, SoundApp, UiState}; -use super::docking_workflows::{drag, harness}; +use super::docking_workflows::harness; fn tabs(panel: Panel) -> Node { - Node::Tabs { panels: vec![panel], active: 0 } + Node::tabs(vec![panel], 0) +} + +fn column(panels: Vec, active: usize, width: f32) -> Column { + Column::new(vec![Group::new(panels, active)]).with_width(width) } fn dock(side: DockEdge, panel: Panel, width: f32) -> Node { - Node::Dock { side, columns: vec![Column::new(vec![Group::new(vec![panel], 0)], width)] } + Node::dock(side, vec![column(vec![panel], 0, width)]) } -fn split(axis: Axis, size: SplitSize, first: Node, second: Node) -> Node { - Node::Split { axis, size, first: Box::new(first), second: Box::new(second) } +fn rect(x: f32, y: f32, width: f32, height: f32) -> Rect { + Rect::from_min_size(pos2(x, y), vec2(width, height)) } /// The columns of the dock on `side`. fn columns(node: &Node, side: DockEdge) -> Option<&Vec>> { match node { Node::Split { first, second, .. } => columns(first, side).or_else(|| columns(second, side)), - Node::Dock { side: found, columns } if *found == side => Some(columns), + Node::Dock { side: found, columns, .. } if *found == side => Some(columns), _ => None, } } fn dock_columns(h: &egui_kittest::Harness<'_, SoundApp>, side: DockEdge) -> Vec> { - h.state().ui.docking.layout.root.as_ref().and_then(|root| columns(root, side)).cloned().unwrap_or_default() + h.state().ui.docking.layout().root.as_ref().and_then(|root| columns(root, side)).cloned().unwrap_or_default() } #[test] fn default_layouts_put_the_side_lists_in_full_height_dock_columns() { let edit = docking::edit_default(); - let session = split(Axis::Y, SplitSize::FixedSecond(MIDI_HEIGHT + 26.0), tabs(Panel::Canvas), tabs(Panel::Midi)); - let expected = split( + let session = Node::split(Axis::Y, SplitSize::FixedSecond(MIDI_HEIGHT + 26.0), tabs(Panel::Canvas), tabs(Panel::Midi)); + let expected = Node::split( Axis::X, SplitSize::FixedFirst(TRACKS_WIDTH), dock(DockEdge::Start, Panel::Tracks, TRACKS_WIDTH), - split(Axis::X, SplitSize::FixedSecond(CLIPS_WIDTH), session, dock(DockEdge::End, Panel::Clips, CLIPS_WIDTH)), + Node::split(Axis::X, SplitSize::FixedSecond(CLIPS_WIDTH), session, dock(DockEdge::End, Panel::Clips, CLIPS_WIDTH)), ); - assert_eq!(edit.layout.root, Some(expected)); + assert_eq!(edit.layout().root, Some(expected)); assert_eq!((TRACKS_WIDTH, CLIPS_WIDTH, MIDI_HEIGHT), (168.0, 230.0, 320.0)); let mix = docking::mix_default(); assert_eq!( - mix.layout.root, - Some(split(Axis::X, SplitSize::FixedFirst(TRACKS_WIDTH), dock(DockEdge::Start, Panel::Tracks, TRACKS_WIDTH), tabs(Panel::Canvas))) + mix.layout().root, + Some(Node::split(Axis::X, SplitSize::FixedFirst(TRACKS_WIDTH), dock(DockEdge::Start, Panel::Tracks, TRACKS_WIDTH), tabs(Panel::Canvas))) ); for workspace in [&edit, &mix] { - let floating: Vec<_> = workspace.layout.floating.iter().map(|window| (window.panels().copied().collect::>(), window.rect)).collect(); - assert_eq!(floating, [(vec![Panel::Memory], [160.0, 120.0, 480.0, 280.0]), (vec![Panel::History], [680.0, 120.0, 260.0, 300.0])]); - assert!(workspace.hidden.is_empty()); + let floating: Vec<_> = + workspace.layout().floating.iter().map(|window| (window.panels().copied().collect::>(), window.rect)).collect(); + assert_eq!(floating, [(vec![Panel::Memory], rect(160.0, 120.0, 480.0, 280.0)), (vec![Panel::History], rect(680.0, 120.0, 260.0, 300.0))]); + assert!(workspace.hidden().is_empty()); } docking::validate(&edit).unwrap(); docking::validate_mix(&mix).unwrap(); @@ -72,54 +76,15 @@ fn default_layouts_put_the_side_lists_in_full_height_dock_columns() { let midi = h.ctx.data(|data| data.get_temp::(egui::Id::unique("soundcraft-midi-body"))).unwrap(); assert!(tracks.left() < TRACKS_WIDTH && clips.right() > width - CLIPS_WIDTH, "tracks {tracks:?}, clips {clips:?}"); assert!(midi.left() >= TRACKS_WIDTH && midi.right() <= width - CLIPS_WIDTH, "midi {midi:?}"); - assert!((midi.height() - MIDI_HEIGHT).abs() < 1.0 && midi.top() > clips.bottom(), "midi {midi:?}"); -} - -/// The Tracks group's body in the start dock: below its tab strip, down to the column's foot. -fn tracks_body(h: &egui_kittest::Harness<'_, SoundApp>) -> Rect { - let hits = DockArea::::hit_rects(&h.ctx, docking::area_id(MainWindow::Edit)); - let strip = hits - .iter() - .filter(|(hit, _)| matches!(hit, Hit::Tab(Panel::Tracks) | Hit::DragBar(Panel::Tracks))) - .fold(Rect::NOTHING, |all, (_, rect)| all.union(*rect)); - // The column's inner edge runs the column's full height. - let bottom = - hits.iter().find(|(hit, _)| *hit == Hit::Divider(Divider::Column(Panel::Tracks))).map_or(f32::NEG_INFINITY, |(_, rect)| rect.bottom()); - assert!(strip.is_positive() && bottom > strip.bottom() + 100.0, "strip {strip:?}, bottom {bottom}, hits {hits:?}"); - Rect::from_min_max(egui::pos2(strip.left(), strip.bottom()), egui::pos2(strip.right(), bottom)) -} - -#[test] -fn a_tab_dropped_on_a_dock_group_joins_it_in_the_middle_and_stacks_below_in_the_lower_third() { - let mut h = harness(None, 1400.0, 1.0); - let body = tracks_body(&h); - let clips = h.get_by_role_and_label(Role::Tab, "Clips").rect().center(); - drag(&mut h, clips, body.center()); - assert_eq!( - dock_columns(&h, DockEdge::Start), - [Column::new(vec![Group { active: 1, ..Group::new(vec![Panel::Tracks, Panel::Clips], 0) }], TRACKS_WIDTH)] - ); - assert!(dock_columns(&h, DockEdge::End).is_empty(), "the emptied end dock goes"); - - let mut h = harness(None, 1400.0, 1.0); - let body = tracks_body(&h); - let clips = h.get_by_role_and_label(Role::Tab, "Clips").rect().center(); - drag(&mut h, clips, egui::pos2(body.center().x, body.bottom() - body.height() / 6.0)); - let column = dock_columns(&h, DockEdge::Start); - let groups: Vec<_> = column.iter().flat_map(|column| column.groups.iter().map(|group| group.panels.clone())).collect(); - assert_eq!(groups, [vec![Panel::Tracks], vec![Panel::Clips]], "Clips stacks below Tracks in its column"); - assert_eq!(column.len(), 1); - assert!(h.state().ui.show_clip_list); - docking::validate(&h.state().ui.docking).unwrap(); + assert!(midi.height() > MIDI_HEIGHT / 2.0 && midi.top() > clips.bottom(), "midi {midi:?}"); } #[test] fn a_panel_without_a_recorded_place_reopens_at_its_default_place() { use craft_behavior::dock::{Action, DockPlacement, Permissions}; -use craft_ui::docking::{Zone}; let close = |state: &mut UiState, panel: Panel| { - state.docking.apply(Action::Close { panel }, |_| Permissions::default()).unwrap(); - state.docking.hidden.clear(); + state.docking.apply(Action::close(panel), false, |_| Permissions::default()).unwrap(); + state.docking.forget_hidden(|_| true); }; // Both docks gone: each list makes its dock again, at its default width. The MIDI editor // opens under the session view, and Memory Locations and Undo History float where they @@ -137,30 +102,20 @@ use craft_ui::docking::{Zone}; h.state_mut().run("ui.dock", json!({"operation":"open","panel":panel})).unwrap(); } h.run_steps(4); - assert_eq!(dock_columns(&h, DockEdge::Start), [Column::new(vec![Group::new(vec![Panel::Tracks], 0)], TRACKS_WIDTH)]); - assert_eq!(dock_columns(&h, DockEdge::End), [Column::new(vec![Group::new(vec![Panel::Clips], 0)], CLIPS_WIDTH)]); - let layout = &h.state().ui.docking.layout; + assert_eq!(dock_columns(&h, DockEdge::Start), [column(vec![Panel::Tracks], 0, TRACKS_WIDTH)]); + assert_eq!(dock_columns(&h, DockEdge::End), [column(vec![Panel::Clips], 0, CLIPS_WIDTH)]); + let layout = h.state().ui.docking.layout(); let midi = layout.location(&Panel::Midi).unwrap(); - assert_eq!((midi.anchor, midi.placement), (Some(Panel::Canvas), DockPlacement::Split(Zone::Bottom))); - let rect = |panel: Panel| layout.floating.iter().find(|window| window.contains(&panel)).map(|window| window.rect); - assert_eq!((rect(Panel::Memory), rect(Panel::History)), (Some([160.0, 120.0, 480.0, 280.0]), Some([680.0, 120.0, 260.0, 300.0]))); + assert_eq!((midi.anchor, midi.placement), (Some(Panel::Canvas), DockPlacement::Split(DockSide::Bottom))); + let floats = |panel: Panel| layout.floating.iter().find(|window| window.contains(&panel)).map(|window| window.rect); + assert_eq!((floats(Panel::Memory), floats(Panel::History)), (Some(rect(160.0, 120.0, 480.0, 280.0)), Some(rect(680.0, 120.0, 260.0, 300.0)))); let ui = &h.state().ui; assert!(ui.show_tracks_list && ui.show_clip_list && ui.show_midi_editor && ui.show_memory_locations && ui.show_undo_history); docking::validate(&h.state().ui.docking).unwrap(); // A dock that is still shown takes the list into its first group. let mut state = UiState::default(); - state - .docking - .apply( - Action::Move { - panel: Panel::History, - anchor: Panel::Tracks, - placement: craft_behavior::dock::DockPlacement::Group { below: true, height: None }, - }, - |_| Permissions::default(), - ) - .unwrap(); + state.docking.apply(Action::move_beside(Panel::History, Panel::Tracks, DockPlacement::group(true, None)), false, |_| Permissions::default()).unwrap(); close(&mut state, Panel::Tracks); state.show_tracks_list = false; state.show_undo_history = true; @@ -169,7 +124,7 @@ use craft_ui::docking::{Zone}; h.run_steps(4); let groups: Vec<_> = dock_columns(&h, DockEdge::Start).iter().flat_map(|column| column.groups.iter().map(|group| group.panels.clone())).collect(); assert_eq!(groups, [vec![Panel::History, Panel::Tracks]]); - assert_eq!(h.state().ui.docking.layout.panel_state(&Panel::Tracks), craft_behavior::dock::PanelState::Front); + assert_eq!(h.state().ui.docking.layout().panel_state(&Panel::Tracks), craft_behavior::dock::PanelState::Front); } /// A hidden list or editor whose recorded anchor has disappeared reopens at its default place @@ -177,32 +132,32 @@ use craft_ui::docking::{Zone}; #[test] fn a_recorded_place_whose_anchor_is_gone_reopens_at_its_default_place() { use craft_behavior::dock::{Action, DockPlacement, Permissions}; -use craft_ui::docking::{Zone}; let allow = |_: &Panel| Permissions::default(); let mut state = UiState::default(); // Stale saved locations: their recorded anchor closed without leaving a place to follow. for panel in [Panel::Clips, Panel::Midi, Panel::Tracks] { - state.docking.apply(Action::Close { panel }, allow).unwrap(); + state.docking.apply(Action::close(panel), false, allow).unwrap(); } - state.docking.hidden.retain(|(panel, _)| *panel != Panel::Tracks); - for (_, location) in state.docking.hidden.iter_mut().filter(|(panel, _)| matches!(panel, Panel::Clips | Panel::Midi)) { + let mut hidden: Vec<_> = state.docking.hidden().iter().filter(|(panel, _)| *panel != Panel::Tracks).cloned().collect(); + for (_, location) in hidden.iter_mut().filter(|(panel, _)| matches!(panel, Panel::Clips | Panel::Midi)) { location.anchor = Some(Panel::Tracks); - location.placement = DockPlacement::Split(Zone::Left); + location.placement = DockPlacement::Split(DockSide::Start); location.sibling.clear(); location.floating = None; } + state.docking = docking::Workspace::from_parts(state.docking.layout().clone(), hidden, state.docking.floated().to_vec()); docking::validate(&state.docking).unwrap(); state.show_clip_list = false; state.show_midi_editor = false; state.show_tracks_list = false; let mut h = harness(Some(state), 1400.0, 1.0); - assert!(!h.state().ui.docking.layout.contains(&Panel::Tracks), "app sync keeps the stale anchor absent"); + assert!(!h.state().ui.docking.layout().contains(&Panel::Tracks), "app sync keeps the stale anchor absent"); h.state_mut().run("ui.dock", json!({"operation":"open","panel":"clips"})).unwrap(); h.state_mut().run("ui.dock", json!({"operation":"open","panel":"midi"})).unwrap(); h.run_steps(4); - assert_eq!(dock_columns(&h, DockEdge::End), [Column::new(vec![Group::new(vec![Panel::Clips], 0)], CLIPS_WIDTH)]); - let midi = h.state().ui.docking.layout.location(&Panel::Midi).unwrap(); - assert_eq!((midi.anchor, midi.placement), (Some(Panel::Canvas), DockPlacement::Split(Zone::Bottom))); + assert_eq!(dock_columns(&h, DockEdge::End), [column(vec![Panel::Clips], 0, CLIPS_WIDTH)]); + let midi = h.state().ui.docking.layout().location(&Panel::Midi).unwrap(); + assert_eq!((midi.anchor, midi.placement), (Some(Panel::Canvas), DockPlacement::Split(DockSide::Bottom))); assert!(h.state().ui.show_clip_list && h.state().ui.show_midi_editor); docking::validate(&h.state().ui.docking).unwrap(); } @@ -244,7 +199,7 @@ fn split_frame_settings() -> serde_json::Value { fn split_frame_settings_load_as_the_dock_defaults_and_dock_layouts_round_trip() { let mut settings = split_frame_settings(); // The old layout still parses: the reset is what replaces it. - assert!(serde_json::from_value::(settings.clone()).unwrap().docking.layout.contains(&Panel::Clips)); + assert!(serde_json::from_value::(settings.clone()).unwrap().docking.layout().contains(&Panel::Clips)); docking::reset_old_layouts(&mut settings); let state: UiState = serde_json::from_value(settings).unwrap(); assert_eq!(state.docking, docking::edit_default()); @@ -274,7 +229,7 @@ fn split_frame_settings_load_as_the_dock_defaults_and_dock_layouts_round_trip() let loaded: UiState = serde_json::from_value(value).unwrap(); assert_eq!(loaded.docking, saved.docking); assert_eq!(loaded.mix_docking, saved.mix_docking); - let groups: Vec<_> = columns(loaded.docking.layout.root.as_ref().unwrap(), DockEdge::Start) + let groups: Vec<_> = columns(loaded.docking.layout().root.as_ref().unwrap(), DockEdge::Start) .unwrap() .iter() .flat_map(|column| column.groups.iter().map(|group| group.panels.clone())) @@ -291,11 +246,11 @@ fn a_floating_list_closed_beside_its_shown_dock_reopens_floating() { h.state_mut().run("ui.dock", json!({"operation":"move","panel":"tracks","target":"clips","zone":"center"})).unwrap(); h.state_mut().run("ui.dock", json!({"operation":"float","panel":"clips","rect":[300,200,260,320]})).unwrap(); h.run_steps(4); - let rect = h.state().ui.docking.layout.floating.iter().find(|w| w.contains(&Panel::Clips)).unwrap().rect; + let floated = h.state().ui.docking.layout().floating.iter().find(|w| w.contains(&Panel::Clips)).unwrap().rect; assert!(dock_columns(&h, DockEdge::End).iter().any(|c| c.groups.iter().any(|g| g.panels.contains(&Panel::Tracks)))); h.state_mut().run("ui.dock", json!({"operation":"close","panel":"clips"})).unwrap(); h.run_steps(4); h.state_mut().run("ui.dock", json!({"operation":"open","panel":"clips"})).unwrap(); h.run_steps(4); - assert_eq!(h.state().ui.docking.layout.floating.iter().find(|w| w.contains(&Panel::Clips)).map(|w| w.rect), Some(rect)); + assert_eq!(h.state().ui.docking.layout().floating.iter().find(|w| w.contains(&Panel::Clips)).map(|w| w.rect), Some(floated)); } diff --git a/crates/ui-egui/tests/it/docking_workflows.rs b/crates/ui-egui/tests/it/docking_workflows.rs index c425f8a51..764f24ddb 100644 --- a/crates/ui-egui/tests/it/docking_workflows.rs +++ b/crates/ui-egui/tests/it/docking_workflows.rs @@ -1,5 +1,5 @@ //! Real Edit/Mix panel workflows, persistence, and command ownership without OS windows. -use egui::{Event, Modifiers, PointerButton, vec2}; +use egui::{Rect, pos2, vec2}; use egui_kittest::{Harness, kittest::Queryable}; use serde_json::json; use soundcraft_ui_egui::{MainWindow, Services, SoundApp, UiState, docking::Panel}; @@ -10,7 +10,11 @@ pub(crate) fn harness(state: Option, width: f32, scale: f32) -> Harness if let Some(state) = state { app.ui = state; } - let mut h = Harness::builder().with_size(vec2(width, 900.0)).with_pixels_per_point(scale).build_ui_state( + let mut h = Harness::builder() + .with_size(vec2(width, 900.0)) + .with_pixels_per_point(scale) + .with_context_setup(soundcraft_ui_egui::framework::install_headless) + .build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); @@ -21,58 +25,33 @@ pub(crate) fn harness(state: Option, width: f32, scale: f32) -> Harness h } -pub(crate) fn drag(h: &mut Harness<'_, SoundApp>, from: egui::Pos2, to: egui::Pos2) { - h.event(Event::PointerMoved(from)); - h.run_steps(2); - h.event(Event::PointerButton { pos: from, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); - h.run_steps(2); - for step in 1..=8 { - h.event(Event::PointerMoved(from.lerp(to, step as f32 / 8.0))); - h.run_steps(1); - } - h.event(Event::PointerButton { pos: to, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE }); - h.run_steps(4); -} - -/// A real panel drag, float, close and reopen keeps the recorded floating rectangle through a UI-state reload; +/// A panel moved, floated, closed and reopened keeps its recorded floating rectangle through a UI-state reload; /// the Trim tool and record-arm controls still work, and a floating edit panel does not cover the mix strip used /// after switching windows. #[test] -fn real_drag_float_close_reopen_reload_retains_transport_and_mixer_commands() { +fn move_float_close_reopen_reload_retains_transport_and_mixer_commands() { let mut h = harness(None, 1400.0, 1.0); - let source = h.get_by_role_and_label(egui::accesskit::Role::Tab, "Clips").rect().center(); - let target = h.get_by_role_and_label(egui::accesskit::Role::Tab, "Tracks and Groups").rect().center(); - drag(&mut h, source, target); - assert_eq!(h.state().ui.docking.layout.location(&Panel::Clips).unwrap().anchor, Some(Panel::Tracks)); - h.get_by_role_and_label(egui::accesskit::Role::Tab, "Clips").click_button(PointerButton::Secondary); + h.state_mut().run("ui.dock", json!({"operation":"move","panel":"clips","target":"tracks","zone":"tab"})).unwrap(); h.run_steps(3); - h.get_by_label("Float Panel").click(); + assert_eq!(h.state().ui.docking.layout().location(&Panel::Clips).unwrap().anchor, Some(Panel::Tracks)); + h.state_mut().run("ui.dock", json!({"operation":"float","panel":"clips","rect":[400,150,260,320]})).unwrap(); h.run_steps(5); - let rect = h.state().ui.docking.layout.floating.iter().find(|g| g.contains(&Panel::Clips)).unwrap().rect; - h.get_by_role_and_label(egui::accesskit::Role::Tab, "Clips").click_button(PointerButton::Secondary); - h.run_steps(3); - h.get_by_label("Close Panel").click(); + let rect = h.state().ui.docking.layout().floating.iter().find(|g| g.contains(&Panel::Clips)).unwrap().rect; + h.state_mut().run("ui.dock", json!({"operation":"close","panel":"clips"})).unwrap(); h.run_steps(4); assert!(!h.state().ui.show_clip_list); h.state_mut().run("ui.dock", json!({"operation":"open","panel":"clips"})).unwrap(); h.run_steps(4); - assert_eq!(h.state().ui.docking.layout.floating.iter().find(|g| g.contains(&Panel::Clips)).unwrap().rect, rect); + assert_eq!(h.state().ui.docking.layout().floating.iter().find(|g| g.contains(&Panel::Clips)).unwrap().rect, rect); let saved = serde_json::to_string(&h.state().ui).unwrap(); let expected = serde_json::to_value(&h.state().ui.docking).unwrap(); let mut reloaded = harness(Some(serde_json::from_str(&saved).unwrap()), 1400.0, 1.0); assert_eq!(serde_json::to_value(&reloaded.state().ui.docking).unwrap(), expected); reloaded.state_mut().run("ui.dock", json!({"operation":"move","panel":"clips","target":"tracks","zone":"center"})).unwrap(); reloaded.run_steps(4); - // A Tracks column too narrow for both tabs lists Tracks under the "Panels" overflow. - if let Some(overflow) = reloaded.query_by_label("Panels") { - overflow.click(); - reloaded.run_steps(3); - reloaded.get_by_label("Tracks and Groups").click(); - } else { - reloaded.get_by_role_and_label(egui::accesskit::Role::Tab, "Tracks and Groups").click(); - } + reloaded.state_mut().run("ui.dock", json!({"operation":"activate","panel":"tracks"})).unwrap(); reloaded.run_steps(3); - assert_eq!(reloaded.state().ui.docking.layout.panel_state(&Panel::Tracks), craft_behavior::dock::PanelState::Front); + assert_eq!(reloaded.state().ui.docking.layout().panel_state(&Panel::Tracks), craft_behavior::dock::PanelState::Front); reloaded.get_by_label("Trim (F6)").click(); reloaded.run_steps(3); assert_eq!(reloaded.state().engine.session().edit.tool, soundcraft_model::Tool::Trim); @@ -83,10 +62,10 @@ fn real_drag_float_close_reopen_reload_retains_transport_and_mixer_commands() { reloaded.state_mut().run("ui.dock", json!({"operation":"float","panel":"tracks","rect":[900,70,220,420]})).unwrap(); reloaded.run_steps(4); assert_eq!(serde_json::to_value(&reloaded.state().ui.docking).unwrap(), edit); - assert!(!reloaded.state().ui.mix_docking.layout.contains(&Panel::Clips)); + assert!(!reloaded.state().ui.mix_docking.layout().contains(&Panel::Clips)); let record = reloaded.get_by_label_contains("Record enable"); // A real pointer click must remain outside the floating panel's occluding rectangle. - assert!(!egui::Rect::from_min_size(egui::pos2(900.0, 70.0), vec2(220.0, 420.0)).contains(record.rect().center())); + assert!(!Rect::from_min_size(pos2(900.0, 70.0), vec2(220.0, 420.0)).contains(record.rect().center())); record.click(); reloaded.run_steps(3); assert!(reloaded.state().engine.session().tracks[0].mixer.record_arm); @@ -102,7 +81,7 @@ fn activating_a_hidden_panel_shows_it_and_its_window_flag() { h.state_mut().run("ui.dock", json!({"operation":"activate","panel":"tracks"})).unwrap(); h.run_steps(4); assert!(h.state().ui.show_tracks_list); - assert_eq!(h.state().ui.docking.layout.panel_state(&Panel::Tracks), craft_behavior::dock::PanelState::Front); + assert_eq!(h.state().ui.docking.layout().panel_state(&Panel::Tracks), craft_behavior::dock::PanelState::Front); } #[test] @@ -166,7 +145,7 @@ fn reset_is_enabled_and_resolves_in_native_and_in_window_menu_trees() { assert!(menus::item_state(&app, path, Some("ui.dock.reset")).0); app.run("ui.dock", json!({"operation":"float","panel":"tracks","rect":[50,60,260,420]})).unwrap(); menus::invoke_menu(&mut app, "ui.dock.reset", path); - assert!(!app.ui.docking.layout.floating.iter().any(|group| group.contains(&Panel::Tracks))); + assert!(!app.ui.docking.layout().floating.iter().any(|group| group.contains(&Panel::Tracks))); } #[test] @@ -181,61 +160,31 @@ fn legacy_preferences_restore_the_theme_and_validate_default_docking() { soundcraft_ui_egui::docking::validate_mix(&restored.mix_docking).unwrap(); } -/// The tab group holding `panel` in the docked frames or a dock column. -fn docked_group(node: &craft_behavior::dock::Node, panel: Panel) -> Option> { - use craft_behavior::dock::Node; - match node { - Node::Split { first, second, .. } => docked_group(first, panel).or_else(|| docked_group(second, panel)), - Node::Tabs { panels, .. } if panels.contains(&panel) => Some(panels.clone()), - Node::Dock { columns, .. } => { - columns.iter().flat_map(|column| &column.groups).find(|group| group.panels.contains(&panel)).map(|group| group.panels.clone()) - } - _ => None, - } -} - +/// A floating window saved as one `{panels, active, rect}` group, as releases before the shared docking model wrote +/// it, loads as one window and keeps its panels, active tab and place when written back and read again. #[test] -fn a_floating_window_saved_in_the_one_group_shape_keeps_it_when_written_back() { - use craft_behavior::dock::Node; - // A floating window as one `{panels, active, rect}` group, as releases before the shared - // docking model wrote it, beside the dock layout. +fn a_floating_window_saved_in_the_one_group_shape_round_trips() { let mut settings = serde_json::to_value(UiState { show_midi_editor: true, ..Default::default() }).unwrap(); settings["docking"]["layout"]["floating"] = json!([{"panels": ["memory", "history"], "active": 1, "rect": [300.0, 120.0, 420.0, 360.0]}]); let state: UiState = serde_json::from_value(settings).unwrap(); soundcraft_ui_egui::docking::validate(&state.docking).unwrap(); - let floating = &state.docking.layout.floating; + let floating = &state.docking.layout().floating; assert_eq!(floating.len(), 1); - assert_eq!(floating[0].root, Node::Tabs { panels: vec![Panel::Memory, Panel::History], active: 1 }); - let root = state.docking.layout.root.clone().unwrap(); + let groups = floating[0].groups(); + assert_eq!(groups.len(), 1); + assert_eq!((groups[0].panels.clone(), groups[0].active), (vec![Panel::Memory, Panel::History], 1)); + let root = state.docking.layout().root.clone().unwrap(); let mut state = state; state.show_memory_locations = true; state.show_undo_history = true; let h = harness(Some(state), 1400.0, 1.0); - assert_eq!(h.state().ui.docking.layout.root.as_ref(), Some(&root), "drawing the loaded layout must not rearrange it"); - assert_eq!(h.state().ui.docking.layout.floating[0].rect, [300.0, 120.0, 420.0, 360.0]); - let saved = serde_json::to_value(&h.state().ui.docking).unwrap(); - let window = saved["layout"]["floating"].as_array().unwrap().iter().find(|w| w["panels"] == json!(["memory", "history"])).unwrap(); - assert_eq!(window["active"], json!(1)); - assert_eq!(window["rect"], json!([300.0, 120.0, 420.0, 360.0])); -} - -#[test] -fn dragging_a_group_by_its_drag_bar_joins_it_to_another_group() { - use craft_ui::docking::{DockArea, Hit}; - let mut h = harness(None, 1400.0, 1.0); - let root = h.state().ui.docking.layout.root.clone().unwrap(); - assert_eq!(docked_group(&root, Panel::Tracks), Some(vec![Panel::Tracks])); - let hits = DockArea::::hit_rects(&h.ctx, soundcraft_ui_egui::docking::area_id(MainWindow::Edit)); - let bar = hits.iter().find(|(hit, _)| *hit == Hit::DragBar(Panel::Clips)).expect("the Clips group has a drag bar").1; - let target = h.get_by_role_and_label(egui::accesskit::Role::Tab, "Tracks and Groups").rect().center(); - drag(&mut h, bar.center(), target); - let layout = &h.state().ui.docking.layout; - let group = docked_group(layout.root.as_ref().unwrap(), Panel::Tracks).unwrap(); - assert_eq!(group.len(), 2, "the dropped group joins the Tracks tabs: {group:?}"); - assert!(group.contains(&Panel::Clips)); - assert!(h.state().ui.show_clip_list); - soundcraft_ui_egui::docking::validate(&h.state().ui.docking).unwrap(); + assert_eq!(h.state().ui.docking.layout().root.as_ref(), Some(&root), "drawing the loaded layout must not rearrange it"); + let reread: UiState = serde_json::from_value(serde_json::to_value(&h.state().ui).unwrap()).unwrap(); + let window = reread.docking.layout().floating.iter().find(|window| window.contains(&Panel::Memory)).unwrap(); + assert!(window.contains(&Panel::History)); + assert_eq!(window.groups()[0].active, 1); + assert_eq!(window.rect, Rect::from_min_size(pos2(300.0, 120.0), vec2(420.0, 360.0))); } #[test] @@ -257,31 +206,35 @@ fn malformed_dock_operations_name_the_field() { /// process. #[test] fn panels_hidden_one_by_one_reopen_into_their_recorded_window() { - use craft_behavior::dock::{Action, Node, Permissions}; + use craft_behavior::dock::{Action, Floating, Permissions}; let allow = |_: &Panel| Permissions::default(); let mut state = UiState::default(); - state.docking.layout.floating.retain(|window| !window.contains(&Panel::History)); - let window = state.docking.layout.floating.iter_mut().find(|window| window.contains(&Panel::Memory)).unwrap(); + let mut layout = state.docking.layout().clone(); + layout.floating.retain(|window| !window.contains(&Panel::History)); + let window = layout.floating.iter_mut().find(|window| window.contains(&Panel::Memory)).unwrap(); let rect = window.rect; - window.root = Node::Tabs { panels: vec![Panel::Memory, Panel::History], active: 0 }; - state.docking.apply(Action::Close { panel: Panel::Memory }, allow).unwrap(); - state.docking.apply(Action::Close { panel: Panel::History }, allow).unwrap(); - let own = &mut state.docking.hidden.iter_mut().find(|(panel, _)| *panel == Panel::Memory).unwrap().1; + *window = Floating::single(window.id, vec![Panel::Memory, Panel::History], 0, rect); + state.docking = soundcraft_ui_egui::docking::Workspace::new(layout); + state.docking.apply(Action::close(Panel::Memory), false, allow).unwrap(); + state.docking.apply(Action::close(Panel::History), false, allow).unwrap(); + let mut hidden = state.docking.hidden().to_vec(); + let own = &mut hidden.iter_mut().find(|(panel, _)| *panel == Panel::Memory).unwrap().1; assert_eq!(own.anchor, Some(Panel::History)); // Only the outer hidden anchor retains a floating fallback, so the chain walk is required. own.floating = None; let own = own.clone(); - assert_eq!(state.docking.layout.clone().restore(Panel::Memory, &own), Err(craft_behavior::dock::DockError::MissingTarget)); + state.docking = soundcraft_ui_egui::docking::Workspace::from_parts(state.docking.layout().clone(), hidden, state.docking.floated().to_vec()); + assert_eq!(state.docking.layout().clone().restore(Panel::Memory, &own), Err(craft_behavior::dock::DockError::MissingTarget)); state.show_memory_locations = false; state.show_undo_history = false; let mut h = harness(Some(state), 1400.0, 1.0); h.state_mut().run("ui.dock", json!({"operation":"open","panel":"memory"})).unwrap(); h.run_steps(4); - let hidden_history = &h.state().ui.docking.hidden.iter().find(|(panel, _)| *panel == Panel::History).unwrap().1; + let hidden_history = &h.state().ui.docking.hidden().iter().find(|(panel, _)| *panel == Panel::History).unwrap().1; assert_eq!(hidden_history.anchor, Some(Panel::Memory), "the restored chain reverses its hidden neighbour's anchor"); h.state_mut().run("ui.dock", json!({"operation":"open","panel":"history"})).unwrap(); h.run_steps(4); - let layout = &h.state().ui.docking.layout; + let layout = h.state().ui.docking.layout(); let window = layout.floating.iter().find(|window| window.contains(&Panel::Memory)).expect("Memory reopens in its window"); assert!(window.contains(&Panel::History), "the hidden chain reopens History in Memory's window: {window:?}"); assert_eq!(window.rect, rect); diff --git a/crates/ui-egui/tests/it/edit_modes.rs b/crates/ui-egui/tests/it/edit_modes.rs index 030959055..8f64f97fc 100644 --- a/crates/ui-egui/tests/it/edit_modes.rs +++ b/crates/ui-egui/tests/it/edit_modes.rs @@ -68,6 +68,7 @@ fn tracks(mode: &str, tool: &str, lanes: &[&[(i64, i64)]]) -> (SoundApp, egui::C e.execute("view.zoom_set", &json!({"samples_per_px": 400.0})).unwrap(); let mut app = SoundApp::new(e, None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); frame(&ctx, &mut app, vec![]); frame(&ctx, &mut app, vec![]); (app, ctx, tracks, ids) @@ -251,7 +252,7 @@ fn toolbar_clicks_add_snap_to_grid_lock_shuffle_and_switch_grid_modes_despite_th let mut e = Engine::default(); e.execute("edit.mode", &json!({"mode": "slip"})).unwrap(); let app = SoundApp::new(e, None, Services::default()); - let mut h = egui_kittest::Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = egui_kittest::Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/edit_window_headers.rs b/crates/ui-egui/tests/it/edit_window_headers.rs index e1f73546f..4985b910c 100644 --- a/crates/ui-egui/tests/it/edit_window_headers.rs +++ b/crates/ui-egui/tests/it/edit_window_headers.rs @@ -52,7 +52,7 @@ fn harness(track: &str, height: &str, view: &str) -> (Harness<'static, SoundApp> app.run(view, json!({})).unwrap(); app.run("track.height", json!({"tracks": [track], "height": height})).unwrap(); let id = app.engine.session().track_by_name(track).unwrap().id; - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/focused_dialog_buttons.rs b/crates/ui-egui/tests/it/focused_dialog_buttons.rs index bff4ffb19..4450ae6d9 100644 --- a/crates/ui-egui/tests/it/focused_dialog_buttons.rs +++ b/crates/ui-egui/tests/it/focused_dialog_buttons.rs @@ -14,7 +14,7 @@ use soundcraft_ui_egui::dialogs::{Dialog, ask_to_save}; use soundcraft_ui_egui::{Services, SoundApp, menus}; fn harness(app: SoundApp) -> Harness<'static, SoundApp> { - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); @@ -150,6 +150,7 @@ fn a_dialog_opened_while_a_window_button_has_the_focus_takes_enter() { fn the_enter_that_opens_a_dialog_does_not_press_its_default_button() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); run_frame(&ctx, &mut app, vec![]); menus::invoke_menu(&mut app, "edit.fades_create", "Edit > Fades > Create..."); run_frame(&ctx, &mut app, vec![enter_key(false), enter_up()]); @@ -181,6 +182,7 @@ fn enter_up() -> Event { fn the_enter_that_replaces_an_open_dialog_does_not_press_the_new_default_button() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); menus::invoke_menu(&mut app, "setup.session", "Setup > Session"); run_frame(&ctx, &mut app, vec![]); run_frame(&ctx, &mut app, vec![]); @@ -196,6 +198,7 @@ fn the_enter_that_replaces_an_open_dialog_does_not_press_the_new_default_button( fn a_rename_dialog_that_replaces_an_open_dialog_ignores_the_enter_of_its_first_frame() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); menus::invoke_menu(&mut app, "setup.session", "Setup > Session"); run_frame(&ctx, &mut app, vec![]); run_frame(&ctx, &mut app, vec![]); @@ -236,6 +239,7 @@ fn clear_auto_rename_modify_group_and_save_changes_replacing_a_dialog_ignore_the for (name, open) in cases { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); menus::invoke_menu(&mut app, "setup.session", "Setup > Session"); run_frame(&ctx, &mut app, vec![]); run_frame(&ctx, &mut app, vec![]); @@ -249,6 +253,7 @@ fn clear_auto_rename_modify_group_and_save_changes_replacing_a_dialog_ignore_the fn a_tempo_change_dialog_that_replaces_an_open_dialog_ignores_the_enter_of_its_first_frame() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); menus::invoke_menu(&mut app, "setup.session", "Setup > Session"); run_frame(&ctx, &mut app, vec![]); let shapes = run_frame(&ctx, &mut app, vec![]); @@ -274,6 +279,7 @@ fn a_tempo_change_dialog_that_replaces_an_open_dialog_ignores_the_enter_of_its_f fn a_held_enter_does_not_press_the_default_button_until_it_is_pressed_again() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); run_frame(&ctx, &mut app, vec![]); menus::invoke_menu(&mut app, "edit.fades_create", "Edit > Fades > Create..."); run_frame(&ctx, &mut app, vec![enter_key(false)]); diff --git a/crates/ui-egui/tests/it/group_dialog.rs b/crates/ui-egui/tests/it/group_dialog.rs index bd17ede93..d69d6557a 100644 --- a/crates/ui-egui/tests/it/group_dialog.rs +++ b/crates/ui-egui/tests/it/group_dialog.rs @@ -18,7 +18,7 @@ fn dragging_down_the_group_dialogs_track_list_adds_each_track() { assert!(tracks.len() >= 4); app.run("edit.select", json!({"tracks": [tracks[0].0], "exact": true})).unwrap(); menus::invoke_menu(&mut app, "track.group", "Track > Group..."); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); @@ -61,7 +61,7 @@ fn modify_group_dialog_edits_the_existing_group() { assert_eq!((id.map(|i| i.0), name.as_str(), *edit, *mix), (Some(g), "Drums", true, true)); assert_eq!(members.iter().filter(|m| m.2).map(|m| m.0).collect::>(), vec![tracks[0].0]); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/idle.rs b/crates/ui-egui/tests/it/idle.rs index fcdc6f43a..0cc84bdf7 100644 --- a/crates/ui-egui/tests/it/idle.rs +++ b/crates/ui-egui/tests/it/idle.rs @@ -15,6 +15,7 @@ fn pass(ctx: &egui::Context, app: &mut SoundApp, shown: bool) -> Duration { #[test] fn only_a_shown_window_animates_and_a_hidden_one_wakes_once_a_second() { let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); for _ in 0..3 { pass(&ctx, &mut app, true); diff --git a/crates/ui-egui/tests/it/import_browse.rs b/crates/ui-egui/tests/it/import_browse.rs index 03299b7c5..a57854b7c 100644 --- a/crates/ui-egui/tests/it/import_browse.rs +++ b/crates/ui-egui/tests/it/import_browse.rs @@ -11,7 +11,7 @@ fn browse(picked: Vec) -> Harness<'static, SoundApp> { }); let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services { pick_open_many: Some(pick_open_many), ..Default::default() }); assert!(app.dialogs.open_for_command(&app.engine, "file.import_audio")); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/long_menu_scroll.rs b/crates/ui-egui/tests/it/long_menu_scroll.rs index 48aaf32d6..8722e46e9 100644 --- a/crates/ui-egui/tests/it/long_menu_scroll.rs +++ b/crates/ui-egui/tests/it/long_menu_scroll.rs @@ -18,7 +18,7 @@ fn step(h: &mut Harness<'_, SoundApp>) { #[test] fn a_long_main_menu_scrolls_to_its_last_item() { let app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); - let mut h = Harness::builder().with_size(SIZE).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(SIZE).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/marker_rename.rs b/crates/ui-egui/tests/it/marker_rename.rs index 10ec422ad..16f9b020a 100644 --- a/crates/ui-egui/tests/it/marker_rename.rs +++ b/crates/ui-egui/tests/it/marker_rename.rs @@ -16,6 +16,7 @@ impl Rig { engine.execute("track.new", &json!({})).unwrap(); engine.execute("markers.add", &json!({"name": "Verse", "at": 96_000})).unwrap(); let mut r = Rig { ctx: egui::Context::default(), app: SoundApp::new(engine, None, Services::default()), shapes: Vec::new() }; + soundcraft_ui_egui::framework::install_headless(&r.ctx); r.frames(4); r } diff --git a/crates/ui-egui/tests/it/menu_search.rs b/crates/ui-egui/tests/it/menu_search.rs index 854b69efd..738370ec4 100644 --- a/crates/ui-egui/tests/it/menu_search.rs +++ b/crates/ui-egui/tests/it/menu_search.rs @@ -12,7 +12,7 @@ use soundcraft_ui_egui::{MainWindow, Services, SoundApp}; fn harness(engine: soundcraft_engine::Engine) -> Harness<'static, SoundApp> { let mut app = SoundApp::new(engine, None, Services::default()); app.ui.window = MainWindow::Mix; - let mut h = Harness::builder().with_size(vec2(1400.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/midi_double_click.rs b/crates/ui-egui/tests/it/midi_double_click.rs index 7ed631761..ad51f1840 100644 --- a/crates/ui-egui/tests/it/midi_double_click.rs +++ b/crates/ui-egui/tests/it/midi_double_click.rs @@ -15,6 +15,7 @@ impl Rig { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); app.engine.execute("edit.tool", &json!({"tool": tool})).unwrap(); let mut r = Rig { ctx: egui::Context::default(), app }; + soundcraft_ui_egui::framework::install_headless(&r.ctx); for _ in 0..4 { r.frame(vec![]); } diff --git a/crates/ui-egui/tests/it/midi_editor_keys.rs b/crates/ui-egui/tests/it/midi_editor_keys.rs index 78906d0e5..27c26a486 100644 --- a/crates/ui-egui/tests/it/midi_editor_keys.rs +++ b/crates/ui-egui/tests/it/midi_editor_keys.rs @@ -13,7 +13,7 @@ fn harness(rename: bool) -> Harness<'static, SoundApp> { if rename { app.dialogs.open_rename_track(keys, "Keys"); } - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/midi_inputs.rs b/crates/ui-egui/tests/it/midi_inputs.rs index 984bef7a2..d2688c665 100644 --- a/crates/ui-egui/tests/it/midi_inputs.rs +++ b/crates/ui-egui/tests/it/midi_inputs.rs @@ -20,7 +20,7 @@ fn harness(disabled: &[&str]) -> Harness<'static, SoundApp> { app.midi_inputs = Some(MidiInputs::with_port_names(names(disabled), names(&["Keys", "Drum Pad"]))); app.ui.midi_inputs_off = names(disabled); app.ui.show_playback_engine = true; - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/midi_panel.rs b/crates/ui-egui/tests/it/midi_panel.rs index 7fbb61d8f..aedae06ac 100644 --- a/crates/ui-egui/tests/it/midi_panel.rs +++ b/crates/ui-egui/tests/it/midi_panel.rs @@ -21,137 +21,6 @@ fn button(pos: Pos2, pressed: bool) -> Event { Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Default::default() } } -fn check_resize(with_clip: bool) { - let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); - app.ui.show_midi_editor = true; - if with_clip { - app.run("edit.select", json!({"tracks": ["Keys"]})).unwrap(); - } - assert_eq!(midi_editor::target_clip(&app).is_some(), with_clip); - let ctx = egui::Context::default(); - for _ in 0..6 { - frame(&ctx, &mut app, vec![]); - } - let initial = panel(&ctx); - assert!((initial.height() - 320.0).abs() < 1.0, "initial panel: {initial:?}"); - let notes = app.engine.session().clone(); - - // Drag the shared boundary up and down, then allow several idle frames - // to catch a panel that looks resized but snaps back after release. - for height in [440.0, 280.0, 200.0] { - let before = panel(&ctx); - let start = pos2(before.center().x, before.top() - 26.0 - 2.0); - let end = pos2(start.x, before.bottom() - height - 26.0 - 2.0); - frame(&ctx, &mut app, vec![Event::PointerMoved(start)]); - frame(&ctx, &mut app, vec![button(start, true)]); - for step in 1..=6 { - frame(&ctx, &mut app, vec![Event::PointerMoved(start.lerp(end, step as f32 / 6.0))]); - } - frame(&ctx, &mut app, vec![button(end, false)]); - for _ in 0..4 { - frame(&ctx, &mut app, vec![]); - } - let after = panel(&ctx); - assert!((after.height() - height.max(260.0)).abs() < 1.0, "requested {height}, panel: {after:?}"); - assert!((after.bottom() - initial.bottom()).abs() < 1.0); - assert!(app.edit_layout.timeline[3] <= after.top()); - } - - // Closing and reopening the dock keeps the chosen height. - let resized = panel(&ctx); - app.run("window.midi_editor", json!({})).unwrap(); - frame(&ctx, &mut app, vec![]); - app.run("window.midi_editor", json!({})).unwrap(); - for _ in 0..4 { - frame(&ctx, &mut app, vec![]); - } - assert_eq!(panel(&ctx), resized); - let saved = serde_json::to_string(&app.ui).unwrap(); - app.ui = serde_json::from_str(&saved).unwrap(); - for _ in 0..4 { - frame(&ctx, &mut app, vec![]); - } - assert_eq!(panel(&ctx), resized); - assert_eq!(*app.engine.session(), notes); -} - -#[test] -fn midi_panel_resizes_with_a_selected_clip() { - check_resize(true); -} - -#[test] -fn midi_panel_resizes_without_a_selected_clip() { - check_resize(false); -} - -#[test] -fn layout_reset_cancels_a_held_midi_divider_without_editing_the_session() { - check_held_replacement("reset"); -} - -#[test] -fn arrange_cancels_a_held_midi_divider_without_editing_the_session() { - check_held_replacement("arrange"); -} - -#[test] -fn legacy_visibility_sync_cancels_a_held_midi_divider_without_editing_the_session() { - check_held_replacement("visibility"); -} - -fn check_held_replacement(operation: &str) { - let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); - app.ui.show_midi_editor = true; - app.run("edit.select", json!({"tracks":["Keys"]})).unwrap(); - app.ui.show_memory_locations = operation == "arrange"; - let session = app.engine.session().clone(); - let ctx = egui::Context::default(); - for _ in 0..6 { - frame(&ctx, &mut app, vec![]); - } - let initial = panel(&ctx); - let start = pos2(initial.center().x, initial.top() - 28.0); - frame(&ctx, &mut app, vec![Event::PointerMoved(start)]); - frame(&ctx, &mut app, vec![button(start, true)]); - let first = start - vec2(0.0, 80.0); - frame(&ctx, &mut app, vec![Event::PointerMoved(first)]); - frame(&ctx, &mut app, vec![]); - assert!((panel(&ctx).height() - 400.0).abs() < 1.0, "first drag must resize"); - let second = start - vec2(0.0, 120.0); - frame(&ctx, &mut app, vec![Event::PointerMoved(second)]); - frame(&ctx, &mut app, vec![]); - assert!((panel(&ctx).height() - 440.0).abs() < 1.0, "a normal second held move must continue resizing"); - match operation { - "reset" => { - app.run("ui.dock.reset", json!({})).unwrap(); - } - "arrange" => { - app.run("window.arrange_cascade", json!({})).unwrap(); - } - "visibility" => { - app.run("window.midi_editor", json!({})).unwrap(); - frame(&ctx, &mut app, vec![]); - app.run("window.midi_editor", json!({})).unwrap(); - frame(&ctx, &mut app, vec![]); - } - _ => panic!("unknown synthetic operation"), - } - let reset = serde_json::to_value(&app.ui.docking).unwrap(); - let after_reset = start - vec2(0.0, 160.0); - frame(&ctx, &mut app, vec![Event::PointerMoved(after_reset)]); - frame(&ctx, &mut app, vec![]); - assert_eq!(serde_json::to_value(&app.ui.docking).unwrap(), reset, "old held divider must not resize the replacement layout"); - let expected = if operation == "reset" { 320.0 } else { 440.0 }; - assert!((panel(&ctx).height() - expected).abs() < 1.0); - frame(&ctx, &mut app, vec![button(after_reset, false)]); - for _ in 0..4 { - frame(&ctx, &mut app, vec![]); - } - assert_eq!(serde_json::to_value(&app.ui.docking).unwrap(), reset); - assert_eq!(*app.engine.session(), session); -} - #[test] fn a_selected_video_clip_is_not_a_midi_target() { use soundcraft_model::{ChannelFormat, Clip, ClipContent, SourceId, Track, TrackKind}; @@ -182,6 +51,7 @@ fn only_pencil_inserts_notes_in_the_midi_roll() { let clip = created["clip"].as_u64().unwrap(); app.run("edit.select", json!({"clips": [clip]})).unwrap(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); for _ in 0..6 { frame(&ctx, &mut app, vec![]); } diff --git a/crates/ui-egui/tests/it/midi_quantize.rs b/crates/ui-egui/tests/it/midi_quantize.rs index de9b0b337..a3cd762e0 100644 --- a/crates/ui-egui/tests/it/midi_quantize.rs +++ b/crates/ui-egui/tests/it/midi_quantize.rs @@ -12,7 +12,7 @@ fn quantize_on(grid: &str) -> i64 { app.run("edit.select", json!({"clips": [clip]})).unwrap(); app.run("view.grid", json!({"value": grid})).unwrap(); app.ui.show_midi_editor = true; - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/mix_narrow_headers.rs b/crates/ui-egui/tests/it/mix_narrow_headers.rs index 6e248c02f..c8be7af0d 100644 --- a/crates/ui-egui/tests/it/mix_narrow_headers.rs +++ b/crates/ui-egui/tests/it/mix_narrow_headers.rs @@ -25,7 +25,7 @@ fn painted_labels_with(narrow: bool, fonts: Option) -> Vec<(Str app.run("view.mix_section", json!({"section": "all"})).unwrap(); app.run("view.mix_section", json!({"section": "instruments"})).unwrap(); app.ui.narrow_mix = narrow; - let mut harness = egui_kittest::Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut harness = egui_kittest::Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(ui.ctx()); if let Some(f) = &fonts { diff --git a/crates/ui-egui/tests/it/mix_separate.rs b/crates/ui-egui/tests/it/mix_separate.rs index ad883b96b..e47b507c3 100644 --- a/crates/ui-egui/tests/it/mix_separate.rs +++ b/crates/ui-egui/tests/it/mix_separate.rs @@ -14,7 +14,7 @@ fn mix_in_a_separate_window_toggles_and_closing_it_returns_to_the_main_window() 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( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/new_midi_clip.rs b/crates/ui-egui/tests/it/new_midi_clip.rs index dae4bdbf6..0f7ac7752 100644 --- a/crates/ui-egui/tests/it/new_midi_clip.rs +++ b/crates/ui-egui/tests/it/new_midi_clip.rs @@ -17,6 +17,7 @@ impl Rig { engine.execute("track.new", &json!({"kind": kind})).unwrap(); engine.execute("edit.tool", &json!({"tool": "pencil"})).unwrap(); let mut r = Rig { ctx: egui::Context::default(), app: SoundApp::new(engine, None, Services::default()) }; + soundcraft_ui_egui::framework::install_headless(&r.ctx); r.frames(4); r } diff --git a/crates/ui-egui/tests/it/new_tracks.rs b/crates/ui-egui/tests/it/new_tracks.rs index 53cdffaf3..2b41b1a60 100644 --- a/crates/ui-egui/tests/it/new_tracks.rs +++ b/crates/ui-egui/tests/it/new_tracks.rs @@ -13,7 +13,7 @@ fn harness(tracks: usize) -> Harness<'static, SoundApp> { engine.execute("track.new", &serde_json::json!({"count": tracks})).unwrap(); } let app = SoundApp::new(engine, None, Services::default()); - let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/open_on_insert.rs b/crates/ui-egui/tests/it/open_on_insert.rs index ec62835e3..194cb3130 100644 --- a/crates/ui-egui/tests/it/open_on_insert.rs +++ b/crates/ui-egui/tests/it/open_on_insert.rs @@ -13,7 +13,7 @@ fn harness(engine: soundcraft_engine::Engine, window: MainWindow) -> Harness<'st app.ui.window = window; app.run("view.edit_inserts_ae", json!({})).unwrap(); app.run("track.height", json!({"tracks": ["Vox"], "height": "medium"})).unwrap(); - let mut h = Harness::builder().with_size(vec2(1400.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/plugin_default_reset.rs b/crates/ui-egui/tests/it/plugin_default_reset.rs index df6326e78..47be8d3bd 100644 --- a/crates/ui-egui/tests/it/plugin_default_reset.rs +++ b/crates/ui-egui/tests/it/plugin_default_reset.rs @@ -8,7 +8,7 @@ use soundcraft_ui_egui::{Services, SoundApp}; use std::collections::BTreeMap; fn harness(app: SoundApp) -> Harness<'static, SoundApp> { - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/plugin_fine_sliders.rs b/crates/ui-egui/tests/it/plugin_fine_sliders.rs index 0ff092442..b98569543 100644 --- a/crates/ui-egui/tests/it/plugin_fine_sliders.rs +++ b/crates/ui-egui/tests/it/plugin_fine_sliders.rs @@ -8,7 +8,7 @@ use soundcraft_ui_egui::{Services, SoundApp}; use std::collections::BTreeMap; fn harness(app: SoundApp) -> Harness<'static, SoundApp> { - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/plugin_window.rs b/crates/ui-egui/tests/it/plugin_window.rs index 553b6a8ee..8674083ed 100644 --- a/crates/ui-egui/tests/it/plugin_window.rs +++ b/crates/ui-egui/tests/it/plugin_window.rs @@ -7,7 +7,7 @@ fn a_long_plugin_window_stays_on_a_short_screen() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let kick = app.engine.session().track_by_name("Kick").unwrap().id; app.ui.plugin_windows = vec![(kick, 0)]; - let mut h = Harness::builder().with_size(egui::vec2(1200.0, 500.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(egui::vec2(1200.0, 500.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/pro_tools_keys.rs b/crates/ui-egui/tests/it/pro_tools_keys.rs index 3276a7159..608ab6eb9 100644 --- a/crates/ui-egui/tests/it/pro_tools_keys.rs +++ b/crates/ui-egui/tests/it/pro_tools_keys.rs @@ -202,6 +202,7 @@ fn the_piano_roll_leaves_modified_arrows_to_the_shortcuts() { app.ui.show_midi_editor = true; app.run("edit.select", json!({"tracks": ["Keys"]})).unwrap(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); let frame = |app: &mut SoundApp, events: Vec| { let raw = RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 1000.0))), events, ..Default::default() }; ctx.run_ui(raw, |ui| { @@ -241,6 +242,7 @@ fn the_piano_roll_selection_follows_notes_the_arrows_move_past_others() { app.ui.show_midi_editor = true; app.run("edit.select", json!({"tracks": ["Keys"]})).unwrap(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); let frame = |app: &mut SoundApp, events: Vec| { let raw = RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 1000.0))), events, ..Default::default() }; ctx.run_ui(raw, |ui| { diff --git a/crates/ui-egui/tests/it/record_hint.rs b/crates/ui-egui/tests/it/record_hint.rs index afcd11a03..04736b211 100644 --- a/crates/ui-egui/tests/it/record_hint.rs +++ b/crates/ui-egui/tests/it/record_hint.rs @@ -9,7 +9,7 @@ use soundcraft_ui_egui::{Services, SoundApp}; fn record_in_an_empty_session_shows_why_at_both_record_buttons() { let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); app.ui.show_transport = true; - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/rename_dialog.rs b/crates/ui-egui/tests/it/rename_dialog.rs index 7b10b73b6..79e6d75a2 100644 --- a/crates/ui-egui/tests/it/rename_dialog.rs +++ b/crates/ui-egui/tests/it/rename_dialog.rs @@ -9,7 +9,7 @@ fn typing_in_the_rename_clip_dialog_replaces_the_old_name() { let clip = app.engine.session().track_by_name("Kick").unwrap().clips()[0].clone(); app.run("edit.select", json!({"clips": [clip.id.0]})).unwrap(); menus::invoke_menu(&mut app, "clip.rename", "Clip > Rename..."); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/rtp_window.rs b/crates/ui-egui/tests/it/rtp_window.rs index cd62eb539..8e1bec54c 100644 --- a/crates/ui-egui/tests/it/rtp_window.rs +++ b/crates/ui-egui/tests/it/rtp_window.rs @@ -21,7 +21,7 @@ fn editing_rtp_velocity_leaves_the_other_properties_alone() { app.run("edit.select", json!({"tracks": [t.0], "exact": true})).unwrap(); menus::invoke_menu(&mut app, "window.rtp", "Event > MIDI Real-Time Properties"); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/sampler_window.rs b/crates/ui-egui/tests/it/sampler_window.rs index 7762bc069..728352613 100644 --- a/crates/ui-egui/tests/it/sampler_window.rs +++ b/crates/ui-egui/tests/it/sampler_window.rs @@ -49,7 +49,7 @@ fn harness() -> (Harness<'static, SoundApp>, TrackId) { let keys = engine.session().tracks.iter().find(|t| t.name == "Keys").unwrap().id; let mut app = SoundApp::new(engine, None, Services::default()); app.ui.plugin_windows.push((keys, soundcraft_mix::INSTRUMENT_SLOT)); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/save_as_replace.rs b/crates/ui-egui/tests/it/save_as_replace.rs index 717e2a6f4..5029388c8 100644 --- a/crates/ui-egui/tests/it/save_as_replace.rs +++ b/crates/ui-egui/tests/it/save_as_replace.rs @@ -19,7 +19,7 @@ fn saving_over_another_session_takes_the_replace_button() { path: path.to_string_lossy().into(), key: "path".into(), }); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/save_changes.rs b/crates/ui-egui/tests/it/save_changes.rs index c189391b8..91618546d 100644 --- a/crates/ui-egui/tests/it/save_changes.rs +++ b/crates/ui-egui/tests/it/save_changes.rs @@ -6,7 +6,7 @@ use soundcraft_ui_egui::{Services, SoundApp, dialogs, menus}; fn harness() -> Harness<'static, SoundApp> { let app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); - Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( + Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(egui::vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/scroll_into_view.rs b/crates/ui-egui/tests/it/scroll_into_view.rs index 2a8173577..761b9f44c 100644 --- a/crates/ui-egui/tests/it/scroll_into_view.rs +++ b/crates/ui-egui/tests/it/scroll_into_view.rs @@ -17,7 +17,7 @@ fn harness(tracks: usize) -> Harness<'static, SoundApp> { // Uneven heights, so an offset counted as "n rows" can't pass for the real one. app.run("track.height", json!({"tracks": ["T02"], "height": "large"})).unwrap(); app.run("track.height", json!({"tracks": ["T04"], "height": "small"})).unwrap(); - let mut h = Harness::builder().with_size(vec2(SIZE.0, SIZE.1)).with_step_dt(1.0 / 60.0).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(SIZE.0, SIZE.1)).with_step_dt(1.0 / 60.0).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/send_window.rs b/crates/ui-egui/tests/it/send_window.rs index 30a2d7bd9..7b9ffa870 100644 --- a/crates/ui-egui/tests/it/send_window.rs +++ b/crates/ui-egui/tests/it/send_window.rs @@ -18,7 +18,7 @@ fn harness() -> (Harness<'static, SoundApp>, soundcraft_model::TrackId) { } let mut app = SoundApp::new(engine, None, Services::default()); app.ui.window = MainWindow::Mix; - let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/shared_controls.rs b/crates/ui-egui/tests/it/shared_controls.rs index acee071cb..455dd3652 100644 --- a/crates/ui-egui/tests/it/shared_controls.rs +++ b/crates/ui-egui/tests/it/shared_controls.rs @@ -105,7 +105,7 @@ fn tool_and_record_buttons_handle_keyboard_disabled_state_and_cancelled_clicks() #[test] fn toolbar_keyboard_activation_changes_tools_without_transport_or_marker_actions() { let app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); @@ -138,7 +138,7 @@ fn toolbar_keyboard_activation_changes_tools_without_transport_or_marker_actions fn track_record_button_arms_the_track_without_starting_transport() { let mut app = SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()); app.run("track.new", serde_json::json!({"name": "Voice"})).unwrap(); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); @@ -167,7 +167,7 @@ fn shared_controls_visuals() { std::fs::create_dir_all(&directory).unwrap(); for scale in [1.0, 2.0] { let app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).with_pixels_per_point(scale).wgpu().build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).with_pixels_per_point(scale).wgpu().build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/shortcuts.rs b/crates/ui-egui/tests/it/shortcuts.rs index c9e2f915a..6f18c8c82 100644 --- a/crates/ui-egui/tests/it/shortcuts.rs +++ b/crates/ui-egui/tests/it/shortcuts.rs @@ -42,6 +42,7 @@ fn type_in_app(ctx: &egui::Context, app: &mut SoundApp, keys: &[(Key, Modifiers) fn tab_leaves_the_keys_to_the_shortcuts() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); for _ in 0..3 { type_in_app(&ctx, &mut app, &[]); } @@ -139,6 +140,7 @@ fn x_and_middle(app: &SoundApp, at: i64) -> (f32, f32) { fn left_and_right_arrows_centre_the_edit_window_on_the_selected_clip() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); let (clip_id, clip) = app.engine.session().tracks.iter().flat_map(|t| t.clips()).find(|c| c.start > 100_000).map(|c| (c.id, c.range())).unwrap(); app.run("view.zoom_set", json!({"samples_per_px": 10.0})).unwrap(); app.run("view.scroll", json!({"to": 0})).unwrap(); @@ -172,6 +174,7 @@ fn the_piano_roll_keeps_the_plain_arrows() { app.run("view.zoom_set", json!({"samples_per_px": 10.0})).unwrap(); app.run("view.scroll", json!({"to": 1_000_000})).unwrap(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); for _ in 0..6 { app_frame(&ctx, &mut app, vec![]); } @@ -201,6 +204,7 @@ fn a_midi_editor_behind_another_tab_leaves_the_arrows_to_the_edit_window() { app.run("view.zoom_set", json!({"samples_per_px": 10.0})).unwrap(); app.run("view.scroll", json!({"to": 0})).unwrap(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); for _ in 0..6 { app_frame(&ctx, &mut app, vec![]); } @@ -211,7 +215,7 @@ fn a_midi_editor_behind_another_tab_leaves_the_arrows_to_the_edit_window() { app_frame(&ctx, &mut app, vec![]); } assert!(app.ui.show_midi_editor, "the MIDI editor is still open"); - assert_ne!(app.ui.docking.layout.panel_state(&soundcraft_ui_egui::docking::Panel::Midi), craft_behavior::dock::PanelState::Front); + assert_ne!(app.ui.docking.layout().panel_state(&soundcraft_ui_egui::docking::Panel::Midi), craft_behavior::dock::PanelState::Front); app_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(body.center())]); app.run("edit.select", json!({"clips": [clip_id.0]})).unwrap(); diff --git a/crates/ui-egui/tests/it/side_lists_access.rs b/crates/ui-egui/tests/it/side_lists_access.rs index c44bc4ecd..6f74bdb38 100644 --- a/crates/ui-egui/tests/it/side_lists_access.rs +++ b/crates/ui-egui/tests/it/side_lists_access.rs @@ -15,7 +15,7 @@ fn harness() -> Harness<'static, SoundApp> { let first = app.engine.session().tracks.first().map(|t| t.id.0).unwrap_or_default(); app.run("track.group", json!({"name": "Rhythm", "tracks": [first]})).unwrap(); app.engine.session_mut().edit.selected_tracks.clear(); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/side_lists_text.rs b/crates/ui-egui/tests/it/side_lists_text.rs index a99929a85..b36559441 100644 --- a/crates/ui-egui/tests/it/side_lists_text.rs +++ b/crates/ui-egui/tests/it/side_lists_text.rs @@ -12,7 +12,7 @@ fn harness() -> Harness<'static, SoundApp> { app.run("track.rename", json!({"track": first, "name": LONG_TRACK})).unwrap(); app.run("track.group", json!({"name": LONG_GROUP, "tracks": [first]})).unwrap(); app.engine.session_mut().edit.selected_tracks.clear(); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/strip_silence_dialog.rs b/crates/ui-egui/tests/it/strip_silence_dialog.rs index dbc1083e3..d6d257293 100644 --- a/crates/ui-egui/tests/it/strip_silence_dialog.rs +++ b/crates/ui-egui/tests/it/strip_silence_dialog.rs @@ -15,7 +15,7 @@ fn strip_silence_dialog() -> (Harness<'static, SoundApp>, TrackId, Vec<(i64, i64 let before = app.engine.session().track(track).unwrap().clips().iter().map(|c| (c.start, c.end())).collect(); menus::invoke_menu(&mut app, "edit.strip_silence", "Edit > Strip Silence"); assert_eq!(app.dialogs.open_name(), Some("strip_silence")); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/strip_silence_rectangles.rs b/crates/ui-egui/tests/it/strip_silence_rectangles.rs index a76445ec6..f6ce9916c 100644 --- a/crates/ui-egui/tests/it/strip_silence_rectangles.rs +++ b/crates/ui-egui/tests/it/strip_silence_rectangles.rs @@ -15,7 +15,7 @@ fn strip_silence_dialog() -> (Harness<'static, SoundApp>, TrackId) { app.run("edit.select", json!({"tracks": [track.0], "start": 0, "end": end})).unwrap(); menus::invoke_menu(&mut app, "edit.strip_silence", "Edit > Strip Silence"); assert_eq!(app.dialogs.open_name(), Some("strip_silence")); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/strip_silence_rename.rs b/crates/ui-egui/tests/it/strip_silence_rename.rs index 9f20c33d9..8a869aa8f 100644 --- a/crates/ui-egui/tests/it/strip_silence_rename.rs +++ b/crates/ui-egui/tests/it/strip_silence_rename.rs @@ -15,7 +15,7 @@ fn strip_silence_dialog() -> (Harness<'static, SoundApp>, TrackId) { app.run("edit.select", json!({"tracks": [track.0], "start": 0, "end": end})).unwrap(); menus::invoke_menu(&mut app, "edit.strip_silence", "Edit > Strip Silence"); assert_eq!(app.dialogs.open_name(), Some("strip_silence")); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/strip_silence_sliders.rs b/crates/ui-egui/tests/it/strip_silence_sliders.rs index 42e5d3167..a2a57aff3 100644 --- a/crates/ui-egui/tests/it/strip_silence_sliders.rs +++ b/crates/ui-egui/tests/it/strip_silence_sliders.rs @@ -14,7 +14,7 @@ fn strip_silence_dialog() -> Harness<'static, SoundApp> { let end = app.engine.session().content_end(); app.run("edit.select", json!({"tracks": [track.0], "start": 0, "end": end})).unwrap(); menus::invoke_menu(&mut app, "edit.strip_silence", "Edit > Strip Silence"); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { let ctx = ui.ctx().clone(); app.logic(&ctx); diff --git a/crates/ui-egui/tests/it/sub_counter.rs b/crates/ui-egui/tests/it/sub_counter.rs index c0ba2a6a1..70cbad7b5 100644 --- a/crates/ui-egui/tests/it/sub_counter.rs +++ b/crates/ui-egui/tests/it/sub_counter.rs @@ -17,6 +17,7 @@ impl Rig { app: SoundApp::new(soundcraft_engine::Engine::default(), None, Services::default()), shapes: Vec::new(), }; + soundcraft_ui_egui::framework::install_headless(&r.ctx); r.frames(4); r } diff --git a/crates/ui-egui/tests/it/toolbar_scroll.rs b/crates/ui-egui/tests/it/toolbar_scroll.rs index e71f5f140..9b9fb2f5d 100644 --- a/crates/ui-egui/tests/it/toolbar_scroll.rs +++ b/crates/ui-egui/tests/it/toolbar_scroll.rs @@ -20,7 +20,7 @@ fn a_narrow_window_scrolls_the_toolbar_to_reach_the_tempo() { let mut engine = soundcraft_engine::Engine::default(); engine.execute("track.new", &json!({})).unwrap(); let app = SoundApp::new(engine, None, Services::default()); - let mut h = egui_kittest::Harness::builder().with_size(vec2(WIDTH, 700.0)).build_ui_state( + let mut h = egui_kittest::Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(WIDTH, 700.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/toolbar_tempo.rs b/crates/ui-egui/tests/it/toolbar_tempo.rs index 67ad3f53c..c4d198fa5 100644 --- a/crates/ui-egui/tests/it/toolbar_tempo.rs +++ b/crates/ui-egui/tests/it/toolbar_tempo.rs @@ -16,6 +16,7 @@ impl Rig { let mut engine = soundcraft_engine::Engine::default(); engine.execute("track.new", &json!({})).unwrap(); let mut r = Rig { ctx: egui::Context::default(), app: SoundApp::new(engine, None, Services::default()), shapes: Vec::new() }; + soundcraft_ui_egui::framework::install_headless(&r.ctx); r.frames(4); r } diff --git a/crates/ui-egui/tests/it/track_height.rs b/crates/ui-egui/tests/it/track_height.rs index 027dad937..e2cf5d36a 100644 --- a/crates/ui-egui/tests/it/track_height.rs +++ b/crates/ui-egui/tests/it/track_height.rs @@ -26,6 +26,7 @@ fn button(pos: Pos2, pressed: bool) -> Event { fn rig() -> (egui::Context, SoundApp) { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); frame(&ctx, &mut app, vec![]); frame(&ctx, &mut app, vec![]); (ctx, app) diff --git a/crates/ui-egui/tests/it/track_list.rs b/crates/ui-egui/tests/it/track_list.rs index b0407b292..9d7ea1f41 100644 --- a/crates/ui-egui/tests/it/track_list.rs +++ b/crates/ui-egui/tests/it/track_list.rs @@ -16,6 +16,7 @@ impl Rig { let mut engine = soundcraft_engine::Engine::default(); engine.execute("track.new", &json!({"count": 6})).unwrap(); let mut r = Rig { ctx: egui::Context::default(), app: SoundApp::new(engine, None, Services::default()), shapes: Vec::new() }; + soundcraft_ui_egui::framework::install_headless(&r.ctx); for _ in 0..4 { r.frame(vec![]); } diff --git a/crates/ui-egui/tests/it/track_name_menu.rs b/crates/ui-egui/tests/it/track_name_menu.rs index 4a695ee2e..636d85436 100644 --- a/crates/ui-egui/tests/it/track_name_menu.rs +++ b/crates/ui-egui/tests/it/track_name_menu.rs @@ -19,7 +19,7 @@ fn right_click_on_a_track_name_opens_the_track_menu() { let mut engine = soundcraft_engine::Engine::default(); engine.execute("track.new", &serde_json::json!({"name": "Voice"})).unwrap(); let app = SoundApp::new(engine, None, Services::default()); - let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/trackpad.rs b/crates/ui-egui/tests/it/trackpad.rs index fcbea19f2..45ce3d282 100644 --- a/crates/ui-egui/tests/it/trackpad.rs +++ b/crates/ui-egui/tests/it/trackpad.rs @@ -18,6 +18,7 @@ impl Rig { let (tx, rx) = channel(); let app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()).with_control(rx); let mut r = Rig { ctx: egui::Context::default(), app, tx, width }; + soundcraft_ui_egui::framework::install_headless(&r.ctx); // egui 0.37 scroll areas treat point wheel events as a trackpad: they rubber-band at an // edge and can coast after the gesture. These tests assert exact offsets, so the rig uses // deterministic scrolling (production keeps the kinetic feel). diff --git a/crates/ui-egui/tests/it/tracks_scroll_bar.rs b/crates/ui-egui/tests/it/tracks_scroll_bar.rs index 523fb63a2..8a47f3273 100644 --- a/crates/ui-egui/tests/it/tracks_scroll_bar.rs +++ b/crates/ui-egui/tests/it/tracks_scroll_bar.rs @@ -40,7 +40,7 @@ fn first_row(h: &Harness<'_, SoundApp>) -> Rect { fn the_tracks_gutter_pages_a_long_list() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); app.run("track.new", json!({"count": 60})).unwrap(); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/tests/it/waveform.rs b/crates/ui-egui/tests/it/waveform.rs index 489ba0fc3..69a747a70 100644 --- a/crates/ui-egui/tests/it/waveform.rs +++ b/crates/ui-egui/tests/it/waveform.rs @@ -87,6 +87,7 @@ fn blocks_hide_waveforms_and_playlist_lanes_show_them() { app.engine.execute("track.view", &json!({"tracks": ["Snare"], "view": "blocks"})).unwrap(); let main = app.engine.session().track_by_name("Bass").unwrap().height.points(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); assert!(waveforms(&ctx, &mut app, "Kick", 0.0) > 0); assert_eq!(waveforms(&ctx, &mut app, "Snare", 0.0), 0); assert!(waveforms(&ctx, &mut app, "Bass", main) > 0, "the alternate playlist's lane"); @@ -99,6 +100,7 @@ fn overlapped_crossfades_show_the_outgoing_clip_too() { app.engine.execute("view.zoom_set", &json!({"samples_per_px": 64})).unwrap(); app.engine.execute("view.scroll", &json!({"to": {"seconds": 18.0}})).unwrap(); let ctx = egui::Context::default(); + soundcraft_ui_egui::framework::install_headless(&ctx); let plain = waveforms(&ctx, &mut app, "Bass", 0.0); app.engine.execute("view.waveform_overlapped_crossfades", &json!({"value": true})).unwrap(); assert_eq!(waveforms(&ctx, &mut app, "Bass", 0.0), plain + 1); diff --git a/crates/ui-egui/tests/it/zoom_toggle.rs b/crates/ui-egui/tests/it/zoom_toggle.rs index 2011c8128..be6c09a76 100644 --- a/crates/ui-egui/tests/it/zoom_toggle.rs +++ b/crates/ui-egui/tests/it/zoom_toggle.rs @@ -10,7 +10,7 @@ fn e_fits_the_selection_to_the_edit_window_and_the_button_goes_back() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let bass = app.engine.session().track_by_name("Bass").unwrap().id.0; app.engine.execute("edit.select", &json!({"tracks": [bass], "start": 96_000, "end": 192_000})).unwrap(); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).with_os(os).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).with_os(os).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); @@ -49,7 +49,7 @@ fn alt_shift_e_and_an_alt_click_cancel_zoom_toggle_and_keep_the_zoomed_view() { let mut app = SoundApp::new(soundcraft_engine::demo::demo_engine(), None, Services::default()); let bass = app.engine.session().track_by_name("Bass").unwrap().id.0; app.engine.execute("edit.select", &json!({"tracks": [bass], "start": 96_000, "end": 192_000})).unwrap(); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).with_os(os).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).with_os(os).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/mix_instrument_contrast.rs b/crates/ui-egui/tests/mix_instrument_contrast.rs index 2bb6cd928..800cb64b3 100644 --- a/crates/ui-egui/tests/mix_instrument_contrast.rs +++ b/crates/ui-egui/tests/mix_instrument_contrast.rs @@ -111,7 +111,10 @@ fn populated_mix_instrument_uses_readable_palette_in_real_frames() { let session = app.engine.session().clone(); assert!(!session.pool.is_empty(), "the fixture must include decoded audio"); let proof_dir = std::env::var_os("SOUNDCRAFT_MIX_PROOF_DIR").map(std::path::PathBuf::from); - let mut builder = egui_kittest::Harness::builder().with_size(vec2(1600.0, 1000.0)).with_pixels_per_point(2.0); + let mut builder = egui_kittest::Harness::builder() + .with_size(vec2(1600.0, 1000.0)) + .with_pixels_per_point(2.0) + .with_context_setup(soundcraft_ui_egui::framework::install_headless); if proof_dir.is_some() { builder = builder.wgpu(); } diff --git a/crates/ui-egui/tests/mix_strip_layout.rs b/crates/ui-egui/tests/mix_strip_layout.rs index 3f1b0bb30..1cdcbd8ad 100644 --- a/crates/ui-egui/tests/mix_strip_layout.rs +++ b/crates/ui-egui/tests/mix_strip_layout.rs @@ -20,7 +20,7 @@ fn mix(mode: ThemeMode) -> Harness<'static, SoundApp> { } app.run("window.mix", json!({})).unwrap(); app.run("ui.theme", json!({"mode": mode.id()})).unwrap(); - let mut harness = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut harness = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(ui.ctx()); app.ui(ui); diff --git a/crates/ui-egui/tests/recovery.rs b/crates/ui-egui/tests/recovery.rs index 5c295c808..af1a04848 100644 --- a/crates/ui-egui/tests/recovery.rs +++ b/crates/ui-egui/tests/recovery.rs @@ -60,7 +60,7 @@ fn an_exit_without_quit_offers_unsaved_changes_at_the_next_launch() { first.close_autosave(); drop(first); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); @@ -85,7 +85,7 @@ fn every_change_is_autosaved_within_a_second() { let _one = one_at_a_time(); let dir = folder("recovery-changes"); let root = dir.join("Autosave"); - let mut h = Harness::builder().with_size(vec2(1600.0, 1000.0)).build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1600.0, 1000.0)).build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui); diff --git a/crates/ui-egui/tests/theme_docking.rs b/crates/ui-egui/tests/theme_docking.rs index 54495c22a..2d203707c 100644 --- a/crates/ui-egui/tests/theme_docking.rs +++ b/crates/ui-egui/tests/theme_docking.rs @@ -14,7 +14,7 @@ fn shared_panels_and_controls_follow_manual_and_live_system_appearance() { app.run(id, json!({})).unwrap(); } let session = app.engine.session().clone(); - let mut h = Harness::builder().with_size(vec2(1400.0, 1000.0)).with_pixels_per_point(scale).wgpu().build_ui_state( + let mut h = Harness::builder().with_context_setup(soundcraft_ui_egui::framework::install_headless).with_size(vec2(1400.0, 1000.0)).with_pixels_per_point(scale).wgpu().build_ui_state( |ui, app: &mut SoundApp| { app.logic(&ui.ctx().clone()); app.ui(ui);