Merge pull request #2729 from dotCooCoo/fix/canvas-test-worker-deadlines

Tests: five tests that wait on another thread pass on a loaded machine
This commit is contained in:
BFlat
2026-10-18 01:55:29 +07:00
committed by GitHub
3 changed files with 8 additions and 5 deletions
+4 -1
View File
@@ -383,7 +383,10 @@ mod tests {
});
let mut reader = BufReader::new(client.try_clone().unwrap());
for id in [1, 2] {
writeln!(client, "{}", json!({"id": id, "method": "inspect"})).unwrap();
// The client sends each line in one write. `writeln!` on the socket sends the JSON in many
// small writes, and when the machine is busy, a pause of more than the 120 ms line deadline
// between two of them closes the connection.
client.write_all(format!("{}\n", json!({"id": id, "method": "inspect"})).as_bytes()).unwrap();
let mut line = String::new();
reader.read_line(&mut line).unwrap();
assert_eq!(serde_json::from_str::<Value>(&line).unwrap(), json!({"id": id, "ok": true}));
+1 -1
View File
@@ -4411,7 +4411,7 @@ mod tests {
app.session.pointer(&PointerEvent::new(PointerKind::Up, 181.9, 131.3), view).unwrap();
assert!(upload(&mut app).is_none(), "not rendered on this thread");
assert!(app.canvas.worker.as_ref().and_then(|w| w.pending.as_ref()).is_some_and(|k| !k.interacting), "sent to the worker");
let until = std::time::Instant::now() + std::time::Duration::from_secs(10);
let until = std::time::Instant::now() + std::time::Duration::from_secs(60);
let mut after = None;
while after.is_none() && std::time::Instant::now() < until {
std::thread::sleep(std::time::Duration::from_millis(5));
+3 -3
View File
@@ -117,7 +117,7 @@ fn a_slow_clipboard_is_read_off_the_ui_thread() {
frame(&mut app);
assert!(t0.elapsed() < Duration::from_millis(300), "the frame waited on the clipboard: {:?}", t0.elapsed());
// The probe's verdict (the UI's own handle would say no) enables Paste once it arrives.
assert!(frames_until(&mut app, Duration::from_secs(3), |app| app.system_paste), "the probe's verdict never arrived");
assert!(frames_until(&mut app, Duration::from_secs(60), |app| app.system_paste), "the probe's verdict never arrived");
assert!(menus::enabled(&app, "edit.paste"));
let threads = rec.threads.lock().unwrap().clone();
assert!(threads.iter().all(|n| n.as_deref() == Some("vectorcraft-clip")), "checked on: {threads:?}");
@@ -128,7 +128,7 @@ fn the_probe_rests_after_a_copy_and_stops_with_the_app() {
let rec = Arc::new(Recorder::default());
let mut app = app(&rec, Duration::ZERO, false, Some(true));
run(&mut app, "file.new", json!({"width": 100, "height": 100}));
assert!(frames_until(&mut app, Duration::from_secs(2), |app| app.system_paste));
assert!(frames_until(&mut app, Duration::from_secs(60), |app| app.system_paste));
// Something copied in the app enables Paste alone: the clipboard isn't read any more.
copy_rect(&mut app);
frames_until(&mut app, Duration::from_millis(50), |_| false);
@@ -149,7 +149,7 @@ fn without_its_thread_the_check_runs_in_line_again() {
// The probe's clipboard panics: its thread ends.
let mut app = app(&rec, Duration::ZERO, true, None);
run(&mut app, "file.new", json!({"width": 100, "height": 100}));
assert!(frames_until(&mut app, Duration::from_secs(2), |app| app.system_paste), "no fallback");
assert!(frames_until(&mut app, Duration::from_secs(60), |app| app.system_paste), "no fallback");
assert!(app.clipboard_probe.is_none());
let threads = rec.threads.lock().unwrap().clone();
assert_eq!(threads.first().cloned().flatten().as_deref(), Some("vectorcraft-clip"), "{threads:?}");