From b903e2e7e78284f057bdb2e5116066ccdbc9e2d5 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Sun, 1 Nov 2026 23:55:44 +0300 Subject: [PATCH] Placed-document tests: register the gated loader everywhere set_loader keeps the first registration, so a test registering blue_page first left the gate out. Every test in the file now registers gated_blue_page (blue_page while the gate is open). --- crates/render/src/tests/placed_document.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/render/src/tests/placed_document.rs b/crates/render/src/tests/placed_document.rs index 00af69a2c..32b36b77b 100644 --- a/crates/render/src/tests/placed_document.rs +++ b/crates/render/src/tests/placed_document.rs @@ -27,7 +27,7 @@ fn blue_page(p: &PlacedDocument, bytes: &[u8]) -> Option<(Document, Node, Rect)> /// A 100×100 document showing one placed file (`bytes` under `key`) in the box (10, 10)–(90, 50). fn doc_with(key: &str, bytes: &[u8]) -> Document { - vectorcraft_doc::placed_document::set_loader(blue_page); + vectorcraft_doc::placed_document::set_loader(gated_blue_page); let mut d = Document::new(100.0, 100.0); d.images.insert(key.into(), ImageBlob::new("application/json", bytes.to_vec())); let l = d.layers[0].id; @@ -60,7 +60,9 @@ static GATE_SHUT: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool: /// The thread drawing while the gate is shut: it never waits (a file read there is drawn exactly). static GATE_HOLDER: std::sync::Mutex> = std::sync::Mutex::new(None); -/// [`blue_page`] once the gate opens (at most 10 s), except on the thread that shut it. +/// [`blue_page`] once the gate opens (at most 10 s), except on the thread that shut it. Every test +/// here registers it: the first registration stays, so all of them must agree (open, it is +/// `blue_page`). fn gated_blue_page(p: &PlacedDocument, bytes: &[u8]) -> Option<(Document, Node, Rect)> { let here = std::thread::current().id(); let holder = *GATE_HOLDER.lock().unwrap_or_else(std::sync::PoisonError::into_inner); @@ -201,7 +203,7 @@ fn copies_of_one_placed_document_share_its_bitmap() { #[test] fn nine_large_bitmaps_on_screen_are_not_made_again() { let _serial = serial(); - vectorcraft_doc::placed_document::set_loader(blue_page); + vectorcraft_doc::placed_document::set_loader(gated_blue_page); let mut d = Document::new(100.0, 100.0); let l = d.layers[0].id; let keys: Vec = (0..9).map(|i| format!("nine-{i}")).collect();