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)
6 QUnit.module( "SetGeometryCommand" );
8 QUnit.test( "Test SetGeometryCommand (Undo and Redo)", function( assert ) {
10 var editor = new Editor();
12 // initialize objects and geometries
13 var box = aBox( 'Guinea Pig' ); // default ( 100, 100, 100, 1, 1, 1 )
14 var boxGeometry1 = { geometry: { parameters: { width: 200, height: 201, depth: 202, widthSegments: 2, heightSegments: 3, depthSegments: 4 } } };
15 var boxGeometry2 = { geometry: { parameters: { width: 50, height: 51, depth: 52, widthSegments: 7, heightSegments: 8, depthSegments: 9 } } };
16 var geometryParams = [ boxGeometry1, boxGeometry2 ];
20 var cmd = new AddObjectCommand( box );
21 cmd.updatable = false;
22 editor.execute( cmd );
24 for ( var i = 0; i < geometryParams.length; i ++ ) {
26 var cmd = new SetGeometryCommand( box, getGeometry( "BoxGeometry", geometryParams[ i ] ) );
27 cmd.updatable = false;
28 editor.execute( cmd );
30 var actualParams = box.geometry.parameters;
31 var expectedParams = geometryParams[ i ].geometry.parameters;
33 assert.ok( actualParams.width == expectedParams.width, "OK, box width matches the corresponding value from boxGeometry" + ( i + 1 ) );
34 assert.ok( actualParams.height == expectedParams.height, "OK, box height matches the corresponding value from boxGeometry" + ( i + 1 ) );
35 assert.ok( actualParams.depth == expectedParams.depth, "OK, box depth matches the corresponding value from boxGeometry" + ( i + 1 ) );
36 assert.ok( actualParams.widthSegments == expectedParams.widthSegments, "OK, box widthSegments matches the corresponding value from boxGeometry" + ( i + 1 ) );
37 assert.ok( actualParams.heightSegments == expectedParams.heightSegments, "OK, box heightSegments matches the corresponding value from boxGeometry" + ( i + 1 ) );
38 assert.ok( actualParams.depthSegments == expectedParams.depthSegments, "OK, box depthSegments matches the corresponding value from boxGeometry" + ( i + 1 ) );
43 var actualParams = box.geometry.parameters;
44 var expectedParams = geometryParams[ 0 ].geometry.parameters;
45 assert.ok( actualParams.width == expectedParams.width, "OK, box width matches the corresponding value from boxGeometry1 (after undo)" );
46 assert.ok( actualParams.height == expectedParams.height, "OK, box height matches the corresponding value from boxGeometry1 (after undo)" );
47 assert.ok( actualParams.depth == expectedParams.depth, "OK, box depth matches the corresponding value from boxGeometry1 (after undo)" );
48 assert.ok( actualParams.widthSegments == expectedParams.widthSegments, "OK, box widthSegments matches the corresponding value from boxGeometry1 (after undo)" );
49 assert.ok( actualParams.heightSegments == expectedParams.heightSegments, "OK, box heightSegments matches the corresponding value from boxGeometry1 (after undo)" );
50 assert.ok( actualParams.depthSegments == expectedParams.depthSegments, "OK, box depthSegments matches the corresponding value from boxGeometry1 (after undo)" );
53 var actualParams = box.geometry.parameters;
54 var expectedParams = geometryParams[ 1 ].geometry.parameters;
55 assert.ok( actualParams.width == expectedParams.width, "OK, box width matches the corresponding value from boxGeometry2 (after redo)" );
56 assert.ok( actualParams.height == expectedParams.height, "OK, box height matches the corresponding value from boxGeometry2 (after redo)" );
57 assert.ok( actualParams.depth == expectedParams.depth, "OK, box depth matches the corresponding value from boxGeometry2 (after redo)" );
58 assert.ok( actualParams.widthSegments == expectedParams.widthSegments, "OK, box widthSegments matches the corresponding value from boxGeometry2 (after redo)" );
59 assert.ok( actualParams.heightSegments == expectedParams.heightSegments, "OK, box heightSegments matches the corresponding value from boxGeometry2 (after redo)" );
60 assert.ok( actualParams.depthSegments == expectedParams.depthSegments, "OK, box depthSegments matches the corresponding value from boxGeometry2 (after redo)" );