mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-27 19:48:14 -06:00
tests: the pending-open control test waits for the worker by time, not by 30 frames
This commit is contained in:
@@ -1672,15 +1672,19 @@ fn control_open_replies_pending_while_the_worker_opens_and_focuses_once_it_has()
|
||||
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;
|
||||
for _ in 0..30 {
|
||||
while std::time::Instant::now() < deadline {
|
||||
h.run_steps(1);
|
||||
let state = ok(&mut 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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user