From 57eb75a0fad3962ba0efa36aa34e862e190fdbb4 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 23:06:02 +0100 Subject: [PATCH] Warp: the smart-object preset tests follow main's transform session After the merge with main, the open transform keeps its warp in `session.warp()` and the shared `app_with_square` helper is private to the transform tests, so the test file reads the warp through the session, changes Bend with `set_warp` and has its own square helper. Co-Authored-By: Claude Opus 5.5 --- .../transform_tool/warp_smart_style_tests.rs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tools/transform_tool/warp_smart_style_tests.rs b/crates/ui-egui/src/tools/transform_tool/warp_smart_style_tests.rs index 2b7370df0e4..517fe89137b 100644 --- a/crates/ui-egui/src/tools/transform_tool/warp_smart_style_tests.rs +++ b/crates/ui-egui/src/tools/transform_tool/warp_smart_style_tests.rs @@ -5,11 +5,26 @@ use serde_json::json; -use super::super::tests::app_with_square; +use super::super::warp::set_warp; use super::super::*; +/// A `size` × `size` document with a new layer filled red over `fill`. +fn app_with_square(size: u32, fill: photocraft_geom::Rect) -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.execute("file.new", json!({"width": size, "height": size})).unwrap(); + app.sync_views(); + app.session.execute("layer.new.layer", json!({})).unwrap(); + app.session + .edit("paint", |doc, a| { + doc.layer_mut(a.unwrap()).unwrap().surface_mut().unwrap().fill_rect(fill, &[1.0, 0.0, 0.0, 1.0]); + Ok(()) + }) + .unwrap(); + app +} + /// A 64 × 64 document whose red square 8,8 to 32,32 is a smart object warped with `params`. -fn warped(params: serde_json::Value) -> PhotocraftApp { +fn warped(params: serde_json::Value) -> Box { let mut app = app_with_square(64, photocraft_geom::Rect::new(8, 8, 32, 32)); app.run("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); app.run("layer.smartObjects.warp", params).unwrap(); @@ -17,7 +32,7 @@ fn warped(params: serde_json::Value) -> PhotocraftApp { } fn session_warp(app: &PhotocraftApp) -> Warp { - app.ui.transform.as_ref().and_then(|t| t.warp.clone()).expect("Warp mode") + app.ui.transform.as_ref().and_then(|t| t.session.warp()).map(|w| w.warp.clone()).expect("Warp mode") } fn stored(app: &PhotocraftApp) -> Warp { @@ -50,7 +65,9 @@ fn a_changed_bend_commits_as_the_preset() { let ctx = egui::Context::default(); let mut app = warped(json!({"style": "arc", "bend": 50, "rect": [8, 8, 32, 32]})); begin_warp(&mut app, &ctx).unwrap(); - app.ui.transform.as_mut().unwrap().warp.as_mut().unwrap().bend = 25.0; + let mut w = session_warp(&app); + w.bend = 25.0; + set_warp(&mut app, w); commit(&mut app); let w = stored(&app); assert_eq!((w.style, w.bend), (WarpStyle::Arc, 25.0), "stored as Arc, not Custom");