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 BooleanOptionComponentTest extends DrJavaTestCase { 47 48 private static BooleanOptionComponent _option; 49 50 public BooleanOptionComponentTest(String name) { 51 super(name); 52 } 53 54 protected void setUp() throws Exception { 55 super.setUp(); 56 _option = new BooleanOptionComponent( OptionConstants.LINEENUM_ENABLED, "Line Enumeration", new Frame()); 57 DrJava.getConfig().resetToDefaults(); 58 59 } 60 61 public void testCancelDoesNotChangeConfig() { 62 63 Boolean testBoolean = new Boolean (!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue()); 64 65 _option.setValue(testBoolean); 66 _option.resetToCurrent(); _option.updateConfig(); Utilities.clearEventQueue(); 69 assertEquals("Cancel (resetToCurrent) should not change the config", 70 OptionConstants.LINEENUM_ENABLED.getDefault(), 71 DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED)); 72 73 } 74 75 public void testApplyDoesChangeConfig() { 76 Boolean testBoolean = new Boolean (!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue()); 77 78 _option.setValue(testBoolean); 79 _option.updateConfig(); 80 Utilities.clearEventQueue(); 81 assertEquals("Apply (updateConfig) should write change to file", 82 testBoolean, 83 DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED)); 84 } 85 86 public void testApplyThenResetDefault() { 87 Boolean testBoolean = new Boolean (!DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED).booleanValue()); 88 89 _option.setValue(testBoolean); 90 _option.updateConfig(); 91 Utilities.clearEventQueue(); 92 _option.resetToDefault(); Utilities.clearEventQueue(); 94 _option.updateConfig(); 95 Utilities.clearEventQueue(); 96 97 assertEquals("Apply (updateConfig) should write change to file", 98 OptionConstants.LINEENUM_ENABLED.getDefault(), 99 DrJava.getConfig().getSetting(OptionConstants.LINEENUM_ENABLED)); 100 } 101 } 102 103 | Popular Tags |