Add tests for auto-panning - #2597
Conversation
|
@0HyperCube PTAL! |
|
@0HyperCube Can you review the select tool part for this PR. I will add other tests soon! Thanks :) |
@0HyperCube PTAL! |
|
Please mark as ready to review. |
I am marking this as ready to review! |
|
@0HyperCube !!! |
0HyperCube
left a comment
There was a problem hiding this comment.
Thanks for the contribution so far.
However the code is overly verbose and the checks are rather dubious.
| // Moving cursor outside viewport to trigger auto-panning | ||
| editor.move_mouse(2000., 100., ModifierKeys::empty(), MouseKeys::LEFT).await; | ||
|
|
||
| let pointer_keys = SelectToolPointerKeys { | ||
| axis_align: Key::Shift, | ||
| snap_angle: Key::Control, | ||
| center: Key::Alt, | ||
| duplicate: Key::Alt, | ||
| }; | ||
|
|
||
| // Sending multiple outside viewport events to simulate continuous auto-panning | ||
| for _ in 0..5 { | ||
| editor.handle_message(SelectToolMessage::PointerOutsideViewport(pointer_keys.clone())).await; | ||
| } | ||
|
|
||
| editor | ||
| .mouseup( | ||
| EditorMouseState { | ||
| editor_position: DVec2::new(2000., 100.), | ||
| mouse_keys: MouseKeys::empty(), | ||
| scroll_delta: ScrollDelta::default(), | ||
| }, | ||
| ModifierKeys::empty(), | ||
| ) | ||
| .await; |
There was a problem hiding this comment.
Please make a function instead of duplicating so much code.
| let scale_ratio = final_scale / initial_scale; | ||
|
|
||
| assert!( | ||
| scale_ratio > 1.1 || scale_ratio < 0.9, |
There was a problem hiding this comment.
Why can you not determine what happens to the scale? Surely the scale should increase.
|
|
||
| // Comparing transform matrices to detect scale changes | ||
| let initial_scale = initial_transform.matrix2.determinant().sqrt(); | ||
| let final_scale = final_transform.matrix2.determinant().sqrt(); |
There was a problem hiding this comment.
You have assumed that the scale is uniform. Please justify this in a comment.
| mouse_keys: MouseKeys::empty(), | ||
| scroll_delta: ScrollDelta::default(), |
There was a problem hiding this comment.
you can just to ..Default::default()
| assert!(!artboards.is_empty(), "Artboard should have been created"); | ||
| assert!( | ||
| artboards[0].dimensions.x > 200, | ||
| "Artboard should have significant width due to auto-panning: {}", |
There was a problem hiding this comment.
What led you to decide that this was «significant». Please justify in a comment.
| assert!(!artboards.is_empty(), "Artboard should have been created"); | ||
| let initial_location = artboards[0].location; | ||
|
|
||
| editor.select_tool(ToolType::Artboard).await; |
There was a problem hiding this comment.
Artboard is already selected.
|
|
||
| // This test is marked as ignored due to inconsistent behavior when run as part of the test suite. | ||
| // It passes when run individually but frequently fails when run with other tests. | ||
| // The issue appears to be related to difficulty consistently capturing resize handles with mouse events |
There was a problem hiding this comment.
Please elaborate further.
|
Hi, are you interested in continuing this or should I close it as incomplete? Thanks! |
This pull request introduces automated tests for the auto-panning functionality.
Currently implemented:
Closes #2505