TestCmdSetPosition.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. module( "CmdSetPosition" );
  2. test( "Test CmdSetPosition (Undo and Redo)", function() {
  3. var editor = new Editor();
  4. var mesh = aBox();
  5. var initPosX = 50 ;
  6. var initPosY = -80 ;
  7. var initPosZ = 30 ;
  8. mesh.position.x = initPosX ;
  9. mesh.position.y = initPosY ;
  10. mesh.position.z = initPosZ ;
  11. editor.execute( new CmdAddObject( mesh ) );
  12. editor.select( mesh );
  13. // translate the object
  14. var newPosX = 100 ;
  15. var newPosY = 200 ;
  16. var newPosZ = 500 ;
  17. var newPosition = new THREE.Vector3( newPosX, newPosY, newPosZ );
  18. editor.execute( new CmdSetPosition( mesh, newPosition ) );
  19. ok( mesh.position.x != initPosX, "OK, changing X position was successful" );
  20. ok( mesh.position.y != initPosY, "OK, changing Y position was successful" );
  21. ok( mesh.position.z != initPosZ, "OK, changing Z position was successful" );
  22. editor.undo();
  23. ok( mesh.position.x == initPosX, "OK, changing X position value is undone" );
  24. ok( mesh.position.y == initPosY, "OK, changing Y position value is undone" );
  25. ok( mesh.position.z == initPosZ, "OK, changing Z position value is undone" );
  26. editor.redo();
  27. ok( mesh.position.x == newPosX, "OK, changing X position value is redone" );
  28. ok( mesh.position.y == newPosY, "OK, changing Y position value is redone" );
  29. ok( mesh.position.z == newPosZ, "OK, changing Z position value is redone" );
  30. });