TestCmdSetMaterial.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. module("CmdSetMaterial");
  2. test( "Test for CmdSetMaterial (Undo and Redo)", function() {
  3. // setup
  4. var editor = new Editor();
  5. var box = aBox( 'Material girl in a material world' );
  6. var cmd = new CmdAddObject( box );
  7. cmd.updatable = false;
  8. editor.execute( cmd );
  9. materialClasses = [
  10. 'LineBasicMaterial',
  11. 'LineDashedMaterial',
  12. 'MeshBasicMaterial',
  13. 'MeshDepthMaterial',
  14. 'MeshLambertMaterial',
  15. 'MeshNormalMaterial',
  16. 'MeshPhongMaterial',
  17. 'ShaderMaterial',
  18. 'SpriteMaterial'
  19. ];
  20. materialClasses.map( function( materialClass ) {
  21. material = new THREE[ materialClass ]();
  22. editor.execute( new CmdSetMaterial( box, material ) );
  23. });
  24. var i = materialClasses.length - 1;
  25. // initial test
  26. ok( box.material.type == materialClasses[ i ],
  27. "OK, initial material type was set correctly (expected: '" + materialClasses[ i ] + "', actual: '" + box.material.type + "')" );
  28. // test undos
  29. while( i > 0 ) {
  30. editor.undo();
  31. --i;
  32. ok( box.material.type == materialClasses[ i ],
  33. "OK, material type was set correctly after undo (expected: '" + materialClasses[ i ] + "', actual: '" + box.material.type + "')" );
  34. }
  35. // test redos
  36. while( i < materialClasses.length - 1 ) {
  37. editor.redo();
  38. ++i;
  39. ok( box.material.type == materialClasses[ i ],
  40. "OK, material type was set correctly after redo (expected: '" + materialClasses[ i ] + "', actual: '" + box.material.type + "')" );
  41. }
  42. });