From b2a6a823a226087c6d029be2b6f7f87aa94c48cd Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Nov 2026 20:51:50 +0000 Subject: [PATCH 1/2] Tests: reuse the Camera Raw histogram harness (#15928) --- .../ui-egui/tests/it/camera_raw_histogram.rs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/tests/it/camera_raw_histogram.rs b/crates/ui-egui/tests/it/camera_raw_histogram.rs index f90da8ef97..0136b99cec 100644 --- a/crates/ui-egui/tests/it/camera_raw_histogram.rs +++ b/crates/ui-egui/tests/it/camera_raw_histogram.rs @@ -37,23 +37,23 @@ fn request(h: &mut Harness<'_, Box>, params: Value) -> Value { #[test] fn histogram_matches_visible_preview_at_all_supported_depths_and_cancel_commit_are_reversible() { + let mut h = Harness::builder().with_step_dt(1.0 / 60.0).with_size(egui::vec2(1200.0, 800.0)).build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, AppTheme::pro()); + PhotocraftApp::with_context(cc.egui_ctx.clone(), photocraft_engine::Session::new(), Default::default()) + }); for mode in ["rgb", "grayscale"] { for depth in [8, 16, 32] { - let mut h = Harness::builder().with_step_dt(1.0 / 60.0).with_size(egui::vec2(1200.0, 800.0)).build_eframe(move |cc| { - PhotocraftApp::setup_context(&cc.egui_ctx, AppTheme::pro()); - let mut app = PhotocraftApp::with_context(cc.egui_ctx.clone(), photocraft_engine::Session::new(), Default::default()); - app.run("file.new", json!({"width": 16, "height": 8, "mode": mode, "depth": depth})).unwrap(); - app.run("layer.new.layer", json!({})).unwrap(); - app.run("edit.fill", json!({"color": "#808080"})).unwrap(); - app - }); + let app = h.state_mut(); + app.run("file.new", json!({"width": 16, "height": 8, "mode": mode, "depth": depth})).unwrap(); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("edit.fill", json!({"color": "#808080"})).unwrap(); h.run_steps(3); let original = h.state().session.active().unwrap().doc.clone(); let steps = h.state().session.active().unwrap().history.past_len(); let initial = request(&mut h, json!({})); assert_eq!(initial["histogram"]["samples"], 128); let changed = request(&mut h, json!({"ui": {"set": {"exposure": 1.0}}})); - assert_ne!(changed["histogram"]["red"], initial["histogram"]["red"]); + assert_ne!(changed["histogram"]["red"], initial["histogram"]["red"], "{mode}/{depth}: exposure must change the histogram"); assert_eq!(h.state().session.active().unwrap().history.past_len(), steps); request(&mut h, json!({"ui": {"cancel": true}})); assert!(std::sync::Arc::ptr_eq(&h.state().session.active().unwrap().doc, &original), "Cancel leaves the document alone"); @@ -64,6 +64,10 @@ fn histogram_matches_visible_preview_at_all_supported_depths_and_cancel_commit_a h.state_mut().run("edit.redo", json!({})).unwrap(); let committed = request(&mut h, json!({})); assert_eq!(committed["histogram"]["red"], changed["histogram"]["red"], "{mode}/{depth}: graph and committed pixels disagree"); + request(&mut h, json!({"ui": {"cancel": true}})); + assert!(described(&h).is_null(), "{mode}/{depth}: Camera Raw must close"); + h.state_mut().run("file.close", json!({"discard": true})).unwrap(); + assert!(h.state().session.active().is_none(), "{mode}/{depth}: the next case needs a fresh document"); } } } From f8d9f92a7af36f5ad4bad205302d4b5df8c7042b Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Nov 2026 21:40:29 +0000 Subject: [PATCH 2/2] Tests: wait for a new Camera Raw preview revision (#15928) --- .../ui-egui/tests/it/camera_raw_histogram.rs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/tests/it/camera_raw_histogram.rs b/crates/ui-egui/tests/it/camera_raw_histogram.rs index 0136b99cec..e6c2af6106 100644 --- a/crates/ui-egui/tests/it/camera_raw_histogram.rs +++ b/crates/ui-egui/tests/it/camera_raw_histogram.rs @@ -11,13 +11,13 @@ fn described(h: &Harness<'_, Box>) -> Value { /// Runs the app's frames until the develop of the settings in force has landed, and returns the dialog's /// description. The develop waits on the framework's queue until a request finishes it, as the agent entry /// point's `waitPreview` does. -fn settled(h: &mut Harness<'_, Box>) -> Value { - h.run_steps(2); +fn settled(h: &mut Harness<'_, Box>, previous_revision: u64) -> Value { for _ in 0..2000 { craft::ui::runtime::pending::finish_jobs(&h.ctx, std::time::Duration::from_secs(30)); h.run_steps(1); let now = described(h); - if now["previewPending"] == false && !now["histogram"].is_null() { + let advanced = now["previewRevision"].as_u64().is_some_and(|revision| revision > previous_revision); + if advanced && now["previewPending"] == false && !now["histogram"].is_null() { return now; } std::thread::sleep(std::time::Duration::from_millis(5)); @@ -25,14 +25,9 @@ fn settled(h: &mut Harness<'_, Box>) -> Value { panic!("the Camera Raw preview never finished"); } -/// A control request, then the develop it asks for. -fn request(h: &mut Harness<'_, Box>, params: Value) -> Value { +fn request(h: &mut Harness<'_, Box>, params: Value) { let ctx = h.ctx.clone(); - let reply = camera_raw_ui::menu(h.state_mut(), &ctx, "filter.cameraRaw", ¶ms).unwrap().unwrap(); - if described(h).is_null() { - return reply; - } - settled(h) + camera_raw_ui::menu(h.state_mut(), &ctx, "filter.cameraRaw", ¶ms).unwrap().unwrap(); } #[test] @@ -47,12 +42,14 @@ fn histogram_matches_visible_preview_at_all_supported_depths_and_cancel_commit_a app.run("file.new", json!({"width": 16, "height": 8, "mode": mode, "depth": depth})).unwrap(); app.run("layer.new.layer", json!({})).unwrap(); app.run("edit.fill", json!({"color": "#808080"})).unwrap(); - h.run_steps(3); + h.run_steps(1); let original = h.state().session.active().unwrap().doc.clone(); let steps = h.state().session.active().unwrap().history.past_len(); - let initial = request(&mut h, json!({})); + request(&mut h, json!({})); + let initial = settled(&mut h, 0); assert_eq!(initial["histogram"]["samples"], 128); - let changed = request(&mut h, json!({"ui": {"set": {"exposure": 1.0}}})); + request(&mut h, json!({"ui": {"set": {"exposure": 1.0}}})); + let changed = settled(&mut h, initial["previewRevision"].as_u64().unwrap()); assert_ne!(changed["histogram"]["red"], initial["histogram"]["red"], "{mode}/{depth}: exposure must change the histogram"); assert_eq!(h.state().session.active().unwrap().history.past_len(), steps); request(&mut h, json!({"ui": {"cancel": true}})); @@ -62,7 +59,8 @@ fn histogram_matches_visible_preview_at_all_supported_depths_and_cancel_commit_a h.state_mut().run("edit.undo", json!({})).unwrap(); assert!(std::sync::Arc::ptr_eq(&h.state().session.active().unwrap().doc, &original)); h.state_mut().run("edit.redo", json!({})).unwrap(); - let committed = request(&mut h, json!({})); + request(&mut h, json!({})); + let committed = settled(&mut h, 0); assert_eq!(committed["histogram"]["red"], changed["histogram"]["red"], "{mode}/{depth}: graph and committed pixels disagree"); request(&mut h, json!({"ui": {"cancel": true}})); assert!(described(&h).is_null(), "{mode}/{depth}: Camera Raw must close");