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.

refactor(cua-driver)(test-harness): per-OS layout + cross-platform/shared signposting (#1727)

Francesco Bonacci9a36eb3b94e7
diff --git a/.gitignore b/.gitignore
index 5806dbb21c..32a250ed36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@ node_modules/*
build/
!libs/lume/scripts/build/
!libs/cua-driver/scripts/build/
+!libs/cua-driver/test-harness/build/
+!libs/cua-driver/test-harness/build/**
develop-eggs/
dist/
downloads/
diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/harness_appkit_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/harness_appkit_test.rs
index a5ee077de3..a0c30907ef 100644
--- a/libs/cua-driver/rust/crates/cua-driver/tests/harness_appkit_test.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/tests/harness_appkit_test.rs
@@ -1,11 +1,11 @@
//! Integration test against the CuaTestHarness.AppKit Swift app.
//!
//! Mirror of `harness_wpf_test.rs` for the macOS AppKit hosting pattern.
-//! The harness app lives at `libs/cua-driver/test-harness/CuaTestHarness.AppKit`
+//! The harness app lives at `libs/cua-driver/test-harness/apps/macos/appkit`
//! and is published into `libs/cua-driver/rust/test-apps/harness-appkit/`
-//! by `libs/cua-driver/test-harness/build.sh`.
+//! by `libs/cua-driver/test-harness/build/macos.sh`.
//!
-//! Scenarios (see `libs/cua-driver/test-harness/scenarios/scenarios.json`
+//! Scenarios (see `libs/cua-driver/test-harness/shared/scenarios.json`
//! `appkit` section):
//! - counter : NSButton AXPress invocation increments counter
//! - text_body : get_window_state extracts known marker text
@@ -14,7 +14,7 @@
//! - scroll_target : scroll updates VerticalOffset label
//! - ns_menubar : main menubar item enumerable (Mac-specific)
//!
-//! Run locally (after `libs/cua-driver/test-harness/build.sh`):
+//! Run locally (after `libs/cua-driver/test-harness/build/macos.sh`):
//! cargo test --test harness_appkit_test -- --ignored --nocapture
//!
//! Tests are `#[ignore]` so they don't run in plain `cargo test`.
@@ -98,7 +98,7 @@ impl Harness {
let exe = harness_exe();
if !exe.exists() {
eprintln!("harness exe not found at {exe:?} \
- — run libs/cua-driver/test-harness/build.sh first");
+ — run libs/cua-driver/test-harness/build/macos.sh first");
return None;
}
// Launch the binary directly (not via `open`) so we control the pid
@@ -371,7 +371,7 @@ fn harness_appkit_type_text_keystroke() {
/// changes (it mirrors the clip view's documentVisibleRect.origin.y).
///
/// **Status:** EXPECTED-FAIL today (see notes below). The `scroll` tool
-/// itself works at the API level — `scripts/mac-smoke.sh` confirms it
+/// itself works at the API level — `libs/cua-driver/test-harness/smoke/macos.sh` confirms it
/// PASSes against the same harness window. What this test would
/// verify additionally is that the scroll event actually moved the
/// scroll view's bounds (state-change observation, not just API
diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/harness_swiftui_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/harness_swiftui_test.rs
index 3050bcaa01..adcfcae209 100644
--- a/libs/cua-driver/rust/crates/cua-driver/tests/harness_swiftui_test.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/tests/harness_swiftui_test.rs
@@ -11,7 +11,7 @@
//! - text_input: TextField with mirror Text
//! - popover : .popover() — SwiftUI analogue of WinUI3 CommandBarFlyout
//!
-//! Run locally (after `libs/cua-driver/test-harness/build.sh`):
+//! Run locally (after `libs/cua-driver/test-harness/build/macos.sh`):
//! cargo test --test harness_swiftui_test -- --ignored --nocapture
#![cfg(target_os = "macos")]
diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/harness_web_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/harness_web_test.rs
index eecd7609de..1f7852277e 100644
--- a/libs/cua-driver/rust/crates/cua-driver/tests/harness_web_test.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/tests/harness_web_test.rs
@@ -1,6 +1,6 @@
//! Integration tests against the CuaTestHarness.WebView (WPF + WebView2)
//! and CuaTestHarness.Electron hosts. Both load the same
-//! `test-harness/shared-web/index.html`, so the same `page` tool flows
+//! `test-harness/shared/web/index.html`, so the same `page` tool flows
//! are exercised against two Chromium-based hosts.
//!
//! Run via:
@@ -125,7 +125,7 @@ where F: FnOnce(u32, u64, &mut ChildStdin, &mut BufReader<&mut ChildStdout>) {
eprintln!("cua-driver.exe not built — run `cargo build` first"); return;
}
if !host_exe.exists() {
- eprintln!("{label} host exe not found at {host_exe:?} — run test-harness/build.ps1"); return;
+ eprintln!("{label} host exe not found at {host_exe:?} — run test-harness/build/windows.ps1"); return;
}
// Set the CDP port the host should use so the daemon can find it.
let env_var = if label == "webview" { "CUA_WEBVIEW_CDP_PORT" } else { "CUA_ELECTRON_CDP_PORT" };
diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/harness_winui3_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/harness_winui3_test.rs
index 4f26d1273e..e40c5dcee4 100644
--- a/libs/cua-driver/rust/crates/cua-driver/tests/harness_winui3_test.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/tests/harness_winui3_test.rs
@@ -74,7 +74,7 @@ impl Harness {
fn launch() -> Option<Self> {
let exe = harness_exe();
if !exe.exists() {
- eprintln!("WinUI3 harness exe not found at {exe:?} — run test-harness/build.ps1");
+ eprintln!("WinUI3 harness exe not found at {exe:?} — run test-harness/build/windows.ps1");
return None;
}
let app = Command::new(&exe)
diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/harness_wpf_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/harness_wpf_test.rs
index 3f22376e03..5e7132c788 100644
--- a/libs/cua-driver/rust/crates/cua-driver/tests/harness_wpf_test.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/tests/harness_wpf_test.rs
@@ -19,7 +19,7 @@
//! Run via the sandbox runner:
//! .\sandbox\run-tests-in-sandbox.ps1 harness_wpf
//!
-//! Or locally (requires .NET 8 SDK + `test-harness/build.ps1`):
+//! Or locally (requires .NET 8 SDK + `test-harness/build/windows.ps1`):
//! cargo test --test harness_wpf_test -- --ignored --nocapture
//!
//! Tests are `#[ignore]` so they don't run in plain `cargo test`. The
@@ -99,7 +99,7 @@ impl Harness {
fn launch() -> Option<Self> {
let exe = harness_exe();
if !exe.exists() {
- eprintln!("harness exe not found at {exe:?} — run test-harness/build.ps1 first");
+ eprintln!("harness exe not found at {exe:?} — run test-harness/build/windows.ps1 first");
return None;
}
let app = Command::new(&exe)
diff --git a/libs/cua-driver/rust/sandbox/run-tests-in-sandbox.ps1 b/libs/cua-driver/rust/sandbox/run-tests-in-sandbox.ps1
index 1a7be139f8..2299ab2d4a 100644
--- a/libs/cua-driver/rust/sandbox/run-tests-in-sandbox.ps1
+++ b/libs/cua-driver/rust/sandbox/run-tests-in-sandbox.ps1
@@ -103,7 +103,7 @@ try {
# dotnet isn't available — the smoke tests degrade to "skipped" inside
# the sandbox rather than failing the whole run.
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
- $harnessBuild = Join-Path $wsRoot "..\test-harness\build.ps1"
+ $harnessBuild = Join-Path $wsRoot "..\test-harness\build\windows.ps1"
if (Test-Path $harnessBuild) {
Write-Host "`n[BUILD] test-harness (dotnet publish)..." -ForegroundColor Yellow
# build.ps1 sets $ErrorActionPreference=Stop and throws on
@@ -118,7 +118,7 @@ if (Get-Command dotnet -ErrorAction SilentlyContinue) {
Write-Host "[WARN] test-harness build errored: $($_.Exception.Message) — harness tests will skip." -ForegroundColor Yellow
}
} else {
- Write-Host "`n[SKIP] test-harness/build.ps1 not found — harness tests will skip." -ForegroundColor Yellow
+ Write-Host "`n[SKIP] test-harness/build/windows.ps1 not found — harness tests will skip." -ForegroundColor Yellow
}
} else {
Write-Host "`n[SKIP] dotnet CLI not on PATH — test-harness build skipped, harness tests will degrade." -ForegroundColor Yellow
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.sln b/libs/cua-driver/test-harness/CuaTestHarness.sln
index 366302b890..b47460b615 100644
--- a/libs/cua-driver/test-harness/CuaTestHarness.sln
+++ b/libs/cua-driver/test-harness/CuaTestHarness.sln
@@ -2,11 +2,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CuaTestHarness.Wpf", "CuaTestHarness.Wpf\CuaTestHarness.Wpf.csproj", "{A1B2C3D4-E5F6-4789-ABCD-EF0123456789}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CuaTestHarness.Wpf", "apps\windows\wpf\CuaTestHarness.Wpf.csproj", "{A1B2C3D4-E5F6-4789-ABCD-EF0123456789}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CuaTestHarness.WinUI3", "CuaTestHarness.WinUI3\CuaTestHarness.WinUI3.csproj", "{B2C3D4E5-F6A7-489B-CDEF-012345678901}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CuaTestHarness.WinUI3", "apps\windows\winui3\CuaTestHarness.WinUI3.csproj", "{B2C3D4E5-F6A7-489B-CDEF-012345678901}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CuaTestHarness.WebView", "CuaTestHarness.WebView\CuaTestHarness.WebView.csproj", "{C3D4E5F6-A7B8-49CD-EF01-234567890123}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CuaTestHarness.WebView", "apps\windows\webview2\CuaTestHarness.WebView.csproj", "{C3D4E5F6-A7B8-49CD-EF01-234567890123}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/libs/cua-driver/test-harness/README.md b/libs/cua-driver/test-harness/README.md
index 290f457171..fb68d7926f 100644
--- a/libs/cua-driver/test-harness/README.md
+++ b/libs/cua-driver/test-harness/README.md
@@ -1,211 +1,176 @@
# cua-driver test harness
Deterministic host apps that present a fixed scenario set for cua-driver
-to drive. The apps cover the hosting patterns that matter for background
-automation on each OS:
+to drive. One layout, three buckets: cross-OS reusable assets in
+`shared/`, OS-specific (or cross-platform) target apps in `apps/`,
+host-OS build scripts in `build/`, host-OS CLI smoke runners in
+`smoke/`.
-- **Windows**: two minimal .NET 8 host apps — `CuaTestHarness.Wpf` and
- `CuaTestHarness.WinUI3`
-- **macOS**: two single-file Swift host apps — `CuaTestHarness.AppKit`
- and `CuaTestHarness.SwiftUI`
+## Layout
+
+```text
+test-harness/
+├── shared/ # cross-OS reusable
+│ ├── scenarios.json # single SoT for AutomationIds / window titles
+│ └── web/index.html # WebView2 + Electron load this same file
+├── apps/ # the test-target host apps
+│ ├── cross-platform/
+│ │ └── electron/ # CuaTestHarness.Electron (CDP host, runs on any OS)
+│ ├── macos/
+│ │ ├── appkit/ # CuaTestHarness.AppKit (single-file Swift)
+│ │ └── swiftui/ # CuaTestHarness.SwiftUI (single-file Swift)
+│ └── windows/
+│ ├── wpf/ # CuaTestHarness.Wpf (.NET 8 WPF)
+│ ├── winui3/ # CuaTestHarness.WinUI3 (.NET 8 WinUI3 unpackaged)
+│ └── webview2/ # CuaTestHarness.WebView (WPF + Microsoft.Edge.WebView2)
+├── build/ # host-OS build scripts (publish into ../rust/test-apps/)
+│ ├── macos.sh # builds appkit + swiftui
+│ └── windows.ps1 # builds wpf + winui3 + webview2 + electron
+└── smoke/ # host-OS per-tool CLI smoke runners
+ ├── macos.sh # spawns appkit harness, iterates every tool
+ └── results/macos.txt # checked-in baseline for diff-based regression detection
+```
+
+`shared/scenarios.json` is the single source of truth — both the host
+apps and the Rust integration tests read it so AutomationIds, AX
+identifiers, and window titles never drift between the two halves.
+
+Published build outputs land in `../rust/test-apps/harness-{wpf,winui3,webview,electron,appkit,swiftui}/`
+so the existing sandbox runner and Rust integration tests pick them up
+without further wiring.
## What's exercised
-WPF scenarios (`CuaTestHarness.Wpf`):
+WPF (`apps/windows/wpf`):
- Plain XAML controls + AutomationIds (`counter`, `text_body`)
-- TextBox + mirrored label (`text_input` — drives `type_text` and `set_value`)
-- Right/double-click target (`click_target` — drives `right_click` /
- `double_click` via `MouseRightButtonDown` / `MouseDoubleClick`)
+- TextBox + mirrored label (`text_input`)
+- Right/double-click target (`click_target`)
- Scroll body with VerticalOffset label + WM_VSCROLL hook (`scroll_target`)
- Modal `MessageBox` (`message_box`)
-- Save/Cancel bottom strip — the layout that previously clipped under
- `GetClientRect` (`bottom_strip` — regression guard for PR #1696)
+- Save/Cancel bottom strip — regression guard for PR #1696 (`bottom_strip`)
- Native Win32 child HWNDs via `HwndHost` (`child_hwnd`)
- Owned secondary `Window` (`owned_popup`)
- Layered transparent window (`layered_popup`)
-- Keyboard accelerators — F5 (no modifier) + Ctrl+Shift+H (`accelerator`)
+- Keyboard accelerators — F5 + Ctrl+Shift+H (`accelerator`)
-WinUI3 scenarios (`CuaTestHarness.WinUI3`):
+WinUI3 (`apps/windows/winui3`):
- `counter` / `text_body` / `exit` (parity with WPF)
-- TextBox + mirror (`text_input` — drives `type_text` via UIA `ValuePattern`)
+- TextBox + mirror (`text_input` — UIA `ValuePattern`)
- `CommandBarFlyout` — popup in same HWND, DComp-rendered
- XAML `Popup` — primitive, not a separate HWND
-`scenarios/scenarios.json` is the single source of truth — both the C#
-host apps and the Rust integration tests read it so AutomationIds /
-window titles never drift between the two halves.
-
-## Coverage matrix (Rust integration tests)
-
-| Capability | WPF | WinUI3 |
-|----------------------------------|-----------------|-----------------|
-| Smoke (UIA tree + AutomationIds) | ✅ | ✅ |
-| UIA Invoke click | ✅ | (implicit) |
-| `right_click` (PostMessage/SendInput) | ✅ | — |
-| `double_click` | ✅ | — |
-| `type_text` (PostMessage WM_CHAR / UIA ValuePattern) | ✅ | ✅ |
-| `set_value` (UIA ValuePattern) | ✅ | (covered) |
-| `scroll` (WM_VSCROLL via hook) | ✅ | — |
-| `press_key` accelerator (F5) | ✅ | — |
-| Modal `MessageBox` open + parse + dismiss | ✅ | — |
-| Owned popup open + parse | ✅ | — |
-| Layered popup capture (non-black assertion) | ✅ | — |
-| XAML Popup open + parse | — | ✅ |
+WebView2 (`apps/windows/webview2`):
+- Loads `shared/web/index.html` — same page as the Electron harness.
+- Exposes CDP on `default_cdp_port=9222` so cua-driver's `page` tool can drive it.
-## Layout
-
-```text
-test-harness/
-├── CuaTestHarness.sln
-├── build.ps1 # publishes both projects
-├── scenarios/scenarios.json # shared SoT
-├── CuaTestHarness.Wpf/ # .NET 8, WPF, x64
-└── CuaTestHarness.WinUI3/ # .NET 8, WinUI3 unpackaged, x64
-```
-
-Publish output is staged into `../rust/test-apps/harness-{wpf,winui3}/`
-so the existing sandbox runner picks them up via its mapped-folder route
-(same path convention as `desktop-test-app-electron`).
-
-## Build
-
-Requires the **.NET 8 SDK** on `PATH`:
-```powershell
-winget install Microsoft.DotNet.SDK.8
-```
-
-Then:
-```powershell
-cd libs\cua-driver\test-harness
-.\build.ps1 # both projects
-.\build.ps1 -Skip winui3 # WPF only (fast path for local iteration)
-```
-
-## Run the tests
-
-Locally:
-```powershell
-cd libs\cua-driver\rust
-cargo test --test harness_wpf_test -- --ignored --nocapture
-cargo test --test harness_winui3_test -- --ignored --nocapture
-```
+Electron (`apps/cross-platform/electron`):
+- Loads the same `shared/web/index.html`. CDP on `default_cdp_port=9223`.
-In Windows Sandbox (matches CI):
-```powershell
-.\rust\sandbox\run-tests-in-sandbox.ps1 harness_wpf
-.\rust\sandbox\run-tests-in-sandbox.ps1 harness_winui3
-```
-
-The sandbox runner auto-detects `dotnet` on the host and rebuilds the
-harness before launching. If `dotnet` isn't installed the harness tests
-silently skip (the rest of the suite still runs).
-
----
-
-## macOS — AppKit + SwiftUI harness
-
-### What's exercised
-
-AppKit (`CuaTestHarness.AppKit`):
-- Plain NSButton + NSTextField counter (`counter` — AXPress on a Cocoa NSButton)
+AppKit (`apps/macos/appkit`):
+- Plain NSButton + NSTextField counter (`counter`)
- NSTextField label with shared marker (`text_body`)
-- Editable NSTextField + mirror label (`text_input` — drives `type_text` /
- `set_value` via AXValue)
-- Custom NSView click-target (`click_target` — distinguishes
- `right_click`, `double_click`, plain `click`)
+- Editable NSTextField + mirror label (`text_input`)
+- Custom NSView click-target (`click_target`)
- NSScrollView with tall NSTextView body + offset label (`scroll_target`)
-- Top NSMenu item with known title (`ns_menubar` — Mac-specific scenario
- that has no Windows analogue)
-- Exit button (`exit`)
+- Top NSMenu item with known title (`ns_menubar`)
+- Exit button
-SwiftUI (`CuaTestHarness.SwiftUI`):
+SwiftUI (`apps/macos/swiftui`):
- Counter / text_body / text_input parity with AppKit
-- SwiftUI `.popover()` — Mac analogue of WinUI3 `CommandBarFlyout` /
- XAML `Popup` (`popover`)
+- SwiftUI `.popover()` — Mac analogue of WinUI3 CommandBarFlyout / XAML Popup
- Exit button
-### Coverage matrix (Rust integration tests)
+## Coverage matrices (Rust integration tests)
+
+Windows:
+
+| Capability | WPF | WinUI3 |
+|-------------------------------------|-----------------|--------------|
+| Smoke (UIA tree + AutomationIds) | yes | yes |
+| UIA Invoke click | yes | (implicit) |
+| `right_click` | yes | — |
+| `double_click` | yes | — |
+| `type_text` (PostMessage / UIA) | yes | yes |
+| `set_value` (UIA ValuePattern) | yes | (covered) |
+| `scroll` (WM_VSCROLL via hook) | yes | — |
+| `press_key` accelerator (F5) | yes | — |
+| Modal `MessageBox` open + dismiss | yes | — |
+| Owned popup open + parse | yes | — |
+| Layered popup capture | yes | — |
+| XAML Popup open + parse | — | yes |
+
+macOS:
+
+| Capability | AppKit | SwiftUI |
+|-------------------------------------|-----------------|--------------|
+| Smoke (AX tree + identifiers) | yes | yes |
+| Counter click via element_index | yes | (implicit) |
+| `set_value` (AXSetAttribute) | yes | (covered) |
+| Popover open + body assert | — | yes |
+| Per-tool CLI smoke | `smoke/macos.sh`| — |
-| Capability | AppKit | SwiftUI |
-|----------------------------------|--------------|---------------|
-| Smoke (AX tree + identifiers) | ✅ | ✅ |
-| Counter click via element_index | ✅ | (implicit) |
-| `set_value` (AXSetAttribute) | ✅ | (covered) |
-| Popover open + body assert | — | ✅ |
-| `right_click` / `double_click` | scenario in fixture, manual today | — |
-| Per-tool CLI smoke | covered by `scripts/mac-smoke.sh` | — |
+## Build
-### Layout (macOS half)
+macOS (requires Xcode CLT for `xcrun swiftc`):
-```text
-test-harness/
-├── CuaTestHarness.AppKit/
-│ └── main.swift # single-file AppKit host
-├── CuaTestHarness.SwiftUI/
-│ └── main.swift # single-file SwiftUI host
-├── scenarios/scenarios.json # shared SoT — `appkit` + `swiftui` sections
-└── build.sh # macOS build script (parallels build.ps1)
+```bash
+libs/cua-driver/test-harness/build/macos.sh # both apps
+libs/cua-driver/test-harness/build/macos.sh --skip swiftui # AppKit only
+libs/cua-driver/test-harness/build/macos.sh --clean # nuke stage dirs first
```
-Built outputs are staged into `../rust/test-apps/harness-{appkit,swiftui}/`
-as `.app` bundles — same convention as the Windows side.
+Windows (requires .NET 8 SDK on PATH; Node.js + npm for the Electron app):
-### Build (macOS)
-
-Requires Xcode command line tools on `PATH` (provides `xcrun swiftc`):
-
-```bash
-cd libs/cua-driver/test-harness
-./build.sh # both apps
-./build.sh --skip swiftui # AppKit only (fast iteration)
-./build.sh --clean # nuke stage dirs first
+```powershell
+cd libs\cua-driver\test-harness
+.\build\windows.ps1 # all four apps
+.\build\windows.ps1 -Skip winui3 # skip a specific one
```
-The build script compiles each `main.swift` with `xcrun swiftc -O
--target arm64-apple-macos13.0`, then writes a minimal `Info.plist`
-into a manually-constructed `.app` bundle. No Xcode project files, no
-Swift Package Manager — keeps the bar to "have Xcode CLT installed."
-
-### Run the tests (macOS)
+## Run the integration tests
```bash
+# macOS
cd libs/cua-driver/rust
cargo test --release --test harness_appkit_test -- --ignored --nocapture
cargo test --release --test harness_swiftui_test -- --ignored --nocapture
+
+# Windows (locally)
+cd libs\cua-driver\rust
+cargo test --test harness_wpf_test -- --ignored --nocapture
+cargo test --test harness_winui3_test -- --ignored --nocapture
+
+# Windows Sandbox (matches CI)
+.\rust\sandbox\run-tests-in-sandbox.ps1 harness_wpf
+.\rust\sandbox\run-tests-in-sandbox.ps1 harness_winui3
```
Tests are `#[ignore]` so they don't run in plain `cargo test` (they
-require the harness to be built and TCC Accessibility permission). On a
-fresh Mac, when TCC is NOT granted to the test runner, the smoke tests
-print a TCC hint and exit cleanly rather than misreporting as a hard
-failure.
-
-To grant TCC: System Settings → Privacy & Security → Accessibility →
-add the test binary (`target/release/cua-driver`) or your terminal app.
+require the harness apps to be built and, on macOS, TCC Accessibility
+granted to the test runner).
-### Per-tool CLI smoke (`scripts/mac-smoke.sh`)
+## Per-tool CLI smoke
Companion to the MCP integration tests. Spawns the AppKit harness as a
victim, then iterates every cua-driver tool with sensible JSON args and
reports PASS / FAIL / SKIP in a sorted table. Runs in ~25 seconds.
```bash
-scripts/mac-smoke.sh
+libs/cua-driver/test-harness/smoke/macos.sh
```
-A baseline result file (`scripts/mac-smoke-RESULTS.txt`) is checked in
-for the current driver version (0.2.18) — diff against it to catch
-regressions in tool coverage.
+A baseline result file (`smoke/results/macos.txt`) is checked in for the
+current driver version — diff against it to catch regressions in tool
+coverage.
-### AppKit / SwiftUI AX quirks captured in the tests
+## AppKit / SwiftUI AX quirks captured in the tests
-- **`accessibilityIdentifier` on AXStaticText doesn't propagate.**
+- `accessibilityIdentifier` on AXStaticText doesn't propagate.
NSTextField label-mode + SwiftUI `Text` views render as AXStaticText
leaves and the OS drops the identifier slot. Tests assert AX-id only
- on actionable controls (Buttons, TextFields, menu items) and assert
- on text-content for labels. Same quirk as WPF's TextBlock.
-- **SwiftUI popovers may live in a separate AXWindow.** The popover
- test walks `list_windows` for any new window owned by the harness pid
- if the trigger window doesn't contain the marker.
-- **AX element budget caps tree depth + width.** The harness keeps its
- scroll-body to 30 lines so later scenarios don't get truncated.
+ on actionable controls and assert on text-content for labels.
+- SwiftUI popovers may live in a separate AXWindow. The popover test
+ walks `list_windows` for any new window owned by the harness pid if
+ the trigger window doesn't contain the marker.
+- AX element budget caps tree depth + width. The scroll-body is capped
+ at 30 lines so later scenarios don't get truncated.
diff --git a/libs/cua-driver/test-harness/apps/README.md b/libs/cua-driver/test-harness/apps/README.md
new file mode 100644
index 0000000000..e0da6574b6
--- /dev/null
+++ b/libs/cua-driver/test-harness/apps/README.md
@@ -0,0 +1,30 @@
+# test-harness apps
+
+Each subdirectory is one self-contained host app cua-driver drives. They
+share fixtures via `../shared/scenarios.json` and (where relevant)
+`../shared/web/index.html` so AutomationIds, AX identifiers, and DOM
+ids never drift between the apps and the integration tests.
+
+| Path | Host OS | What it tests |
+|-------------------------------|-----------------|-----------------------------------------------------------------|
+| `cross-platform/electron` | any | Electron + CDP — exercises cua-driver's `page` tool |
+| `macos/appkit` | macOS 13+ | AppKit / Cocoa hosting — NSButton, NSScrollView, NSMenu, etc. |
+| `macos/swiftui` | macOS 13+ | SwiftUI hosting — `.popover()`, declarative state |
+| `windows/wpf` | Windows | WPF / UIA — popups, layered windows, modal MessageBox, hwndhost |
+| `windows/winui3` | Windows | WinUI3 unpackaged — DComp popups, XAML Popup primitive |
+| `windows/webview2` | Windows | Microsoft.Edge.WebView2 hosting the same DOM as Electron |
+
+Built outputs land in `../../rust/test-apps/harness-{appkit,swiftui,wpf,winui3,webview,electron}/`
+via `../build/macos.sh` or `..\build\windows.ps1`. The Rust integration
+tests under `../../rust/crates/cua-driver/tests/harness_*.rs` consume
+those staged outputs.
+
+Adding a new app:
+
+1. Pick the right OS bucket (or `cross-platform/` if Electron-equivalent).
+2. Mirror an existing app's layout — Swift `main.swift` for macOS,
+ `.csproj` + XAML for Windows.
+3. Add a section to `../shared/scenarios.json` with the AutomationIds /
+ AX identifiers / window title your tests will assert on.
+4. Wire it into `../build/{macos.sh,windows.ps1}` so it stages into
+ `rust/test-apps/harness-<name>/`.
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Electron/.gitignore b/libs/cua-driver/test-harness/apps/cross-platform/electron/.gitignore
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Electron/.gitignore
rename to libs/cua-driver/test-harness/apps/cross-platform/electron/.gitignore
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Electron/build.ps1 b/libs/cua-driver/test-harness/apps/cross-platform/electron/build.ps1
similarity index 90%
rename from libs/cua-driver/test-harness/CuaTestHarness.Electron/build.ps1
rename to libs/cua-driver/test-harness/apps/cross-platform/electron/build.ps1
index 4b7e406169..d132fba3df 100644
--- a/libs/cua-driver/test-harness/CuaTestHarness.Electron/build.ps1
+++ b/libs/cua-driver/test-harness/apps/cross-platform/electron/build.ps1
@@ -5,13 +5,15 @@
# the electron runtime + our app resources, with electron.exe renamed to
# CuaTestHarness.Electron.exe so tests get a deterministic exe name.
#
-# Output: ../rust/test-apps/harness-electron/
+# Output: ../../../../rust/test-apps/harness-electron/
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$elecDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
-$harnessDir = Split-Path -Parent $elecDir
+$crossDir = Split-Path -Parent $elecDir
+$appsDir = Split-Path -Parent $crossDir
+$harnessDir = Split-Path -Parent $appsDir
$cuaDriverDir = Split-Path -Parent $harnessDir
$testAppsDir = Join-Path $cuaDriverDir "rust\test-apps"
$outDir = Join-Path $testAppsDir "harness-electron"
@@ -25,7 +27,7 @@ Push-Location $elecDir
try {
$webDir = Join-Path $elecDir "web"
if (-not (Test-Path $webDir)) { New-Item -ItemType Directory $webDir | Out-Null }
- Copy-Item (Join-Path $harnessDir "shared-web\*") $webDir -Recurse -Force
+ Copy-Item (Join-Path $harnessDir "shared\web\*") $webDir -Recurse -Force
if (-not (Test-Path "node_modules\electron\dist\electron.exe")) {
Write-Host "[INSTALL] npm install (first run)..." -ForegroundColor Yellow
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Electron/main.js b/libs/cua-driver/test-harness/apps/cross-platform/electron/main.js
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Electron/main.js
rename to libs/cua-driver/test-harness/apps/cross-platform/electron/main.js
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Electron/package.json b/libs/cua-driver/test-harness/apps/cross-platform/electron/package.json
similarity index 93%
rename from libs/cua-driver/test-harness/CuaTestHarness.Electron/package.json
rename to libs/cua-driver/test-harness/apps/cross-platform/electron/package.json
index afe7cd99e1..c154dea269 100644
--- a/libs/cua-driver/test-harness/CuaTestHarness.Electron/package.json
+++ b/libs/cua-driver/test-harness/apps/cross-platform/electron/package.json
@@ -1,7 +1,7 @@
{
"name": "cua-test-harness-electron",
"version": "1.0.0",
- "description": "cua-driver Electron test harness — loads the same shared-web/index.html as CuaTestHarness.WebView",
+ "description": "cua-driver Electron test harness — loads the same shared/web/index.html as CuaTestHarness.WebView",
"private": true,
"main": "main.js",
"scripts": {
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.AppKit/main.swift b/libs/cua-driver/test-harness/apps/macos/appkit/main.swift
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.AppKit/main.swift
rename to libs/cua-driver/test-harness/apps/macos/appkit/main.swift
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.SwiftUI/main.swift b/libs/cua-driver/test-harness/apps/macos/swiftui/main.swift
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.SwiftUI/main.swift
rename to libs/cua-driver/test-harness/apps/macos/swiftui/main.swift
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WebView/.gitignore b/libs/cua-driver/test-harness/apps/windows/webview2/.gitignore
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WebView/.gitignore
rename to libs/cua-driver/test-harness/apps/windows/webview2/.gitignore
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WebView/App.xaml b/libs/cua-driver/test-harness/apps/windows/webview2/App.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WebView/App.xaml
rename to libs/cua-driver/test-harness/apps/windows/webview2/App.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WebView/App.xaml.cs b/libs/cua-driver/test-harness/apps/windows/webview2/App.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WebView/App.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/webview2/App.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WebView/CuaTestHarness.WebView.csproj b/libs/cua-driver/test-harness/apps/windows/webview2/CuaTestHarness.WebView.csproj
similarity index 91%
rename from libs/cua-driver/test-harness/CuaTestHarness.WebView/CuaTestHarness.WebView.csproj
rename to libs/cua-driver/test-harness/apps/windows/webview2/CuaTestHarness.WebView.csproj
index 09d73533f5..62642fd635 100644
--- a/libs/cua-driver/test-harness/CuaTestHarness.WebView/CuaTestHarness.WebView.csproj
+++ b/libs/cua-driver/test-harness/apps/windows/webview2/CuaTestHarness.WebView.csproj
@@ -20,7 +20,7 @@
</ItemGroup>
<ItemGroup>
- <None Include="..\shared-web\index.html" Link="web\index.html">
+ <None Include="..\..\..\shared\web\index.html" Link="web\index.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WebView/MainWindow.xaml b/libs/cua-driver/test-harness/apps/windows/webview2/MainWindow.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WebView/MainWindow.xaml
rename to libs/cua-driver/test-harness/apps/windows/webview2/MainWindow.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WebView/MainWindow.xaml.cs b/libs/cua-driver/test-harness/apps/windows/webview2/MainWindow.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WebView/MainWindow.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/webview2/MainWindow.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WebView/app.manifest b/libs/cua-driver/test-harness/apps/windows/webview2/app.manifest
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WebView/app.manifest
rename to libs/cua-driver/test-harness/apps/windows/webview2/app.manifest
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WinUI3/App.xaml b/libs/cua-driver/test-harness/apps/windows/winui3/App.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WinUI3/App.xaml
rename to libs/cua-driver/test-harness/apps/windows/winui3/App.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WinUI3/App.xaml.cs b/libs/cua-driver/test-harness/apps/windows/winui3/App.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WinUI3/App.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/winui3/App.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WinUI3/CuaTestHarness.WinUI3.csproj b/libs/cua-driver/test-harness/apps/windows/winui3/CuaTestHarness.WinUI3.csproj
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WinUI3/CuaTestHarness.WinUI3.csproj
rename to libs/cua-driver/test-harness/apps/windows/winui3/CuaTestHarness.WinUI3.csproj
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WinUI3/MainWindow.xaml b/libs/cua-driver/test-harness/apps/windows/winui3/MainWindow.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WinUI3/MainWindow.xaml
rename to libs/cua-driver/test-harness/apps/windows/winui3/MainWindow.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WinUI3/MainWindow.xaml.cs b/libs/cua-driver/test-harness/apps/windows/winui3/MainWindow.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WinUI3/MainWindow.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/winui3/MainWindow.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WinUI3/Program.cs b/libs/cua-driver/test-harness/apps/windows/winui3/Program.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WinUI3/Program.cs
rename to libs/cua-driver/test-harness/apps/windows/winui3/Program.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.WinUI3/app.manifest b/libs/cua-driver/test-harness/apps/windows/winui3/app.manifest
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.WinUI3/app.manifest
rename to libs/cua-driver/test-harness/apps/windows/winui3/app.manifest
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/App.xaml b/libs/cua-driver/test-harness/apps/windows/wpf/App.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/App.xaml
rename to libs/cua-driver/test-harness/apps/windows/wpf/App.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/App.xaml.cs b/libs/cua-driver/test-harness/apps/windows/wpf/App.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/App.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/wpf/App.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/CuaTestHarness.Wpf.csproj b/libs/cua-driver/test-harness/apps/windows/wpf/CuaTestHarness.Wpf.csproj
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/CuaTestHarness.Wpf.csproj
rename to libs/cua-driver/test-harness/apps/windows/wpf/CuaTestHarness.Wpf.csproj
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/LayeredPopupWindow.xaml b/libs/cua-driver/test-harness/apps/windows/wpf/LayeredPopupWindow.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/LayeredPopupWindow.xaml
rename to libs/cua-driver/test-harness/apps/windows/wpf/LayeredPopupWindow.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/LayeredPopupWindow.xaml.cs b/libs/cua-driver/test-harness/apps/windows/wpf/LayeredPopupWindow.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/LayeredPopupWindow.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/wpf/LayeredPopupWindow.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/MainWindow.xaml b/libs/cua-driver/test-harness/apps/windows/wpf/MainWindow.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/MainWindow.xaml
rename to libs/cua-driver/test-harness/apps/windows/wpf/MainWindow.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/MainWindow.xaml.cs b/libs/cua-driver/test-harness/apps/windows/wpf/MainWindow.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/MainWindow.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/wpf/MainWindow.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/NativeButtonHost.cs b/libs/cua-driver/test-harness/apps/windows/wpf/NativeButtonHost.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/NativeButtonHost.cs
rename to libs/cua-driver/test-harness/apps/windows/wpf/NativeButtonHost.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/OwnedPopupWindow.xaml b/libs/cua-driver/test-harness/apps/windows/wpf/OwnedPopupWindow.xaml
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/OwnedPopupWindow.xaml
rename to libs/cua-driver/test-harness/apps/windows/wpf/OwnedPopupWindow.xaml
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/OwnedPopupWindow.xaml.cs b/libs/cua-driver/test-harness/apps/windows/wpf/OwnedPopupWindow.xaml.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/OwnedPopupWindow.xaml.cs
rename to libs/cua-driver/test-harness/apps/windows/wpf/OwnedPopupWindow.xaml.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/Scenarios.cs b/libs/cua-driver/test-harness/apps/windows/wpf/Scenarios.cs
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/Scenarios.cs
rename to libs/cua-driver/test-harness/apps/windows/wpf/Scenarios.cs
diff --git a/libs/cua-driver/test-harness/CuaTestHarness.Wpf/app.manifest b/libs/cua-driver/test-harness/apps/windows/wpf/app.manifest
similarity index 100%
rename from libs/cua-driver/test-harness/CuaTestHarness.Wpf/app.manifest
rename to libs/cua-driver/test-harness/apps/windows/wpf/app.manifest
diff --git a/libs/cua-driver/test-harness/build/README.md b/libs/cua-driver/test-harness/build/README.md
new file mode 100644
index 0000000000..d7aa5cd09a
--- /dev/null
+++ b/libs/cua-driver/test-harness/build/README.md
@@ -0,0 +1,22 @@
+# test-harness build scripts
+
+Run `macos.sh` or `windows.ps1` to build every harness app for that host
+OS. Outputs are staged into `../../rust/test-apps/harness-<name>/` so
+the Rust integration tests and the Windows Sandbox runner pick them up
+unchanged.
+
+```bash
+# macOS — builds appkit + swiftui via xcrun swiftc into .app bundles
+./macos.sh
+
+# Windows — dotnet publish for wpf/winui3/webview2 + electron-builder for electron
+.\windows.ps1
+```
+
+Both scripts accept a `--skip` / `-Skip` argument to build one app at a
+time during local iteration; see the file headers for the full surface.
+
+Cross-platform Electron is built by `windows.ps1` today (which runs
+`apps/cross-platform/electron/build.ps1`). When a non-Windows test path
+needs the Electron host, lift the staging step into `macos.sh` (or
+`linux.sh`).
diff --git a/libs/cua-driver/test-harness/build.sh b/libs/cua-driver/test-harness/build/macos.sh
similarity index 82%
rename from libs/cua-driver/test-harness/build.sh
rename to libs/cua-driver/test-harness/build/macos.sh
index 558c56e3dd..07728fb0b9 100755
--- a/libs/cua-driver/test-harness/build.sh
+++ b/libs/cua-driver/test-harness/build/macos.sh
@@ -1,17 +1,18 @@
#!/usr/bin/env bash
# Build the macOS test-harness apps (AppKit + SwiftUI) into .app bundles
-# under ../rust/test-apps/harness-{appkit,swiftui}/ — matching the
-# convention used by build.ps1 for the Windows WPF + WinUI3 apps.
+# under ../../rust/test-apps/harness-{appkit,swiftui}/ — matching the
+# convention used by windows.ps1 for the Windows WPF + WinUI3 apps.
#
# Usage:
-# ./build.sh # build both
-# ./build.sh --skip swiftui # AppKit only
-# ./build.sh --skip appkit # SwiftUI only
-# ./build.sh --clean # remove staged outputs first
+# ./macos.sh # build both
+# ./macos.sh --skip swiftui # AppKit only
+# ./macos.sh --skip appkit # SwiftUI only
+# ./macos.sh --clean # remove staged outputs first
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-STAGE_DIR="$(cd "$SCRIPT_DIR/../rust/test-apps" && pwd)"
+HARNESS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
+STAGE_DIR="$(cd "$HARNESS_DIR/../rust/test-apps" && pwd)"
SKIP=""
CLEAN=0
@@ -76,14 +77,14 @@ EOF
if [[ "$SKIP" != "appkit" ]]; then
build_app "CuaTestHarness.AppKit" \
- "$SCRIPT_DIR/CuaTestHarness.AppKit" \
+ "$HARNESS_DIR/apps/macos/appkit" \
"" \
"harness-appkit"
fi
if [[ "$SKIP" != "swiftui" ]]; then
build_app "CuaTestHarness.SwiftUI" \
- "$SCRIPT_DIR/CuaTestHarness.SwiftUI" \
+ "$HARNESS_DIR/apps/macos/swiftui" \
"" \
"harness-swiftui"
fi
diff --git a/libs/cua-driver/test-harness/build.ps1 b/libs/cua-driver/test-harness/build/windows.ps1
similarity index 75%
rename from libs/cua-driver/test-harness/build.ps1
rename to libs/cua-driver/test-harness/build/windows.ps1
index 766d52677f..23e0f8127e 100644
--- a/libs/cua-driver/test-harness/build.ps1
+++ b/libs/cua-driver/test-harness/build/windows.ps1
@@ -1,14 +1,14 @@
-# build.ps1 - publish the cua-driver test harness binaries.
+# windows.ps1 - publish the cua-driver test harness binaries.
#
-# Outputs land in libs/cua-driver/rust/test-apps/harness-{wpf,winui3}/ so
-# the existing sandbox runner picks them up via its mapped folder.
+# Outputs land in libs/cua-driver/rust/test-apps/harness-{wpf,winui3,webview,electron}/
+# so the existing sandbox runner picks them up via its mapped folder.
#
# Usage:
-# .\build.ps1 # build both
-# .\build.ps1 -Skip wpf # build only WinUI3
-# .\build.ps1 -Skip winui3
+# .\windows.ps1 # build all Windows-runnable apps
+# .\windows.ps1 -Skip wpf # skip WPF
+# .\windows.ps1 -Skip winui3
#
-# Requires: .NET 8 SDK on PATH.
+# Requires: .NET 8 SDK on PATH (Node.js + npm for the Electron app).
param(
[ValidateSet("none","wpf","winui3","webview","electron")]
@@ -18,7 +18,8 @@ param(
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
-$harnessDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
+$buildDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
+$harnessDir = Split-Path -Parent $buildDir
$cuaDriverDir = Split-Path -Parent $harnessDir
$testAppsDir = Join-Path $cuaDriverDir "rust\test-apps"
@@ -53,10 +54,10 @@ function Publish-Project {
}
if ($Skip -ne "wpf") {
- Publish-Project (Join-Path $harnessDir "CuaTestHarness.Wpf\CuaTestHarness.Wpf.csproj") "harness-wpf"
+ Publish-Project (Join-Path $harnessDir "apps\windows\wpf\CuaTestHarness.Wpf.csproj") "harness-wpf"
}
if ($Skip -ne "winui3") {
- $winuiProj = Join-Path $harnessDir "CuaTestHarness.WinUI3\CuaTestHarness.WinUI3.csproj"
+ $winuiProj = Join-Path $harnessDir "apps\windows\winui3\CuaTestHarness.WinUI3.csproj"
if (Test-Path $winuiProj) {
Publish-Project $winuiProj "harness-winui3"
} else {
@@ -64,7 +65,7 @@ if ($Skip -ne "winui3") {
}
}
if ($Skip -ne "webview") {
- $webProj = Join-Path $harnessDir "CuaTestHarness.WebView\CuaTestHarness.WebView.csproj"
+ $webProj = Join-Path $harnessDir "apps\windows\webview2\CuaTestHarness.WebView.csproj"
if (Test-Path $webProj) {
Publish-Project $webProj "harness-webview"
} else {
@@ -72,10 +73,10 @@ if ($Skip -ne "webview") {
}
}
if ($Skip -ne "electron") {
- $elecBuild = Join-Path $harnessDir "CuaTestHarness.Electron\build.ps1"
+ $elecBuild = Join-Path $harnessDir "apps\cross-platform\electron\build.ps1"
if (Test-Path $elecBuild) {
Write-Host ""
- Write-Host "[BUILD] CuaTestHarness.Electron -> $testAppsDir\harness-electron\" -ForegroundColor Cyan
+ Write-Host "[BUILD] electron -> $testAppsDir\harness-electron\" -ForegroundColor Cyan
# Electron build sets $ErrorActionPreference=Stop internally and
# throws on npm install / publish failure. Wrap so a throw degrades
# to a warning rather than aborting the whole harness build.
diff --git a/libs/cua-driver/test-harness/scenarios/scenarios.json b/libs/cua-driver/test-harness/shared/scenarios.json
similarity index 98%
rename from libs/cua-driver/test-harness/scenarios/scenarios.json
rename to libs/cua-driver/test-harness/shared/scenarios.json
index fdadffda65..71e7139d05 100644
--- a/libs/cua-driver/test-harness/scenarios/scenarios.json
+++ b/libs/cua-driver/test-harness/shared/scenarios.json
@@ -182,7 +182,7 @@
"title": "CuaTestHarness WebView",
"automation_id": "wnd-main"
},
- "description": "WPF host with Microsoft.Edge.WebView2 control. Loads ../shared-web/index.html. Exposes Chromium DevTools Protocol at default_cdp_port for cua-driver's `page` tool.",
+ "description": "WPF host with Microsoft.Edge.WebView2 control. Loads shared/web/index.html. Exposes Chromium DevTools Protocol at default_cdp_port for cua-driver's `page` tool.",
"shared_dom_aids": [
"btn-increment", "btn-reset", "lbl-counter",
"txt-input", "lbl-input-mirror",
@@ -200,7 +200,7 @@
"main_window": {
"title": "CuaTestHarness Electron"
},
- "description": "Electron host loading the same ../shared-web/index.html as the WebView harness. Exposes CDP at default_cdp_port via --remote-debugging-port."
+ "description": "Electron host loading the same shared/web/index.html as the WebView harness. Exposes CDP at default_cdp_port via --remote-debugging-port."
},
"winui3": {
"process_name": "CuaTestHarness.WinUI3",
diff --git a/libs/cua-driver/test-harness/shared-web/index.html b/libs/cua-driver/test-harness/shared/web/index.html
similarity index 100%
rename from libs/cua-driver/test-harness/shared-web/index.html
rename to libs/cua-driver/test-harness/shared/web/index.html
diff --git a/libs/cua-driver/test-harness/smoke/README.md b/libs/cua-driver/test-harness/smoke/README.md
new file mode 100644
index 0000000000..f6ab8598ff
--- /dev/null
+++ b/libs/cua-driver/test-harness/smoke/README.md
@@ -0,0 +1,28 @@
+# test-harness CLI smoke runners
+
+Per-OS broad PASS / FAIL / SKIP probes across the full cua-driver tool
+surface. Complements the Rust integration tests under `../../rust/crates/cua-driver/tests/`:
+
+- Integration tests drive cua-driver through the MCP stdio loop and
+ assert on specific UIA / AX state changes.
+- Smoke runners drive cua-driver through the CLI (`cua-driver call
+ <tool> <json>`) — different code path (CLI argument parser + tool
+ resolution), one broad sweep across every registered tool in ~30 sec.
+
+| File | Host OS | What it runs |
+|-------------------|----------|----------------------------------------------------------------|
+| `macos.sh` | macOS | Spawns the AppKit harness, calls every tool once |
+
+Each script checks in a baseline result file under `results/` for the
+current driver version — diff against it to catch regressions in tool
+coverage:
+
+```bash
+./macos.sh > /tmp/run.txt
+diff results/macos.txt /tmp/run.txt
+```
+
+Prereqs (macOS):
+- `../build/macos.sh` must have produced `../../rust/test-apps/harness-appkit/`
+- `../../rust/target/release/cua-driver` built (debug works too)
+- TCC Accessibility granted to the cua-driver binary
diff --git a/scripts/mac-smoke.sh b/libs/cua-driver/test-harness/smoke/macos.sh
similarity index 95%
rename from scripts/mac-smoke.sh
rename to libs/cua-driver/test-harness/smoke/macos.sh
index c1b693ae84..fdf9caba20 100755
--- a/scripts/mac-smoke.sh
+++ b/libs/cua-driver/test-harness/smoke/macos.sh
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
# macOS cua-driver per-tool smoke test.
#
-# Spawns the AppKit harness app from libs/cua-driver/test-harness, runs
-# every cua-driver tool against it with sensible JSON args, and reports
+# Spawns the built AppKit harness app from libs/cua-driver/rust/test-apps/harness-appkit
+# (source lives under libs/cua-driver/test-harness/apps/macos),
+# runs every cua-driver tool against it with sensible JSON args, and reports
# PASS / FAIL / SKIP in a sorted table.
#
# Mirror of scripts/linux-smoke.sh — same shape, classified the same way.
@@ -13,14 +14,14 @@
# surface in ~30 seconds.
#
# Prereqs:
-# - libs/cua-driver/test-harness/build.sh must have been run
+# - libs/cua-driver/test-harness/build/macos.sh must have been run
# - cua-driver binary built (this script uses target/release if present)
# - TCC Accessibility permission granted to the cua-driver binary
# (otherwise AX-using tools return empty trees, which scores as PASS
# because the call exits cleanly — flagged in output)
set -u
-ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd)"
DRIVER="$ROOT/libs/cua-driver/rust/target/release/cua-driver"
[[ -x "$DRIVER" ]] || DRIVER="$ROOT/libs/cua-driver/rust/target/debug/cua-driver"
HARNESS_APP="$ROOT/libs/cua-driver/rust/test-apps/harness-appkit/CuaTestHarness.AppKit.app"
@@ -78,7 +79,7 @@ fi
if [[ ! -x "$HARNESS_EXE" ]]; then
echo "ERROR: AppKit harness not built at $HARNESS_EXE" >&2
- echo " Run: libs/cua-driver/test-harness/build.sh" >&2
+ echo " Run: libs/cua-driver/test-harness/build/macos.sh" >&2
exit 1
fi
diff --git a/scripts/mac-smoke-RESULTS.txt b/libs/cua-driver/test-harness/smoke/results/macos.txt
similarity index 100%
rename from scripts/mac-smoke-RESULTS.txt
rename to libs/cua-driver/test-harness/smoke/results/macos.txt