test(selection): cover quick click boxes and intentional held lasso

This commit is contained in:
gianlucafiore committed 2026-10-16 17:00:24 -03:00
1 parent afb2585468
commit 6cafa1e3ac
1 file changed
+37 -1
+37 -1
View File
@@ -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();