TestCmdSetMaterialColor.js 1.3 KB

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