From 94064f104030c7cfb23d7788db1cd688d482775d Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 21:37:57 +0000 Subject: [PATCH] RAW Develop trial: a sampler reads the before picture while Before shows --- crates/imaging/tests/it/raw_develop.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/imaging/tests/it/raw_develop.rs b/crates/imaging/tests/it/raw_develop.rs index ca755ce1f..56ede1520 100644 --- a/crates/imaging/tests/it/raw_develop.rs +++ b/crates/imaging/tests/it/raw_develop.rs @@ -107,8 +107,9 @@ impl RawDevelopSource for Source { None } - fn sample(&self, _: [f64; 2], _: bool, _: bool) -> Option { - None + fn sample(&self, _: [f64; 2], before: bool, _: bool) -> Option { + let level = f32::from(if before { self.before.level } else { self.after.level }) / 255.0; + Some(ScopeReadout::Rgb([level; 3])) } fn has_selection(&self) -> bool { @@ -246,6 +247,25 @@ fn before_shows_the_before_picture_and_edits_nothing() { assert_eq!(exposure(&host), 0.0, "Before records no history step"); } +#[trial] +fn a_sampler_reads_the_picture_on_show() { + let host = Rc::new(RefCell::new(DialogHost::new())); + let mut fixture = fixture(&host, &Rc::new(Cell::new(false))); + host.borrow_mut().open(HostedWorkspace::new(RawDevelopWorkspace::new(open(RawTarget::Filter)), Source::new())); + fixture.idle(10); + let canvas = focus_canvas(&mut fixture); + fixture.key(Key::S, Modifiers::NONE).idle(2); + fixture.click(&canvas).idle(4); + let reading = |fixture: &Fixture| fixture.texts().iter().find(|run| run.text.starts_with("#1 ")).map(|run| run.text.to_string()); + let developed = reading(&fixture).expect("a click of the Color Sampler tool adds a sampler"); + + fixture.frame(vec![key_event(Key::Y, true)]).idle(6); + let before = reading(&fixture).expect("the sampler keeps reading while Before shows"); + assert_ne!(before, developed, "Before reads the undeveloped pixel"); + fixture.frame(vec![key_event(Key::Y, false)]).idle(4); + assert_eq!(reading(&fixture), Some(developed), "releasing Y reads the developed pixel again"); +} + /// A color sampler's readout shows under the zoom bar. fn readout_shown(fixture: &Fixture) -> bool { fixture.texts().iter().any(|run| run.text.starts_with("#1 "))