X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=webglFramework%2FThirdparty%2Fthree.js-master%2Ftest%2Funit%2Feditor%2FTestNegativeCases.js;fp=webglFramework%2FThirdparty%2Fthree.js-master%2Ftest%2Funit%2Feditor%2FTestNegativeCases.js;h=157ab8d5e87d2cc0214e69f01a8f7983b7e20e73;hb=05b15e87b35a7cc0c848c07b0e0550d0befd0c73;hp=0000000000000000000000000000000000000000;hpb=9b45f1a137e35166eaa9062f6a7078bd551704d6;p=webglgame%2Fwebgl_framework.git diff --git a/webglFramework/Thirdparty/three.js-master/test/unit/editor/TestNegativeCases.js b/webglFramework/Thirdparty/three.js-master/test/unit/editor/TestNegativeCases.js new file mode 100644 index 0000000..157ab8d --- /dev/null +++ b/webglFramework/Thirdparty/three.js-master/test/unit/editor/TestNegativeCases.js @@ -0,0 +1,55 @@ +/** + * @author lxxxvi / https://github.com/lxxxvi + * Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch) + */ + +QUnit.module( "NegativeCases" ); + +QUnit.test( "Test unwanted situations ", function( assert ) { + + var editor = new Editor(); + + // illegal + editor.undo(); + assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" ); + assert.ok( editor.history.redos.length == 0, "OK, (illegal) undo did not affect the redo history" ); + + // illegal + editor.redo(); + assert.ok( editor.history.undos.length == 0, "OK, (illegal) redo did not affect the undo history" ); + assert.ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" ); + + + var box = aBox(); + var cmd = new AddObjectCommand( box ); + cmd.updatable = false; + editor.execute( cmd ); + + assert.ok( editor.history.undos.length == 1, "OK, execute changed undo history" ); + assert.ok( editor.history.redos.length == 0, "OK, execute did not change redo history" ); + + // illegal + editor.redo(); + assert.ok( editor.history.undos.length == 1, "OK, (illegal) redo did not affect the undo history" ); + assert.ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" ); + + + editor.undo(); + assert.ok( editor.history.undos.length == 0, "OK, undo changed the undo history" ); + assert.ok( editor.history.redos.length == 1, "OK, undo changed the redo history" ); + + // illegal + editor.undo(); + assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" ); + assert.ok( editor.history.redos.length == 1, "OK, (illegal) undo did not affect the redo history" ); + + editor.redo(); + assert.ok( editor.history.undos.length == 1, "OK, redo changed the undo history" ); + assert.ok( editor.history.redos.length == 0, "OK, undo changed the redo history" ); + + // illegal + editor.redo(); + assert.ok( editor.history.undos.length == 1, "OK, (illegal) did not affect the undo history" ); + assert.ok( editor.history.redos.length == 0, "OK, (illegal) did not affect the redo history" ); + +} );