forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSetSceneCommand.js
More file actions
73 lines (49 loc) · 1.74 KB
/
TestSetSceneCommand.js
File metadata and controls
73 lines (49 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* @author lxxxvi / https://github.com/lxxxvi
* Developed as part of a project at University of Applied Sciences and Arts Northwestern Switzerland (www.fhnw.ch)
*/
module( "TestCmdSetScene" );
test( "Test for SetSceneCommand (Undo and Redo)", function() {
// setup
var editor = new Editor();
objects = [ aBox(), aSphere(), aPointlight() ];
// create multiple editors (scenes) and save the output
var scenes = objects.map( function( object ) {
editor = new Editor();
var cmd = new AddObjectCommand( object );
cmd.updatable = false;
editor.execute( cmd );
return { obj: object, exportedData: exportScene( editor ) };
} );
// create new empty editor (scene), merge the other editors (scenes)
editor = new Editor();
scenes.map( function( scene ) {
var importedScene = importScene( scene.exportedData );
var cmd = new SetSceneCommand( importedScene );
cmd.updatable = false;
editor.execute( cmd );
} );
// tests
ok( editor.scene.children.length = scenes.length,
"OK, all scenes have been merged" );
var i = 0;
while ( i < editor.scene.children.length ) {
ok( editor.scene.children[ i ].name == scenes[ i ].obj.name,
"OK, editor.scene.children[ " + i + " ].name matches scenes[ " + i + " ].obj.name" );
i ++;
}
editor.undo();
var i = 0;
while ( i < editor.scene.children.length ) {
ok( editor.scene.children[ i ].name == scenes[ i ].obj.name,
"OK, editor.scene.children[ " + i + " ].name matches scenes[ " + i + " ].obj.name after undo" );
i ++;
}
editor.redo();
var i = 0;
while ( i < editor.scene.children.length ) {
ok( editor.scene.children[ i ].name == scenes[ i ].obj.name,
"OK, editor.scene.children[ " + i + " ].name matches scenes[ " + i + " ].obj.name after redo" );
i ++;
}
} );