|
@@ -2,38 +2,45 @@ module( "CmdSetRotation" );
|
|
|
|
|
|
test( "Test CmdSetRotation (Undo and Redo)", function() {
|
|
|
|
|
|
+ // setup
|
|
|
var editor = new Editor();
|
|
|
+ var box = aBox();
|
|
|
+ editor.execute( new CmdAddObject( box ) );
|
|
|
|
|
|
- var mesh = aBox();
|
|
|
- var initRotationX = 1.1 ;
|
|
|
- var initRotationY = 0.4 ;
|
|
|
- var initRotationZ = -2.0 ;
|
|
|
- mesh.rotation.x = initRotationX ;
|
|
|
- mesh.rotation.y = initRotationY ;
|
|
|
- mesh.rotation.z = initRotationZ ;
|
|
|
|
|
|
- editor.execute( new CmdAddObject( mesh ) );
|
|
|
- editor.select( mesh );
|
|
|
+ var rotations = [
|
|
|
|
|
|
- // rotate the object
|
|
|
- var newRotationX = -3.2 ;
|
|
|
- var newRotationY = 0.8 ;
|
|
|
- var newRotationZ = 1.5 ;
|
|
|
- var newRotation = new THREE.Euler( newRotationX, newRotationY, newRotationZ );
|
|
|
- editor.execute ( new CmdSetRotation( mesh, newRotation ) );
|
|
|
+ { x: 1.1, y: 0.4, z: -2.0 },
|
|
|
+ { x: 2.2, y: -1.3, z: 1.3 },
|
|
|
+ { x: 0.3, y: -0.1, z: -1.9 }
|
|
|
|
|
|
- ok( mesh.rotation.x != initRotationX, "OK, changing X rotation was successful" );
|
|
|
- ok( mesh.rotation.y != initRotationY, "OK, changing Y rotation was successful" );
|
|
|
- ok( mesh.rotation.z != initRotationZ, "OK, changing Z rotation was successful" );
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ rotations.map( function( rotation ) {
|
|
|
+
|
|
|
+ var newRotation = new THREE.Euler( rotation.x, rotation.y, rotation.z );
|
|
|
+ var cmd = new CmdSetRotation( box, newRotation );
|
|
|
+ cmd.updatable = false;
|
|
|
+ editor.execute ( cmd );
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ ok( box.rotation.x == rotations[ rotations.length - 1 ].x, "OK, changing X rotation was successful" );
|
|
|
+ ok( box.rotation.y == rotations[ rotations.length - 1 ].y, "OK, changing Y rotation was successful" );
|
|
|
+ ok( box.rotation.z == rotations[ rotations.length - 1 ].z, "OK, changing Z rotation was successful" );
|
|
|
|
|
|
editor.undo();
|
|
|
- ok( mesh.rotation.x == initRotationX, "OK, changing X rotation value is undone" );
|
|
|
- ok( mesh.rotation.y == initRotationY, "OK, changing Y rotation value is undone" );
|
|
|
- ok( mesh.rotation.z == initRotationZ, "OK, changing Z rotation value is undone" );
|
|
|
+ ok( box.rotation.x == rotations[ rotations.length - 2 ].x, "OK, changing X rotation was successful (after undo)" );
|
|
|
+ ok( box.rotation.y == rotations[ rotations.length - 2 ].y, "OK, changing Y rotation was successful (after undo)" );
|
|
|
+ ok( box.rotation.z == rotations[ rotations.length - 2 ].z, "OK, changing Z rotation was successful (after undo)" );
|
|
|
|
|
|
editor.redo();
|
|
|
- ok( mesh.rotation.x == newRotationX, "OK, changing X rotation value is redone" );
|
|
|
- ok( mesh.rotation.y == newRotationY, "OK, changing Y rotation value is redone" );
|
|
|
- ok( mesh.rotation.z == newRotationZ, "OK, changing Z rotation value is redone" );
|
|
|
+ ok( box.rotation.x == rotations[ rotations.length - 1 ].x, "OK, changing X rotation was successful (after redo)" );
|
|
|
+ ok( box.rotation.y == rotations[ rotations.length - 1 ].y, "OK, changing Y rotation was successful (after redo)" );
|
|
|
+ ok( box.rotation.z == rotations[ rotations.length - 1 ].z, "OK, changing Z rotation was successful (after redo)" );
|
|
|
+
|
|
|
+
|
|
|
|
|
|
});
|