OSDN Git Service

157ab8d5e87d2cc0214e69f01a8f7983b7e20e73
[webglgame/webgl_framework.git] / webglFramework / Thirdparty / three.js-master / test / unit / editor / TestNegativeCases.js
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
6 QUnit.module( "NegativeCases" );
7
8 QUnit.test( "Test unwanted situations ", function( assert ) {
9
10         var editor = new Editor();
11
12         // illegal
13         editor.undo();
14         assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
15         assert.ok( editor.history.redos.length == 0, "OK, (illegal) undo did not affect the redo history" );
16
17         // illegal
18         editor.redo();
19         assert.ok( editor.history.undos.length == 0, "OK, (illegal) redo did not affect the undo history" );
20         assert.ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" );
21
22
23         var box = aBox();
24         var cmd = new AddObjectCommand( box );
25         cmd.updatable = false;
26         editor.execute( cmd );
27
28         assert.ok( editor.history.undos.length == 1, "OK, execute changed undo history" );
29         assert.ok( editor.history.redos.length == 0, "OK, execute did not change redo history" );
30
31         // illegal
32         editor.redo();
33         assert.ok( editor.history.undos.length == 1, "OK, (illegal) redo did not affect the undo history" );
34         assert.ok( editor.history.redos.length == 0, "OK, (illegal) redo did not affect the redo history" );
35
36
37         editor.undo();
38         assert.ok( editor.history.undos.length == 0, "OK, undo changed the undo history" );
39         assert.ok( editor.history.redos.length == 1, "OK, undo changed the redo history" );
40
41         // illegal
42         editor.undo();
43         assert.ok( editor.history.undos.length == 0, "OK, (illegal) undo did not affect the undo history" );
44         assert.ok( editor.history.redos.length == 1, "OK, (illegal) undo did not affect the redo history" );
45
46         editor.redo();
47         assert.ok( editor.history.undos.length == 1, "OK, redo changed the undo history" );
48         assert.ok( editor.history.redos.length == 0, "OK, undo changed the redo history" );
49
50         // illegal
51         editor.redo();
52         assert.ok( editor.history.undos.length == 1, "OK, (illegal) did not affect the undo history" );
53         assert.ok( editor.history.redos.length == 0, "OK, (illegal) did not affect the redo history" );
54
55 } );