Skip to content

Commit c7cea76

Browse files
author
Mario Schuettel
committed
added test for CmdSetMaterialColor
1 parent eaf1c86 commit c7cea76

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module("CmdSetMaterialColor");
2+
3+
test("Test for CmdSetMaterialColor (Undo and Redo)", function() {
4+
5+
// Setup scene
6+
var editor = new Editor();
7+
var box = aBox();
8+
var cmd = new CmdAddObject( box );
9+
cmd.updatable = false;
10+
editor.execute( cmd );
11+
12+
var green = 12581843; // bffbd3
13+
var blue = 14152447; // d7f2ff
14+
var yellow = 16775383; // fff8d7
15+
16+
// there have to be at least 2 colors !
17+
colors = [ green, blue, yellow ];
18+
19+
[ 'color', 'emissive', 'specular' ].map( function( attributeName ) {
20+
21+
colors.map( function ( color ) {
22+
23+
var cmd = new CmdSetMaterialColor( box, attributeName, color );
24+
cmd.updatable = false;
25+
editor.execute( cmd );
26+
27+
});
28+
29+
ok( box.material[ attributeName ].getHex() == colors[ colors.length - 1 ], "OK, " + attributeName + " was set correctly to last color " );
30+
31+
editor.undo();
32+
ok( box.material[ attributeName ].getHex() == colors[ colors.length - 2 ], "OK, " + attributeName + " is set correctly to second to last color after undo");
33+
34+
editor.redo();
35+
ok( box.material[ attributeName ].getHex() == colors[ colors.length - 1 ], "OK, " + attributeName + " is set correctly to last color after redo");
36+
37+
38+
});
39+
40+
});

test/unit/unittests_editor.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@
8080
<script src="../../editor/js/CmdSetColor.js"></script>
8181
<script src="../../editor/js/CmdSetGeometry.js"></script>
8282
<script src="../../editor/js/CmdSetGeometryValue.js"></script>
83+
<script src="../../editor/js/CmdSetMaterialColor.js"></script>
8384
<script src="../../editor/js/CmdSetPosition.js"></script>
8485
<script src="../../editor/js/CmdSetRotation.js"></script>
8586
<script src="../../editor/js/CmdSetScale.js"></script>
87+
<!-- <script src="../../editor/js/CmdSetScene.js"></script> -->
8688
<script src="../../editor/js/CmdSetScriptValue.js"></script>
8789
<script src="../../editor/js/CmdSetUuid.js"></script>
8890
<script src="../../editor/js/CmdSetValue.js"></script>
@@ -102,9 +104,11 @@
102104
<script src="editor/TestCmdSetColor.js"></script>
103105
<script src="editor/TestCmdSetGeometry.js"></script>
104106
<script src="editor/TestCmdSetGeometryValue.js"></script>
107+
<script src="editor/TestCmdSetMaterialColor.js"></script>
105108
<script src="editor/TestCmdSetPosition.js"></script>
106109
<script src="editor/TestCmdSetRotation.js"></script>
107110
<script src="editor/TestCmdSetScale.js"></script>
111+
<!-- <script src="editor/TestCmdSetScene.js"></script> -->
108112
<script src="editor/TestCmdSetScriptName.js"></script>
109113
<script src="editor/TestCmdSetScriptValue.js"></script>
110114
<script src="editor/TestCmdSetUuid.js"></script>

0 commit comments

Comments
 (0)