Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

7.4 KB
Raw Blame

cua-driver desktop E2E suites

Tests in this crate drive a built cua-driver binary against real desktops, staged harness apps, and installed apps. Most are marked #[ignore] because they need an interactive desktop; the canonical OS runners select them. The few non-ignored tests are hermetic oracle and parser checks.

Hermetic protocol, CLI, and schema tests stay with the driver in ../../cua-driver/tests/. Put a new test here when it needs a desktop, a fixture app, an installed app, or OS permissions.

This crate does not depend on the driver. Build cua-driver first, or point CUA_TEST_DRIVER_BIN at a built binary; the testkit otherwise looks for it in the Cargo target directory.

Start with the contributor overview in ../../../../docs/test-harnesses-guide.md, then use the matrix below as the coverage map.

The cross-OS ownership map is maintained in ../../../../docs/test-matrix.md. Update that matrix when adding a harness, action, addressing mode, delivery mode, or OS-specific window-system case.

Naming

Prefix Purpose
harness_<toolkit>_test.rs Toolkit-specific harness apps
cross_platform_behavior_test.rs Shared Electron/Tauri/WKWebView action matrix
desktop_scope_<os>_test.rs Platform window/desktop scope contract
installed_app_*_test.rs, standalone_browser_behavior_test.rs Installed apps and browsers
perception_capture_loop_test.rs Optional perception capture, parse, capture-bound click, and reobserve loop, including the published signed extension
*_<os>_test.rs, hyprland_*_test.rs, wayland_*_test.rs Platform- or compositor-specific desktop rows

Harness Requirements

Build harness apps before running ignored tests:

# macOS
../../../../tests/fixtures/build/macos.sh

# Linux
../../../../tests/fixtures/build/linux.sh
# Windows
..\..\..\..\tests\fixtures\build\windows.ps1

Staged outputs are read from libs/cua-driver/rust/test-apps/harness-<name>/.

The canonical cross-platform matrix is cross_platform_behavior_test.rs. It runs the same external-state scenarios against Electron and Tauri on each supported host, plus the native WKWebView host on macOS. CI and VM runners set CUA_TEST_DRIVER_BIN, CUA_TEST_APPS_ROOT, and CUA_TEST_WORKSPACE_ROOT when artifacts are built outside Cargo's default workspace paths. They also set CUA_TEST_REQUIRE_FIXTURES=1, turning a missing fixture into a failure instead of a silent skip.

Each matrix row declares its action, AX/PX targeting, foreground or background delivery, scope, driver route, external oracles, and required behavior in cases.jsonl. results.jsonl records the observed behavior and derived test status. The Rust reporter validates both files and renders summary.md.

The canonical OS runners also set CUA_E2E_RECORDINGS_ROOT. Every testkit McpDriver then records its full desktop trajectory to a unique directory containing recording.mp4, cursor samples, action JSON, per-turn screenshots, and a trajectory.json test-label manifest. Windows and Linux require FFmpeg; macOS uses the installed driver's ScreenCaptureKit backend. The runner validates each MP4 with ffprobe before reporting success. A separate Rust preflight verifies the desktop, fixture, AX tree, screenshot, and video lifecycle once before behavioral cells run.

Running

cargo build -p cua-driver
cargo test -p cua-driver-e2e --test harness_appkit_test -- --ignored --nocapture
cargo test -p cua-driver-e2e --test desktop_scope_macos_test -- --ignored --nocapture

The canonical Windows E2E entrypoint is scripts/ci/windows/run-rust-e2e.ps1 -RequireGui. It runs the complete Rust harness matrix; internal lane selectors are retained only for focused diagnosis. Optional external-app suites remain separate.

The canonical macOS E2E entrypoint is libs/cua-driver/tests/runners/macos-lume/run-all.sh. It runs in a disposable clone of the private maintainer seed, or in a SIP-off worker prepared with the checked-in macOS consent seed helper. It requires a logged-in user session and verifies the installed driver's Accessibility and Screen Recording grants before delegating to scripts/ci/macos/run-rust-e2e.sh.

For focused macOS runs on a workstation shared with other driver clients, start a TCC-authorized daemon on a dedicated socket and set CUA_E2E_MACOS_DAEMON_SOCKET to that socket. This prevents an unrelated MCP client from changing the shared daemon's session or recording state while a row is asserting focus preservation.

Legacy Windows Sandbox runs use ../../../../tests/runners/windows-sandbox/run-tests-in-sandbox.ps1, which builds selected Windows harness apps and maps them into the sandbox. The current Windows GUI validation path should use a real user desktop session through RDP or an interactive scheduled task.

Windows GUI tests require a usable interactive desktop. SSH-launched commands start in Session 0 and cannot drive the user's desktop directly; launch GUI tests through an interactive scheduled task (/IT) or equivalent so they run in the logged-on user session.

The testkit's native DesktopObserver records foreground-window, z-order, cursor, and leaked-input state around rows that promise no desktop side effects. If the input desktop is not Default or cannot be opened, the session is usually locked or disconnected. Reconnect, use tscon /dest:console on a disposable GUI VM, or boot the VM into an unlocked console session before running ignored GUI tests.

Set CUA_REQUIRE_GUI=1 on dedicated GUI runners to turn these desktop self-skips into hard failures with the full desktop-state diagnostic.

The repository-level runners are the preferred entrypoints for the canonical matrix:

scripts/ci/linux/run-rust-e2e.sh
.\scripts\ci\windows\run-rust-e2e.ps1 -RequireGui

Optional External Apps

These suites are Rust source-of-truth coverage for real installed apps, but they are not part of the canonical run-all path because they depend on software or desktop state outside the repo-local fixtures:

  • harness_libreoffice_test.rs: Windows LibreOffice Writer, the only coverage of the SAL/VCL MSAA fallback. Requires LibreOffice installed, or LO_SWRITER_EXE pointing at swriter.exe; it fails when Writer is missing.
  • installed_app_launch_macos_test.rs: macOS Calculator/TextEdit launch focus checks. Requires a logged-in GUI session and usable System Events scripting.
  • installed_app_textedit_macos_test.rs: real TextEdit background AX write and verification, plus the window-only foreground chord delivered while Finder holds the front or while a sibling document holds the keyboard focus. Requires a logged-in GUI session and Accessibility permission.
  • standalone_browser_behavior_test.rs: installed Chrome and Edge browser-tool targeting, mutation, frame, tab, ambiguity, and isolated-profile rows. The harness owns a fresh browser profile and creates adversarial tabs and windows through the browser endpoint instead of relying on browser command-line handoff behavior. Run it through the cross-platform scripts/ci/run-rust-standalone-browser-e2e.sh, which stages the Electron foreground sentinel when needed and opts pure Wayland runs into the native backend. Non-macOS runs prove that standard mode refuses existing-profile attachment before running the authorized success rows with a disposable unrestricted daemon. The macOS Lume run-all.sh acceptance run always includes the success rows.