Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ fn electron_exe() -> PathBuf {

// ── shared session helper ────────────────────────────────────────────────────

/// Wait (up to ~5s) for `port` to become free. These web tests use FIXED CDP
/// ports (9222/9223) and a process-global `CUA_DRIVER_CDP_PORT`, so they must
/// run serially (`--test-threads=1`). A previous test's host can still be
/// releasing its port when the next launches; reusing it before then makes the
/// daemon discover the OLD host's page (`pages[0]`), so the click lands on a
/// stale window and the counter check fails. This guard closes that teardown
/// overlap — belt-and-braces on top of serial execution.
fn wait_port_free(port: u16) {
for _ in 0..50 {
if std::net::TcpStream::connect(("127.0.0.1", port)).is_err() {
return;
}
std::thread::sleep(Duration::from_millis(100));
}
eprintln!("warning: CDP port {port} still bound after 5s — prior host may not have released it");
}

/// Launch the harness exe + a cua-driver child with `CUA_DRIVER_CDP_PORT`
/// pointing at the harness's CDP endpoint. Polls list_windows until the
/// host's window appears.
Expand All @@ -63,6 +80,9 @@ where
eprintln!("{label} host exe not found at {host_exe:?} — run test-harness/build/windows.ps1");
return;
}
// A prior test's host may still hold this fixed CDP port — wait for it to
// free so the daemon doesn't discover the stale host's page.
wait_port_free(cdp_port);
// Set the CDP port the daemon should probe; the spawned cua-driver child
// inherits it from this process's environment.
std::env::set_var("CUA_DRIVER_CDP_PORT", cdp_port.to_string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,14 @@ fn harness_wpf_slider_drag() {

let resp = driver.call("drag", serde_json::json!({
"pid": pid as i64, "window_id": wid,
// drag screen-coords path: send_drag_synthesized takes screen
// coords directly. The harness window is centered at
// (517, 66) with the slider track at client (50-330, 275);
// convert to screen via ClientToScreen approximation by
// offsetting by window position + non-client chrome
// (title bar + border ~30,8). screen coords here are
// re-derived in window-local form by the tool's existing
// ClientToScreen step.
"from_x": 50.0, "from_y": 275.0,
"to_x": 330.0, "to_y": 275.0,
// Window-local coords along the slider TRACK. The track row sits at
// window-local y≈304 (verified on the VM: y=275 landed ~29px above
// it, on empty GroupBox space, so the thumb never moved); the thumb
// rests at the left (x≈44) at value=0. Dragging left→right advances
// the value. (TODO: derive these from the `sld-value` element frame
// in get_window_state for DPI/placement independence.)
"from_x": 44.0, "from_y": 304.0,
"to_x": 330.0, "to_y": 304.0,
"duration_ms": 700, "steps": 40,
"dispatch": "foreground"
}));
Expand Down
Loading