diff --git a/crates/ui-egui/tests/viewer.rs b/crates/ui-egui/tests/viewer.rs index 46c04cc0f..9f560c81c 100644 --- a/crates/ui-egui/tests/viewer.rs +++ b/crates/ui-egui/tests/viewer.rs @@ -108,7 +108,10 @@ fn view_history_select_all_and_find_options() { h.state_mut().views[0].open_find(); h.state_mut().views[0].find.as_mut().unwrap().query = "page".into(); h.state_mut().views[0].rerun_find(); - for _ in 0..60 { + // Find runs in the background: wait for it by a deadline, not a frame count, which a loaded + // machine (the whole workspace testing at once) can use up before the last page is searched. + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20); + while std::time::Instant::now() < deadline { h.run_steps(2); std::thread::sleep(std::time::Duration::from_millis(5)); if h.state().views[0].find.as_ref().unwrap().matches.len() >= 15 { @@ -126,7 +129,11 @@ fn view_history_select_all_and_find_options() { assert_eq!(h.state().views[0].find.as_ref().unwrap().matches.len(), 0, "\"page\" alone, lower case, appears nowhere"); h.state_mut().views[0].find.as_mut().unwrap().query = "PAGE".into(); h.state_mut().views[0].rerun_find(); - h.run_steps(2); + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20); + while std::time::Instant::now() < deadline && h.state().views[0].find.as_ref().unwrap().matches.len() < 5 { + h.run_steps(2); + std::thread::sleep(std::time::Duration::from_millis(5)); + } assert_eq!(h.state().views[0].find.as_ref().unwrap().matches.len(), 5); }