Add tests for the Freehand tool (#2599)

* Add tests for freehand tool

* add test: line weight affects stroke width

* refactor
This commit is contained in:
Sidharth-Singh10
2025-05-01 01:23:59 +05:30
committed by GitHub
parent 1a81e45673
commit 2fc4896d01
2 changed files with 405 additions and 0 deletions

View File

@@ -240,6 +240,7 @@ impl EditorTestUtils {
self.press(Key::Enter, ModifierKeys::empty()).await;
}
pub async fn get_selected_layer(&mut self) -> Option<LayerNodeIdentifier> {
self.active_document().network_interface.selected_nodes().selected_layers(self.active_document().metadata()).next()
}
@@ -255,6 +256,30 @@ impl EditorTestUtils {
})
.await;
}
pub async fn drag_path(&mut self, points: &[DVec2], modifier_keys: ModifierKeys) {
if points.is_empty() {
return;
}
let first_point = points[0];
self.move_mouse(first_point.x, first_point.y, modifier_keys, MouseKeys::empty()).await;
self.left_mousedown(first_point.x, first_point.y, modifier_keys).await;
for &point in &points[1..] {
self.move_mouse(point.x, point.y, modifier_keys, MouseKeys::LEFT).await;
}
self.mouseup(
EditorMouseState {
editor_position: points[points.len() - 1],
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDelta::default(),
},
modifier_keys,
)
.await;
}
}
pub trait FrontendMessageTestUtils {