-
-
Notifications
You must be signed in to change notification settings - Fork 577
Add tests for auto-panning #2597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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 !!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please elaborate further.
This pull request introduces automated tests for the auto-panning functionality.
Currently implemented:
Closes #2505