-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Summary
This issue tracks adding #[cfg(test)] test coverage to three currently untested files in the tool and snapping systems. These are good starting points for GSoC test coverage work, as they follow the same pattern already established in ellipse_shape.rs and line_shape.rs.
Files to Test
1. editor/src/messages/tool/common_functionality/shapes/polygon_shape.rs (~193 LOC)
What to test:
draw_polygon_simple— drag withToolType::Shape(polygon mode), assert vertex count and radiusdraw_polygon_square_ratio— drag withModifierKeys::SHIFT(lock ratio), assert equal dimensionsdraw_polygon_from_center— drag withModifierKeys::ALT, assert center origindraw_polygon_cancel_rmb— usedrag_tool_cancel_rmb, assert no layer createdpolygon_decrease_sides— assertdecrease_or_increase_sides(true, ...)clamps to minimum 3polygon_increase_sides— assert side count increments correctly
Reference pattern: ellipse_shape.rs (same file, same module structure)
2. editor/src/messages/tool/common_functionality/shapes/star_shape.rs (~172 LOC)
What to test:
draw_star_simple— drag to create star, assert outer/inner radius valuesdraw_star_square_ratio— withModifierKeys::SHIFTdraw_star_from_center— withModifierKeys::ALTdraw_star_cancel_rmb— assert no layer created on RMB cancel- Verify inner radius is set to
outer_radius / 2.0by default (Star::update_shapeline 161)
Reference pattern: Same as ellipse_shape.rs; use NodeGraphLayer::upstream_node_id_from_protonode with star::IDENTIFIER
3. editor/src/messages/tool/common_functionality/snapping/grid_snapper.rs (~181 LOC)
What to test:
rectangular_grid_snap_on_line— point exactly on a grid line snaps with distance ≈ 0rectangular_grid_snap_within_tolerance— point within tolerance snaps to nearest linerectangular_grid_no_snap_outside_tolerance— point beyond tolerance produces no snap resultisometric_grid_snap_vertical— snap to vertical lines in isometric gridisometric_grid_angle_lines— snap to angled lines (angle_a / angle_b)constrained_snap_to_grid_intersection— constrained snap hits grid line correctly
Test Infrastructure
All tests should use the existing EditorTestUtils helper:
#[cfg(test)]
mod test_polygon {
use crate::test_utils::test_prelude::*;
// ...
#[tokio::test]
async fn draw_polygon_simple() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Shape, 10., 10., 50., 50., ModifierKeys::empty()).await;
// assert layer count, vertex count, radius etc.
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels