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 IntegerOptionComponentTest extends DrJavaTestCase { 47 48 private static IntegerOptionComponent _option; 49 50 protected void setUp() throws Exception { 51 super.setUp(); 52 _option = new IntegerOptionComponent(OptionConstants.INDENT_LEVEL, "Indent Level", new Frame()); 53 DrJava.getConfig().resetToDefaults(); 54 55 } 56 57 public void testCancelDoesNotChangeConfig() { 58 59 Integer testInteger = new Integer (0); 60 61 _option.setValue(testInteger); 62 _option.resetToCurrent(); Utilities.clearEventQueue(); 64 _option.updateConfig(); Utilities.clearEventQueue(); 66 67 assertEquals("Cancel (resetToCurrent) should not change the config", 68 OptionConstants.INDENT_LEVEL.getDefault(), 69 DrJava.getConfig().getSetting(OptionConstants.INDENT_LEVEL)); 70 71 } 72 73 public void testApplyDoesChangeConfig() { 74 Integer testInteger = new Integer (10); 75 76 _option.setValue(testInteger); 77 _option.updateConfig(); 78 Utilities.clearEventQueue(); 79 80 assertEquals("Apply (updateConfig) should write change to file", 81 testInteger, 82 DrJava.getConfig().getSetting(OptionConstants.INDENT_LEVEL)); 83 } 84 85 public void testApplyThenResetDefault() { 86 Integer testInteger = new Integer (10); 87 88 _option.setValue(testInteger); 89 _option.updateConfig(); 90 Utilities.clearEventQueue(); 91 _option.resetToDefault(); Utilities.clearEventQueue(); 93 _option.updateConfig(); 94 Utilities.clearEventQueue(); 95 96 assertEquals("Apply (updateConfig) should write change to file", 97 OptionConstants.INDENT_LEVEL.getDefault(), 98 DrJava.getConfig().getSetting(OptionConstants.INDENT_LEVEL)); 99 } 100 101 } | Popular Tags |