Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
test(cua-driver): prune redundant cursor overlay tests (#4110)
Francesco Bonaccic30f52598494
diff --git a/libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rs b/libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rsindex e0300b06a4..72a3470f71 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rs@@ -21,16 +21,6 @@ struct GalleryState {session_label: Option<&'static str>,}-#[cfg(test)]-fn runtime_state() -> GalleryState {- GalleryState {- action: CursorAction::Observe,- delivery: Some(DeliveryModifier::Background),- target: Some(TargetModifier::Browser),- session_label: Some(RUNTIME_SESSION_LABEL),- }-}-const DELIVERIES: [Option<DeliveryModifier>; 3] = [None,Some(DeliveryModifier::Background),@@ -177,20 +167,14 @@ fn export_state(output: &Path, state: GalleryState) {mod tests {use super::*;- #[test]- fn runtime_preview_uses_the_complete_production_composition() {- let state = runtime_state();- assert_eq!(state.action, CursorAction::Observe);- assert_eq!(state.delivery, Some(DeliveryModifier::Background));- assert_eq!(state.target, Some(TargetModifier::Browser));- assert_eq!(state.session_label, Some(RUNTIME_SESSION_LABEL));- }-#[test]fn preview_inventory_covers_every_runtime_combination_once() {let root = Path::new("gallery");let states = preview_states(root);- assert_eq!(states.len(), 12 * 3 * 5);+ assert_eq!(+ states.len(),+ CursorAction::ALL.len() * DELIVERIES.len() * TARGETS.len()+ );let slugs = states.iter()diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rsindex 493656b5b9..0e2f2835f2 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/lib.rs@@ -15,7 +15,6 @@ pub mod render_state;pub mod session_badge;pub mod theme;pub mod theme_artifact;-pub mod util;pub mod z_order;pub use badge_glyphs::{BadgeChip, BadgeGlyph};@@ -447,8 +446,10 @@ mod pointer_tracking_tests {else {panic!("pointer tracking must produce an anchored snap");};- assert!((x - (120.0 + heading.cos() * 16.0)).abs() < f64::EPSILON);- assert!((y - (80.0 + heading.sin() * 16.0)).abs() < f64::EPSILON);+ // The artwork centre sits 16 points down-right of the tip at 45 degrees.+ assert_eq!(heading, std::f64::consts::FRAC_PI_4);+ assert!((x - 131.313_708_498_984_76).abs() < 1e-9, "x = {x}");+ assert!((y - 91.313_708_498_984_76).abs() < 1e-9, "y = {y}");}#[test]diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rsindex d217c09e6a..e00ca4502c 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs@@ -1124,36 +1124,53 @@ mod session_badge_and_action_tests {}#[test]- fn movement_preserves_the_active_semantic_action() {- let mut core = RenderStateCore::new(CursorConfig::default());- core.pos = (20.0, 20.0);- core.apply_command_base(- OverlayCommand::BeginAction {- action: CursorAction::Text,- delivery: None,- target: Some(TargetModifier::Ax),- },- false,- false,- );- core.apply_command_base(- OverlayCommand::MoveTo {- x: 200.0,- y: 100.0,- end_heading_radians: 0.0,- },- false,- false,- );- assert_eq!(core.visual.resolved_action, CursorAction::Text);- assert_eq!(core.visual.target, Some(TargetModifier::Ax));- core.apply_command_base(- OverlayCommand::ClickPulse { x: 200.0, y: 100.0 },- false,- false,- );- assert_eq!(core.visual.resolved_action, CursorAction::Text);- assert_eq!(core.visual.target, Some(TargetModifier::Ax));+ fn movement_and_click_pulse_preserve_the_active_semantic_context() {+ // Text keeps its action through a pulse; Click re-begins itself and+ // must carry the declared delivery and target across that restart.+ for action in [CursorAction::Text, CursorAction::Click] {+ let mut core = RenderStateCore::new(CursorConfig::default());+ core.pos = (20.0, 20.0);+ core.apply_command_base(+ OverlayCommand::BeginAction {+ action,+ delivery: Some(DeliveryModifier::Background),+ target: Some(TargetModifier::Ax),+ },+ false,+ false,+ );+ core.apply_command_base(+ OverlayCommand::MoveTo {+ x: 200.0,+ y: 100.0,+ end_heading_radians: 0.0,+ },+ false,+ false,+ );+ assert_eq!(core.visual.resolved_action, action);+ assert_eq!(+ (core.visual.delivery, core.visual.target),+ (Some(DeliveryModifier::Background), Some(TargetModifier::Ax)),+ "{action:?} after move"+ );+ core.apply_command_base(+ OverlayCommand::ClickPulse { x: 200.0, y: 100.0 },+ false,+ false,+ );+ assert_eq!(core.visual.resolved_action, action);+ assert_eq!(+ (core.visual.delivery, core.visual.target),+ (Some(DeliveryModifier::Background), Some(TargetModifier::Ax)),+ "{action:?} after click pulse"+ );+ assert_eq!(+ core.badge_modifiers,+ Some((Some(DeliveryModifier::Background), Some(TargetModifier::Ax))),+ "{action:?} badge context"+ );+ }}#[test]@@ -1223,33 +1240,6 @@ mod session_badge_and_action_tests {assert_eq!(core.badge_modifier_fade_secs, None);assert_eq!(core.session_badge_chip_alpha(), 1.0);}-- #[test]- fn click_pulse_preserves_declared_context_until_the_action_fades() {- let mut core = RenderStateCore::new(CursorConfig::default());- core.apply_command_base(- OverlayCommand::BeginAction {- action: CursorAction::Click,- delivery: Some(DeliveryModifier::Background),- target: Some(TargetModifier::Ax),- },- false,- false,- );- core.apply_command_base(- OverlayCommand::ClickPulse { x: 40.0, y: 60.0 },- false,- false,- );- assert_eq!(- (core.visual.delivery, core.visual.target),- (Some(DeliveryModifier::Background), Some(TargetModifier::Ax))- );- assert_eq!(- core.badge_modifiers,- Some((Some(DeliveryModifier::Background), Some(TargetModifier::Ax)))- );- }}#[cfg(test)]diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/session_badge.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/session_badge.rsindex b37a2c8576..be9147bd66 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/session_badge.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/session_badge.rs@@ -585,9 +585,12 @@ mod tests {}#[test]- fn badge_paints_at_one_and_two_x_backing_scales() {+ fn badge_gradient_tracks_session_color_and_zero_alpha_paints_nothing() {for scale in [1.0, 2.0] {- let mut pixmap = Pixmap::new((240.0 * scale) as u32, (160.0 * scale) as u32).unwrap();+ let (width, height) = ((240.0 * scale) as u32, (160.0 * scale) as u32);+ let mut blue = Pixmap::new(width, height).unwrap();+ let mut purple = Pixmap::new(width, height).unwrap();+ let mut hidden = Pixmap::new(width, height).unwrap();let layout = session_badge_layout(SessionBadgeInput {label: Some("Research run"),delivery: Some(DeliveryModifier::Foreground),@@ -596,35 +599,41 @@ mod tests {backing_scale: scale,label_alpha: 1.0,chip_alpha: 1.0,- clip: Some((pixmap.width() as f32, pixmap.height() as f32)),+ clip: Some((width as f32, height as f32)),}).unwrap();- paint_session_badge(&mut pixmap, &layout, [94, 192, 232, 255], 1.0);- assert!(pixmap.data().chunks_exact(4).any(|pixel| pixel[3] > 0));- }- }+ paint_session_badge(&mut blue, &layout, [94, 192, 232, 255], 1.0);+ paint_session_badge(&mut purple, &layout, [178, 132, 255, 255], 1.0);+ paint_session_badge(&mut hidden, &layout, [94, 192, 232, 255], 0.0);+ assert!(+ blue.data().chunks_exact(4).any(|pixel| pixel[3] > 0),+ "badge paints at {scale}x"+ );+ assert_ne!(blue.data(), purple.data(), "{scale}x");+ assert!(+ hidden.data().chunks_exact(4).all(|pixel| pixel[3] == 0),+ "{scale}x"+ );- #[test]- fn badge_gradient_tracks_session_color_and_zero_alpha_paints_nothing() {- let mut blue = Pixmap::new(240, 160).unwrap();- let mut purple = Pixmap::new(240, 160).unwrap();- let mut hidden = Pixmap::new(240, 160).unwrap();- let layout = session_badge_layout(SessionBadgeInput {- label: Some("Research run"),- delivery: None,- target: None,- cursor: (120.0, 60.0),- backing_scale: 1.0,- label_alpha: 1.0,- chip_alpha: 0.0,- clip: Some((240.0, 160.0)),- })- .unwrap();- paint_session_badge(&mut blue, &layout, [94, 192, 232, 255], 1.0);- paint_session_badge(&mut purple, &layout, [178, 132, 255, 255], 1.0);- paint_session_badge(&mut hidden, &layout, [94, 192, 232, 255], 0.0);- assert_ne!(blue.data(), purple.data());- assert!(hidden.data().chunks_exact(4).all(|pixel| pixel[3] == 0));+ // Without chips, only the pill paints, so the session colour must+ // tint the pill itself rather than just the chips.+ let pill_only = session_badge_layout(SessionBadgeInput {+ label: Some("Research run"),+ delivery: None,+ target: None,+ cursor: (120.0 * scale, 60.0 * scale),+ backing_scale: scale,+ label_alpha: 1.0,+ chip_alpha: 0.0,+ clip: Some((width as f32, height as f32)),+ })+ .unwrap();+ let mut pill_blue = Pixmap::new(width, height).unwrap();+ let mut pill_purple = Pixmap::new(width, height).unwrap();+ paint_session_badge(&mut pill_blue, &pill_only, [94, 192, 232, 255], 1.0);+ paint_session_badge(&mut pill_purple, &pill_only, [178, 132, 255, 255], 1.0);+ assert_ne!(pill_blue.data(), pill_purple.data(), "pill {scale}x");+ }}#[test]diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rsindex d84cb08fab..e9d606916c 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/theme.rs@@ -249,15 +249,6 @@ pub fn paint_default_theme_with_fill(mod tests {use super::*;- #[test]- fn full_profile_has_twelve_unique_actions() {- let mut names = std::collections::BTreeSet::new();- for action in CursorAction::ALL {- assert!(names.insert(action.as_str()));- }- assert_eq!(names.len(), 12);- }-#[test]fn default_theme_uses_compact_42_point_footprint() {assert_eq!(DISPLAY_SIZE, 42.0);diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rsindex e3b5ae415d..fbd7f57c8d 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/theme_artifact.rs@@ -923,16 +923,4 @@ mod tests {let expected: [u8; 32] = Sha256::digest(source).into();assert_eq!(embedded_default_theme().source_hash, expected);}-- #[test]- fn default_tint_preserves_white_and_replaces_blue() {- assert_eq!(- resolved_color([94, 192, 232, 255], Some([12, 34, 56, 255])),- [12, 34, 56, 255]- );- assert_eq!(- resolved_color([255, 255, 255, 255], Some([12, 34, 56, 255])),- [255, 255, 255, 255]- );- }}diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/util.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/util.rsdeleted file mode 100644index 7cf6ebbbeb..0000000000--- a/libs/cua-driver/rust/crates/cursor-overlay/src/util.rs+++ /dev/null@@ -1,57 +0,0 @@-//! Tiny shared utilities for per-OS overlay renderers.-//!-//! These were duplicated verbatim in `platform-windows/src/overlay.rs` and-//! `platform-linux/src/overlay.rs`. Centralising them here keeps the math-//! truth in one place + lets future ports (Wayland-native, X11 v2, etc.)-//! reuse the same primitives without re-deriving them.--/// Rotate the `current` angle toward `desired` by at most `max_step` radians-/// per call, normalising both inputs to (-π, π].-///-/// Used by the per-OS overlay render loops to ease the cursor's heading-/// toward its planned-path tangent without instant snap. Both Windows + Linux-/// renderers want identical semantics here — exact constants matter because-/// the easing rate is tuned against the same Motion config knobs.-pub fn rotate_toward(current: f64, desired: f64, max_step: f64) -> f64 {- let mut diff = desired - current;- while diff > std::f64::consts::PI {- diff -= 2.0 * std::f64::consts::PI;- }- while diff < -std::f64::consts::PI {- diff += 2.0 * std::f64::consts::PI;- }- current + diff.clamp(-max_step, max_step)-}--#[cfg(test)]-mod tests {- use super::*;- const PI: f64 = std::f64::consts::PI;-- #[test]- fn no_motion_when_aligned() {- assert_eq!(rotate_toward(0.5, 0.5, 0.1), 0.5);- }-- #[test]- fn clamps_to_max_step() {- // desired is +1.0 ahead, max_step = 0.1, so we only move 0.1- assert!((rotate_toward(0.0, 1.0, 0.1) - 0.1).abs() < 1e-12);- }-- #[test]- fn picks_short_way_around() {- // current = 0.95π, desired = -0.95π (almost a full rotation away).- // Short way is +0.1π (across the wrap), NOT -1.9π.- let out = rotate_toward(0.95 * PI, -0.95 * PI, 0.5);- // We expect motion in the POSITIVE direction (forward wrap).- assert!(out > 0.95 * PI, "expected positive motion, got {}", out);- }-- #[test]- fn negative_direction_when_shorter() {- // current = -0.95π, desired = 0.95π — short way is the negative wrap.- let out = rotate_toward(-0.95 * PI, 0.95 * PI, 0.5);- assert!(out < -0.95 * PI, "expected negative motion, got {}", out);- }-}diff --git a/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rs b/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rsindex b9f385a527..d0aae9ad73 100644--- a/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rs+++ b/libs/cua-driver/rust/crates/cursor-theme-cli/src/main.rs@@ -959,21 +959,6 @@ mod tests {assert_eq!(&straight[4..], &[0, 0, 0, 0]);}- #[test]- fn usage_lists_every_management_command() {- for command in [- "validate",- "build",- "inspect",- "preview",- "install",- "list",- "uninstall",- ] {- assert!(usage().contains(command));- }- }-fn source_archive(standard_id: &str, variants: &str) -> tempfile::NamedTempFile {source_archive_with_schema(standard_id, variants, "cua.cursor-theme/2")}