From 01784f104fced35fc79766b29a9b62f4a63aa3a8 Mon Sep 17 00:00:00 2001 From: Korg1ch <57859048+Korg1ch@users.noreply.github.com> Date: Mon, 19 Oct 2026 20:54:35 +0300 Subject: [PATCH] test(raw): a developed raw takes the Raw Defaults resolution on every open path; other files keep theirs (#7789) --- crates/engine/src/file_cmds/tests.rs | 29 ++++++++++++++++++++++++++++ crates/ui-egui/src/camera_raw_ui.rs | 19 ++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/crates/engine/src/file_cmds/tests.rs b/crates/engine/src/file_cmds/tests.rs index 9b18da73d0..113a12ded9 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.rs index cfd0d5c8df..0d37beaac7 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();