TestCmdSetMaterialColor.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. module("CmdSetMaterialColor");
  2. test("Test for CmdSetMaterialColor (Undo and Redo)", function() {
  3. // Setup scene
  4. var editor = new Editor();
  5. var box = aBox();
  6. var cmd = new CmdAddObject( box );
  7. cmd.updatable = false;
  8. editor.execute( cmd );
  9. var green = 12581843; // bffbd3
  10. var blue = 14152447; // d7f2ff
  11. var yellow = 16775383; // fff8d7
  12. // there have to be at least 2 colors !
  13. colors = [ green, blue, yellow ];
  14. [ 'color', 'emissive', 'specular' ].map( function( attributeName ) {
  15. colors.map( function ( color ) {
  16. var cmd = new CmdSetMaterialColor( box, attributeName, color );
  17. cmd.updatable = false;
  18. editor.execute( cmd );
  19. });
  20. ok( box.material[ attributeName ].getHex() == colors[ colors.length - 1 ], "OK, " + attributeName + " was set correctly to last color " );
  21. editor.undo();
  22. ok( box.material[ attributeName ].getHex() == colors[ colors.length - 2 ], "OK, " + attributeName + " is set correctly to second to last color after undo");
  23. editor.redo();
  24. ok( box.material[ attributeName ].getHex() == colors[ colors.length - 1 ], "OK, " + attributeName + " is set correctly to last color after redo");
  25. });
  26. });