TestCmdSetScale.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. module( "CmdSetScale" );
  2. test( "Test CmdSetScale (Undo and Redo)", function() {
  3. // setup
  4. var editor = new Editor();
  5. var box = aBox();
  6. editor.execute( new CmdAddObject( box ) );
  7. // scales
  8. var scales = [
  9. { x: 1.4, y: 2.7, z: 0.4 },
  10. { x: 0.1, y: 1.3, z: 2.9 },
  11. { x: 3.2, y: 0.3, z: 2.0 }
  12. ];
  13. scales.map( function( scale ) {
  14. var newScale = new THREE.Vector3( scale.x, scale.y, scale.z );
  15. var cmd = new CmdSetScale( box, newScale );
  16. cmd.updatable = false;
  17. editor.execute( cmd );
  18. });
  19. ok( box.scale.x == scales[ scales.length - 1 ].x, "OK, setting X scale value was successful" );
  20. ok( box.scale.y == scales[ scales.length - 1 ].y, "OK, setting Y scale value was successful" );
  21. ok( box.scale.z == scales[ scales.length - 1 ].z, "OK, setting Z scale value was successful" );
  22. editor.undo();
  23. ok( box.scale.x == scales[ scales.length - 2 ].x, "OK, X scale is correct after undo" );
  24. ok( box.scale.y == scales[ scales.length - 2 ].y, "OK, Y scale is correct after undo" );
  25. ok( box.scale.z == scales[ scales.length - 2 ].z, "OK, Z scale is correct after undo" );
  26. editor.redo();
  27. ok( box.scale.x == scales[ scales.length - 1 ].x, "OK, X scale is correct after redo" );
  28. ok( box.scale.y == scales[ scales.length - 1 ].y, "OK, Y scale is correct after redo" );
  29. ok( box.scale.z == scales[ scales.length - 1 ].z, "OK, Z scale is correct after redo" );
  30. });