TestCmdSetColor.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. module( "CmdSetColor" );
  2. test("Test CmdSetColor (Undo and Redo)", function() {
  3. var editor = new Editor();
  4. var object = aPointlight( "The light Light" );
  5. var green = 12581843; // bffbd3
  6. var blue = 14152447; // d7f2ff
  7. var yellow = 16775383; // fff8d7
  8. editor.execute( new CmdAddObject( object ) );
  9. // set color to green
  10. var cmd = new CmdSetColor( object, 'color', green );
  11. cmd.updatable = false; // Because otherwise the commands are merged into one command
  12. editor.execute( cmd );
  13. ok( object.color.getHex() == green , "OK, color has been set successfully, Expected: '" + green + "', Actual: '" + object.color.getHex() + "'" );
  14. // set color to blue
  15. var cmd = new CmdSetColor( object, 'color', blue );
  16. cmd.updatable = false; // Because otherwise the commands are merged into one command
  17. editor.execute( cmd );
  18. ok( object.color.getHex() == blue , "OK, color has been set successfully, Expected: '" + blue + "', Actual: '" + object.color.getHex() + "'" );
  19. // set color to yellow
  20. var cmd = new CmdSetColor( object, 'color', yellow );
  21. cmd.updatable = false; // Because otherwise the commands are merged into one command
  22. editor.execute( cmd );
  23. ok( object.color.getHex() == yellow , "OK, color has been set successfully, Expected: '" + yellow + "', Actual: '" + object.color.getHex() + "'" );
  24. editor.undo();
  25. ok( object.color.getHex() == blue, "OK, changing color has been undone, Expected: '" + blue + "', Actual: '" + object.color.getHex() + "'" );
  26. editor.redo();
  27. ok( object.color.getHex() == yellow , "OK, changing color has been redone, Expected: '" + yellow + "', Actual: '" + object.color.getHex() + "'" );
  28. });