@@ -345,6 +345,8 @@ fn extend_path_with_next_segment(tool_data: &mut FreehandToolData, position: DVe
345
345
mod test_freehand {
346
346
use crate :: messages:: input_mapper:: utility_types:: input_mouse:: { EditorMouseState , MouseKeys , ScrollDelta } ;
347
347
use crate :: messages:: portfolio:: document:: graph_operation:: utility_types:: TransformIn ;
348
+ use crate :: messages:: tool:: common_functionality:: graph_modification_utils:: get_stroke_width;
349
+ use crate :: messages:: tool:: tool_messages:: freehand_tool:: FreehandOptionsUpdate ;
348
350
use crate :: test_utils:: test_prelude:: * ;
349
351
use glam:: { DAffine2 , DVec2 } ;
350
352
use graphene_core:: vector:: VectorData ;
@@ -681,4 +683,54 @@ mod test_freehand {
681
683
initial_segment_count + expected_new_segments
682
684
) ;
683
685
}
686
+
687
+ #[ tokio:: test]
688
+ async fn test_line_weight_affects_stroke_width ( ) {
689
+ let mut editor = EditorTestUtils :: create ( ) ;
690
+ editor. new_document ( ) . await ;
691
+
692
+ editor. select_tool ( ToolType :: Freehand ) . await ;
693
+
694
+ let custom_line_weight = 5.0 ;
695
+ editor
696
+ . handle_message ( ToolMessage :: Freehand ( FreehandToolMessage :: UpdateOptions ( FreehandOptionsUpdate :: LineWeight ( custom_line_weight) ) ) )
697
+ . await ;
698
+
699
+ let points = [ DVec2 :: new ( 100.0 , 100.0 ) , DVec2 :: new ( 200.0 , 200.0 ) , DVec2 :: new ( 300.0 , 100.0 ) ] ;
700
+
701
+ let first_point = points[ 0 ] ;
702
+ editor. move_mouse ( first_point. x , first_point. y , ModifierKeys :: empty ( ) , MouseKeys :: empty ( ) ) . await ;
703
+ editor. left_mousedown ( first_point. x , first_point. y , ModifierKeys :: empty ( ) ) . await ;
704
+
705
+ for & point in & points[ 1 ..] {
706
+ editor. move_mouse ( point. x , point. y , ModifierKeys :: empty ( ) , MouseKeys :: LEFT ) . await ;
707
+ }
708
+
709
+ let last_point = points[ points. len ( ) - 1 ] ;
710
+ editor
711
+ . mouseup (
712
+ EditorMouseState {
713
+ editor_position : last_point,
714
+ mouse_keys : MouseKeys :: empty ( ) ,
715
+ scroll_delta : ScrollDelta :: default ( ) ,
716
+ } ,
717
+ ModifierKeys :: empty ( ) ,
718
+ )
719
+ . await ;
720
+
721
+ let document = editor. active_document ( ) ;
722
+ let layer = document. metadata ( ) . all_layers ( ) . next ( ) . unwrap ( ) ;
723
+
724
+ let stroke_width = get_stroke_width ( layer, & document. network_interface ) ;
725
+
726
+ assert ! ( stroke_width. is_some( ) , "Stroke width should be available on the created path" ) ;
727
+
728
+ assert_eq ! (
729
+ stroke_width. unwrap( ) ,
730
+ custom_line_weight,
731
+ "Stroke width should match the custom line weight (expected {}, got {})" ,
732
+ custom_line_weight,
733
+ stroke_width. unwrap( )
734
+ ) ;
735
+ }
684
736
}
0 commit comments