TestMassUndoAndRedo.js 998 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * @author lxxxvi / https://github.com/lxxxvi
  3. * Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
  4. */
  5. module( "MassUndoAndRedo" );
  6. test( "MassUndoAndRedo (stress test)", function() {
  7. var editor = new Editor();
  8. var MAX_OBJECTS = 100;
  9. // add objects
  10. var i = 0;
  11. while ( i < MAX_OBJECTS ) {
  12. var object = aSphere( 'Sphere #' + i );
  13. var cmd = new AddObjectCommand( object );
  14. cmd.updatable = false;
  15. editor.execute( cmd );
  16. i ++;
  17. }
  18. ok( editor.scene.children.lenght = MAX_OBJECTS,
  19. "OK, " + MAX_OBJECTS + " objects have been added" );
  20. // remove all objects
  21. i = 0;
  22. while ( i < MAX_OBJECTS ) {
  23. editor.undo();
  24. i ++;
  25. }
  26. ok( editor.scene.children.length == 0,
  27. "OK, all objects have been removed by undos" );
  28. i = 0;
  29. while ( i < MAX_OBJECTS ) {
  30. editor.redo();
  31. i ++;
  32. }
  33. ok( editor.scene.children.lenght = MAX_OBJECTS,
  34. "OK, " + MAX_OBJECTS + " objects have been added again by redos" );
  35. } );