X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=webglFramework%2FThirdparty%2Fthree.js-master%2Ftest%2Funit%2Feditor%2FTestSetMaterialValueCommand.js;fp=webglFramework%2FThirdparty%2Fthree.js-master%2Ftest%2Funit%2Feditor%2FTestSetMaterialValueCommand.js;h=3dc8a7a5b5cfffc15529eca092fd978efb1a74c2;hb=05b15e87b35a7cc0c848c07b0e0550d0befd0c73;hp=0000000000000000000000000000000000000000;hpb=9b45f1a137e35166eaa9062f6a7078bd551704d6;p=webglgame%2Fwebgl_framework.git diff --git a/webglFramework/Thirdparty/three.js-master/test/unit/editor/TestSetMaterialValueCommand.js b/webglFramework/Thirdparty/three.js-master/test/unit/editor/TestSetMaterialValueCommand.js new file mode 100644 index 0000000..3dc8a7a --- /dev/null +++ b/webglFramework/Thirdparty/three.js-master/test/unit/editor/TestSetMaterialValueCommand.js @@ -0,0 +1,63 @@ +/** + * @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( "SetMaterialValueCommand" ); + +QUnit.test( "Test for SetMaterialValueCommand (Undo and Redo)", function( assert ) { + + // setup scene + var editor = new Editor(); + var box = aBox(); + var cmd = new AddObjectCommand( box ); + cmd.updatable = false; + editor.execute( cmd ); + + // every attribute gets three test values + var testData = { + + uuid: [ THREE.Math.generateUUID(), THREE.Math.generateUUID(), THREE.Math.generateUUID() ], + name: [ 'Alpha', 'Bravo', 'Charlie' ], + shininess: [ 11.1, 22.2, 33.3 ], + vertexColors: [ 'No', 'Face', 'Vertex' ], + bumpScale: [ 1.1, 2.2, 3.3 ], + reflectivity: [ - 1.3, 2.1, 5.0 ], + aoMapIntensity: [ 0.1, 0.4, 0.7 ], + side: [ 'Front', 'Back', 'Double' ], + shading: [ 'No', 'Flat', 'Smooth' ], + blending: [ 'No', 'Normal', 'Additive' ], + opacity: [ 0.2, 0.5, 0.8 ], + alphaTest: [ 0.1, 0.6, 0.9 ], + wireframeLinewidth: [ 1.2, 3.4, 5.6 ] + + }; + + var testDataKeys = Object.keys( testData ); + + testDataKeys.map( function( attributeName ) { + + testData[ attributeName ].map( function( value ) { + + var cmd = new SetMaterialValueCommand( box, attributeName, value ); + cmd.updatable = false; + editor.execute( cmd ); + + } ); + + var length = testData[ attributeName ].length; + assert.ok( box.material[ attributeName ] == testData[ attributeName ][ length - 1 ], + "OK, " + attributeName + " was set correctly to the last value (expected: '" + testData[ attributeName ][ length - 1 ] + "', actual: '" + box.material[ attributeName ] + "')" ); + + editor.undo(); + assert.ok( box.material[ attributeName ] == testData[ attributeName ][ length - 2 ], + "OK, " + attributeName + " was set correctly to the second to the last value after undo (expected: '" + testData[ attributeName ][ length - 2 ] + "', actual: '" + box.material[ attributeName ] + "')" ); + + editor.redo(); + assert.ok( box.material[ attributeName ] == testData[ attributeName ][ length - 1 ], + "OK, " + attributeName + " was set correctly to the last value again after redo (expected: '" + testData[ attributeName ][ length - 1 ] + "', actual: '" + box.material[ attributeName ] + "')" ); + + } ); + + +} );