Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

Merge upstream main into integration batch A

aiongg95ec6348c319
diff --cc crates/ui-egui/tests/it/control.rs
index 2e9f11568,ec29ecc97..5a6869b06
--- a/crates/ui-egui/tests/it/control.rs
+++ b/crates/ui-egui/tests/it/control.rs
@@@ -1731,21 -1674,14 +1733,16 @@@ fn control_open_replies_pending_while_t
assert_eq!(first["pending"], true, "{first}");
// The worker completes the open on later frames; the tab shows, and only then does a
- // repeated open focus it instead of reporting another pending open.
+ // repeated open focus it instead of reporting another pending open. The worker is a thread
+ // of its own, so the wait is bounded by time: a busy runner can draw 30 frames before it has
+ // read the file.
- let deadline = std::time::Instant::now() + std::time::Duration::from_secs(30);
let mut documents = 0;
- while std::time::Instant::now() < deadline {
- h.run_steps(1);
- let state = ok(&mut h, &c, "ui.state", json!({}));
+ let opened = crate::support::step_until(&mut h, |h| {
+ let state = ok(h, &c, "ui.state", json!({}));
documents = state["documents"].as_array().map(|d| d.len()).unwrap_or_default();
- if documents == 1 {
- break;
- }
- std::thread::sleep(std::time::Duration::from_millis(5));
- }
- assert_eq!(documents, 1, "the pending open completed into a tab");
+ documents == 1
+ });
+ assert!(opened, "the pending open completed into a tab: {documents} tabs");
let again = ok(&mut h, &c, "ui.open", json!({ "path": a }));
assert_eq!(again["focused"], true, "{again}");