From c07e5b0eaebf61cc3b3c61495cd8e40daccff226 Mon Sep 17 00:00:00 2001 From: Li-Sheng Chou <142213184+choupeanut@users.noreply.github.com> Date: Thu, 19 Nov 2026 22:12:40 +0800 Subject: [PATCH] test(render): inspect shadow jobs without starting work --- crates/map/src/raster.rs | 7 +++++++ crates/render/src/lib.rs | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/map/src/raster.rs b/crates/map/src/raster.rs index 2c85b8088b..040dce3ff2 100644 --- a/crates/map/src/raster.rs +++ b/crates/map/src/raster.rs @@ -746,6 +746,13 @@ impl RasterLayer { jobs.iter().map(|j| j.work.waiting.load(std::sync::atomic::Ordering::SeqCst)).sum() } + /// How many light jobs it and its copies keep, including finished ones: for tests of whether + /// drawing started work, without starting any work through the inspection itself. + #[doc(hidden)] + pub fn cast_shadow_jobs(&self) -> usize { + self.cast.0.lock().unwrap_or_else(|e| e.into_inner()).len() + } + /// The light its cast shadows leave on each cell (see [`crate::shadow::light`]), when it is /// drawn as Shaded Relief with shadows. Worked out once per pixels, band, sun, Z factor and /// mask and kept: each owner's latest, and a few of suns left, for going back. diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rs index cce6c479ff..28857d0846 100644 --- a/crates/render/src/lib.rs +++ b/crates/render/src/lib.rs @@ -9589,6 +9589,7 @@ mod tests { let m = export.join().unwrap(); assert!(waited, "the export waited for the far band's cast shadows"); let rl = m.layer(id).and_then(|l| l.raster.as_ref()).unwrap(); + assert!(rl.cast_shadow_jobs() > 0, "completed light work remains observable"); assert!(matches!(rl.cast_shadows(false, (0, 0), || {}), rustgis_map::raster::CastShadows::Ready(_)), "and drew them"); } @@ -9627,10 +9628,7 @@ mod tests { } render_complete(&mut m, &view).unwrap(); let rl = m.layer(id).and_then(|l| l.raster.as_ref()).unwrap(); - assert!( - matches!(rl.cast_shadows(false, (0, 0), || {}), rustgis_map::raster::CastShadows::Pending), - "grouped {grouped}: nothing was worked out for it" - ); + assert_eq!(rl.cast_shadow_jobs(), 0, "grouped {grouped}: no light work was started"); } }