@@ -2,38 +2,45 @@ module( "CmdSetRotation" );
22
33test ( "Test CmdSetRotation (Undo and Redo)" , function ( ) {
44
5+ // setup
56 var editor = new Editor ( ) ;
7+ var box = aBox ( ) ;
8+ editor . execute ( new CmdAddObject ( box ) ) ;
69
7- var mesh = aBox ( ) ;
8- var initRotationX = 1.1 ;
9- var initRotationY = 0.4 ;
10- var initRotationZ = - 2.0 ;
11- mesh . rotation . x = initRotationX ;
12- mesh . rotation . y = initRotationY ;
13- mesh . rotation . z = initRotationZ ;
1410
15- editor . execute ( new CmdAddObject ( mesh ) ) ;
16- editor . select ( mesh ) ;
11+ var rotations = [
1712
18- // rotate the object
19- var newRotationX = - 3.2 ;
20- var newRotationY = 0.8 ;
21- var newRotationZ = 1.5 ;
22- var newRotation = new THREE . Euler ( newRotationX , newRotationY , newRotationZ ) ;
23- editor . execute ( new CmdSetRotation ( mesh , newRotation ) ) ;
13+ { x : 1.1 , y : 0.4 , z : - 2.0 } ,
14+ { x : 2.2 , y : - 1.3 , z : 1.3 } ,
15+ { x : 0.3 , y : - 0.1 , z : - 1.9 }
2416
25- ok ( mesh . rotation . x != initRotationX , "OK, changing X rotation was successful" ) ;
26- ok ( mesh . rotation . y != initRotationY , "OK, changing Y rotation was successful" ) ;
27- ok ( mesh . rotation . z != initRotationZ , "OK, changing Z rotation was successful" ) ;
17+ ] ;
18+
19+
20+ rotations . map ( function ( rotation ) {
21+
22+ var newRotation = new THREE . Euler ( rotation . x , rotation . y , rotation . z ) ;
23+ var cmd = new CmdSetRotation ( box , newRotation ) ;
24+ cmd . updatable = false ;
25+ editor . execute ( cmd ) ;
26+
27+ } ) ;
28+
29+
30+ ok ( box . rotation . x == rotations [ rotations . length - 1 ] . x , "OK, changing X rotation was successful" ) ;
31+ ok ( box . rotation . y == rotations [ rotations . length - 1 ] . y , "OK, changing Y rotation was successful" ) ;
32+ ok ( box . rotation . z == rotations [ rotations . length - 1 ] . z , "OK, changing Z rotation was successful" ) ;
2833
2934 editor . undo ( ) ;
30- ok ( mesh . rotation . x == initRotationX , "OK, changing X rotation value is undone " ) ;
31- ok ( mesh . rotation . y == initRotationY , "OK, changing Y rotation value is undone " ) ;
32- ok ( mesh . rotation . z == initRotationZ , "OK, changing Z rotation value is undone " ) ;
35+ ok ( box . rotation . x == rotations [ rotations . length - 2 ] . x , "OK, changing X rotation was successful (after undo) " ) ;
36+ ok ( box . rotation . y == rotations [ rotations . length - 2 ] . y , "OK, changing Y rotation was successful (after undo) " ) ;
37+ ok ( box . rotation . z == rotations [ rotations . length - 2 ] . z , "OK, changing Z rotation was successful (after undo) " ) ;
3338
3439 editor . redo ( ) ;
35- ok ( mesh . rotation . x == newRotationX , "OK, changing X rotation value is redone" ) ;
36- ok ( mesh . rotation . y == newRotationY , "OK, changing Y rotation value is redone" ) ;
37- ok ( mesh . rotation . z == newRotationZ , "OK, changing Z rotation value is redone" ) ;
40+ ok ( box . rotation . x == rotations [ rotations . length - 1 ] . x , "OK, changing X rotation was successful (after redo)" ) ;
41+ ok ( box . rotation . y == rotations [ rotations . length - 1 ] . y , "OK, changing Y rotation was successful (after redo)" ) ;
42+ ok ( box . rotation . z == rotations [ rotations . length - 1 ] . z , "OK, changing Z rotation was successful (after redo)" ) ;
43+
44+
3845
3946} ) ;
0 commit comments