PhotoCraft: An open-source, photo editor written by scratch in pure Rust
test(raw): a developed raw takes the Raw Defaults resolution on every open path; other files keep theirs (#7789)
Korg1ch01784f104fce
diff --git a/crates/engine/src/file_cmds/tests.rs b/crates/engine/src/file_cmds/tests.rsindex 9b18da73d..113a12ded 100644--- a/crates/engine/src/file_cmds/tests.rs+++ b/crates/engine/src/file_cmds/tests.rs@@ -92,6 +92,35 @@ fn batch_same_format_saves_camera_raws_as_psd() {}}+/// Edit › Preferences › Raw Defaults › Resolution sets the ppi a raw opens with, through+/// File › Open (the background open job) and through opening bytes; other files keep their own.+#[test]+fn a_developed_raw_opens_at_the_raw_defaults_resolution() {+ use photocraft_raw::testgen::{DngSpec, mosaic, scene};+ let (w, h) = (24, 16);+ let raw = DngSpec::cfa(w, h, mosaic(&scene(w, h), w, [0, 1, 1, 2], 0, 65535)).build();+ let dir = tmp("raw-defaults");+ let path = join(&dir, "IMG_0002.dng");+ std::fs::write(&path, &raw).unwrap();+ let open = |s: &mut Session, path: &str| match s.start_open(path, crate::jobs::OpenSource::Path(path.into())).unwrap() {+ crate::jobs::Started::Job(id) => {+ s.wait_job(id).unwrap();+ }+ crate::jobs::Started::Done(_) => {}+ };+ let mut s = Session::new();+ open_bytes_as(&mut s, "IMG_0001.dng", &raw, None, None).unwrap();+ assert_eq!(doc(&s).resolution_dpi, 300.0, "the default");+ s.execute("prefs.set", json!({"path": "rawDefaults.resolution", "value": 240})).unwrap();+ open_bytes_as(&mut s, "IMG_0001.dng", &raw, None, None).unwrap();+ assert_eq!(doc(&s).resolution_dpi, 240.0);+ open(&mut s, &path);+ assert_eq!(doc(&s).resolution_dpi, 240.0, "File › Open");+ let png = png(&dir, "a.png", 4, 4, "#ff0000");+ open(&mut s, &png);+ assert_eq!(doc(&s).resolution_dpi, 72.0, "not a raw");+}+#[test]fn revert_reloads_as_one_undoable_step() {let dir = tmp("revert");diff --git a/crates/ui-egui/src/camera_raw_ui.rs b/crates/ui-egui/src/camera_raw_ui.rsindex cfd0d5c8d..0d37beaac 100644--- a/crates/ui-egui/src/camera_raw_ui.rs+++ b/crates/ui-egui/src/camera_raw_ui.rs@@ -1890,6 +1890,25 @@ mod tests {assert!(mean_red(&app) > before + 0.05, "{before} → {}", mean_red(&app));}+ /// #7789: Preferences › Raw Defaults › Resolution sets a raw's ppi when the app opens it+ /// itself (no background job) and from automation, and a Camera Raw re-develop keeps it.+ #[test]+ fn a_raw_opens_and_redevelops_at_the_raw_defaults_resolution() {+ let (mut app, dng) = raw_app();+ let ctx = egui::Context::default();+ app.run("prefs.set", json!({"path": "rawDefaults.resolution", "value": 240})).unwrap();+ app.open_bytes("IMG_0004.dng", &dng).unwrap();+ assert_eq!(app.session.active().unwrap().doc.resolution_dpi, 240.0);+ let raw = app.pending_raw_open.take().unwrap();+ open_raw(&mut app, &ctx, raw).unwrap();+ menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"exposure": 1.0}}})).unwrap().unwrap();+ let r = menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"commit": true}})).unwrap().unwrap();+ assert_eq!(r["redeveloped"], true, "{r}");+ assert_eq!(app.session.active().unwrap().doc.resolution_dpi, 240.0, "kept by the re-develop");+ app.open_automation_bytes("IMG_0005.dng", &dng).unwrap();+ assert_eq!(app.session.active().unwrap().doc.resolution_dpi, 240.0, "automation open");+ }+#[test]fn cancel_closes_the_raw_and_the_preference_skips_the_dialog() {let (mut app, dng) = raw_app();