@@ -1376,4 +1376,89 @@ mod test_transform_layer {
13761376 let final_child_transform = get_layer_transform ( & mut editor, child_layer_id) . await . unwrap ( ) ;
13771377 assert ! ( !final_child_transform. abs_diff_eq( original_child_transform, 1e-5 ) , "Child layer inside transformed group should change" ) ;
13781378 }
1379+
1380+ #[ tokio:: test]
1381+ async fn test_artboard_gs_operations ( ) {
1382+ let mut editor = EditorTestUtils :: create ( ) ;
1383+ editor. new_document ( ) . await ;
1384+
1385+ // Create an artboard using the Artboard tool (mirroring existing artboard tests)
1386+ editor. drag_tool ( ToolType :: Artboard , 0. , 0. , 100. , 100. , ModifierKeys :: empty ( ) ) . await ;
1387+ editor. handle_message ( ToolMessage :: ActivateTool { tool_type : ToolType :: Artboard } ) . await ;
1388+ let artboard = {
1389+ let document = editor. active_document ( ) ;
1390+ document. metadata ( ) . all_layers ( ) . next ( ) . unwrap ( )
1391+ } ;
1392+ editor. handle_message ( NodeGraphMessage :: SelectedNodesSet { nodes : vec ! [ artboard. to_node( ) ] } ) . await ;
1393+
1394+ // Test 1: Grab operation
1395+ let document = editor. active_document ( ) ;
1396+ let original_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1397+ editor. handle_message ( TransformLayerMessage :: BeginGrab ) . await ;
1398+ editor. move_mouse ( 50. , 50. , ModifierKeys :: empty ( ) , MouseKeys :: NONE ) . await ;
1399+ editor
1400+ . handle_message ( TransformLayerMessage :: PointerMove {
1401+ slow_key : Key :: Shift ,
1402+ increments_key : Key :: Control ,
1403+ } )
1404+ . await ;
1405+ editor. handle_message ( TransformLayerMessage :: ApplyTransformOperation { final_transform : true } ) . await ;
1406+
1407+ let document = editor. active_document ( ) ;
1408+ let grab_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1409+ let moved = ( grab_bounds[ 0 ] - original_bounds[ 0 ] ) . length ( ) > 1. ;
1410+ assert ! ( moved, "Artboard should move after grab operation" ) ;
1411+
1412+ // Test 2: Scale operation
1413+ let scale_original_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1414+ let original_size = ( scale_original_bounds[ 1 ] - scale_original_bounds[ 0 ] ) . length ( ) ;
1415+
1416+ // Move the mouse to the same side of the pivot that scaling will continue from
1417+ editor. move_mouse ( 150. , 150. , ModifierKeys :: empty ( ) , MouseKeys :: NONE ) . await ;
1418+ editor. handle_message ( TransformLayerMessage :: BeginScale ) . await ;
1419+ editor. move_mouse ( 200. , 200. , ModifierKeys :: empty ( ) , MouseKeys :: NONE ) . await ;
1420+ editor
1421+ . handle_message ( TransformLayerMessage :: PointerMove {
1422+ slow_key : Key :: Shift ,
1423+ increments_key : Key :: Control ,
1424+ } )
1425+ . await ;
1426+ editor. handle_message ( TransformLayerMessage :: ApplyTransformOperation { final_transform : true } ) . await ;
1427+
1428+ let document = editor. active_document ( ) ;
1429+ let scale_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1430+ let final_size = ( scale_bounds[ 1 ] - scale_bounds[ 0 ] ) . length ( ) ;
1431+ assert ! ( final_size > original_size, "Artboard should be larger after scale operation" ) ;
1432+
1433+ // Test 3: Typed scale input
1434+ let typed_original_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1435+ let typed_original_width = typed_original_bounds[ 1 ] . x - typed_original_bounds[ 0 ] . x ;
1436+
1437+ editor. handle_message ( TransformLayerMessage :: BeginScale ) . await ;
1438+ editor. handle_message ( TransformLayerMessage :: TypeDigit { digit : 2 } ) . await ;
1439+ editor. handle_message ( TransformLayerMessage :: ApplyTransformOperation { final_transform : true } ) . await ;
1440+
1441+ let document = editor. active_document ( ) ;
1442+ let typed_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1443+ let typed_final_width = typed_bounds[ 1 ] . x - typed_bounds[ 0 ] . x ;
1444+ let scale_factor = typed_final_width / typed_original_width;
1445+ assert ! ( ( scale_factor - 2. ) . abs( ) < 0.1 , "Artboard should scale by 2x with typed input" ) ;
1446+
1447+ // Test 4: Grab with X constraint
1448+ let constrain_original_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1449+ let constrain_original_x = constrain_original_bounds[ 0 ] . x ;
1450+ let constrain_original_y = constrain_original_bounds[ 0 ] . y ;
1451+
1452+ editor. handle_message ( TransformLayerMessage :: BeginGrab ) . await ;
1453+ editor. move_mouse ( 50. , 50. , ModifierKeys :: empty ( ) , MouseKeys :: NONE ) . await ;
1454+ editor. handle_message ( TransformLayerMessage :: ConstrainX ) . await ;
1455+ editor. handle_message ( TransformLayerMessage :: ApplyTransformOperation { final_transform : true } ) . await ;
1456+
1457+ let document = editor. active_document ( ) ;
1458+ let constrain_bounds = document. metadata ( ) . bounding_box_document ( artboard) . unwrap ( ) ;
1459+ let constrain_final_x = constrain_bounds[ 0 ] . x ;
1460+ let constrain_final_y = constrain_bounds[ 0 ] . y ;
1461+ assert ! ( constrain_final_x != constrain_original_x, "Artboard X should change with X constraint" ) ;
1462+ assert ! ( ( constrain_final_y - constrain_original_y) . abs( ) < 1. , "Artboard Y should stay roughly the same with X constraint" ) ;
1463+ }
13791464}
0 commit comments