1 33 34 package edu.rice.cs.drjava.ui.config; 35 36 import edu.rice.cs.drjava.DrJava; 37 import edu.rice.cs.drjava.DrJavaTestCase; 38 import edu.rice.cs.drjava.config.OptionConstants; 39 import edu.rice.cs.util.swing.Utilities; 40 41 import java.awt.*; 42 43 46 public final class ForcedChoiceOptionComponentTest extends DrJavaTestCase { 47 private static ForcedChoiceOptionComponent _option; 48 49 protected void setUp() throws Exception { 50 super.setUp(); 51 _option = new ForcedChoiceOptionComponent( OptionConstants.JAVADOC_ACCESS_LEVEL, "Private", new Frame()); 52 DrJava.getConfig().resetToDefaults(); 53 } 54 55 public void testCancelDoesNotChangeConfig() { 56 String testForcedChoice = new String (DrJava.getConfig().getSetting(OptionConstants.JAVADOC_ACCESS_LEVEL)); 57 58 _option.setValue(testForcedChoice); 59 _option.resetToCurrent(); Utilities.clearEventQueue(); 61 _option.updateConfig(); Utilities.clearEventQueue(); 63 64 assertEquals("Cancel (resetToCurrent) should not change the config", 65 OptionConstants.JAVADOC_ACCESS_LEVEL.getDefault(), 66 DrJava.getConfig().getSetting(OptionConstants.JAVADOC_ACCESS_LEVEL)); 67 68 } 69 70 public void testApplyDoesChangeConfig() { 71 String testForcedChoice = new String (DrJava.getConfig().getSetting(OptionConstants.JAVADOC_ACCESS_LEVEL)); 72 73 _option.setValue(testForcedChoice); 74 _option.updateConfig(); 75 Utilities.clearEventQueue(); 76 assertEquals("Apply (updateConfig) should write change to file", 77 testForcedChoice, 78 DrJava.getConfig().getSetting(OptionConstants.JAVADOC_ACCESS_LEVEL)); 79 } 80 81 public void testApplyThenResetDefault() { 82 String testForcedChoice = new String (DrJava.getConfig().getSetting(OptionConstants.JAVADOC_ACCESS_LEVEL)); 83 84 _option.setValue(testForcedChoice); 85 _option.updateConfig(); 86 Utilities.clearEventQueue(); 87 _option.resetToDefault(); Utilities.clearEventQueue(); 89 _option.updateConfig(); 90 Utilities.clearEventQueue(); 91 92 assertEquals("Apply (updateConfig) should write change to file", 93 OptionConstants.JAVADOC_ACCESS_LEVEL.getDefault(), 94 DrJava.getConfig().getSetting(OptionConstants.JAVADOC_ACCESS_LEVEL)); 95 } 96 97 } | Popular Tags |