test(raw): a developed raw takes the Raw Defaults resolution on every open path; other files keep theirs (#7789)

This commit is contained in:
Korg1ch
2026-10-21 18:28:11 +03:00
parent 699bbd4b85
commit 01784f104f
2 changed files with 48 additions and 0 deletions
+29
View File
@@ -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");
+19
View File
@@ -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();