From 43b6a793b454ae17c3eba94eedefa839b452388a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 12 Nov 2026 05:54:24 -0800 Subject: [PATCH] Color: the screen color sampler's bus tests wait for the answer without a time limit The tests call the sampler's pick directly instead of giving it 30 seconds on another thread. --- .../src/linux_screen_color/portal.rs | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/apps/vectorcraft/src/linux_screen_color/portal.rs b/apps/vectorcraft/src/linux_screen_color/portal.rs index 4144a373cb..b7518e1ce3 100644 --- a/apps/vectorcraft/src/linux_screen_color/portal.rs +++ b/apps/vectorcraft/src/linux_screen_color/portal.rs @@ -220,17 +220,6 @@ mod tests { connect(zbus::blocking::connection::Builder::address(address)).unwrap() } - /// [`pick`] on `conn`, given 30 seconds to answer: an answer that is never awaited fails the - /// test instead of leaving it waiting. - fn pick_within(conn: &Connection, parent: &str) -> Result, Failure> { - let (tx, rx) = std::sync::mpsc::channel(); - let (conn, parent) = (conn.clone(), parent.to_string()); - std::thread::spawn(move || { - let _ = tx.send(pick(&conn, &parent)); - }); - rx.recv_timeout(std::time::Duration::from_secs(30)).expect("the portal's answer was not awaited within 30 seconds") - } - /// The portal's name, owned on the private bus at `address` before any call, so the bus never /// starts an installed portal in its place. fn portal(address: &str) -> Connection { @@ -295,10 +284,10 @@ mod tests { calls }); let client = client(address); - assert_eq!(pick_within(&client, "x11:12"), Ok(Some([0.25, 0.5, 0.75]))); - assert_eq!(pick_within(&client, "wayland:example"), Ok(None)); - assert_eq!(pick_within(&client, ""), Ok(Some([0.25, 0.5, 0.75]))); - assert!(matches!(pick_within(&client, ""), Err(Failure::NoAnswer(_)))); + assert_eq!(pick(&client, "x11:12"), Ok(Some([0.25, 0.5, 0.75]))); + assert_eq!(pick(&client, "wayland:example"), Ok(None)); + assert_eq!(pick(&client, ""), Ok(Some([0.25, 0.5, 0.75]))); + assert!(matches!(pick(&client, ""), Err(Failure::NoAnswer(_)))); let calls = worker.join().unwrap(); assert_eq!(calls.iter().map(|(parent, _)| parent.as_str()).collect::>(), ["x11:12", "wayland:example", "", ""]); } @@ -323,7 +312,7 @@ mod tests { }); let client = client(address); assert_eq!(client.method_timeout(), Some(CALL_TIMEOUT)); - let failure = pick_within(&client, ""); + let failure = pick(&client, ""); assert!(matches!(failure, Err(Failure::Unavailable(_))), "{failure:?}"); worker.join().unwrap(); }