From 6cafa1e3ac2a7a65d02790942f5ee85977b947f0 Mon Sep 17 00:00:00 2001 From: gianlucafiore <50465150+gianlucafiore@users.noreply.github.com> Date: Fri, 16 Oct 2026 17:00:24 -0300 Subject: [PATCH] test(selection): cover quick click boxes and intentional held lasso --- src/app/automation.rs | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/app/automation.rs b/src/app/automation.rs index 1524e09c9..60cc46846 100644 --- a/src/app/automation.rs +++ b/src/app/automation.rs @@ -3552,7 +3552,17 @@ mod tests { path[0].0, path[0].1, ))); let _ = app.update(Message::ViewportLeftPress); - std::thread::sleep(std::time::Duration::from_millis(180)); + // Deterministically simulate an intentional hold-to-lasso. + // A fast click+move must no longer activate a lasso just + // because the cursor crossed the old 24 px shortcut. + app.tabs[i] + .scene + .selection + .borrow_mut() + .input + .left_press_time = Some( + iced::time::Instant::now() - std::time::Duration::from_millis(260), + ); for &(x, y) in &path { let _ = app.update(Message::ViewportMove(iced::Point::new(x, y))); } @@ -3586,6 +3596,32 @@ mod tests { } } + #[test] + fn fast_click_move_release_arms_a_box_at_the_actual_press_location() { + use crate::app::Message; + + let mut app = OpenCADStudio::new_for_test(); + app.automation_op(r#"{"op":"new"}"#); + let i = app.active_tab; + app.pick_drag_rect = false; + app.tabs[i].scene.selection.borrow_mut().view.vp_size = (800.0, 600.0); + + let pressed = iced::Point::new(100.0, 180.0); + let moved = iced::Point::new(450.0, 350.0); + let _ = app.update(Message::ViewportMove(pressed)); + let _ = app.update(Message::ViewportLeftPress); + let _ = app.update(Message::ViewportMove(moved)); + { + let sel = app.tabs[i].scene.selection.borrow(); + assert!(!sel.input.left_dragging, "fast first click must win over lasso"); + assert!(!sel.gesture.poly_active, "the lasso must not arm"); + } + let _ = app.update(Message::ViewportLeftRelease); + let sel = app.tabs[i].scene.selection.borrow(); + assert_eq!(sel.gesture.box_anchor, Some(pressed)); + assert!(!sel.gesture.poly_active); + } + #[test] fn pickadd_command_flips_flag() { let mut app = OpenCADStudio::new_for_test();