|                                                                                                              1
 19
 20  package org.openide.util.actions;
 21
 22  import org.netbeans.junit.NbTestCase;
 23  import org.openide.util.HelpCtx;
 24
 25
 28  public class BooleanStateActionTest extends NbTestCase {
 29
 30      public BooleanStateActionTest(String
  name) { 31          super(name);
 32      }
 33
 34
 35      public void testToggle() throws Exception
  { 36          BooleanStateAction a1 = (BooleanStateAction)SystemAction.get(SimpleBooleanAction1.class);
 37          assertTrue(a1.isEnabled());
 38          BooleanStateAction a2 = (BooleanStateAction)SystemAction.get(SimpleBooleanAction2.class);
 39          assertTrue(a1.getBooleanState());
 40          assertFalse(a2.getBooleanState());
 41          ActionsInfraHid.WaitPCL l = new ActionsInfraHid.WaitPCL(BooleanStateAction.PROP_BOOLEAN_STATE);
 42          a1.addPropertyChangeListener(l);
 43          a1.actionPerformed(null);
 44          assertTrue(l.changed());
 45          assertFalse(a1.getBooleanState());
 46          a1.removePropertyChangeListener(l);
 47          l.gotit = 0;
 48          a2.addPropertyChangeListener(l);
 49          a2.actionPerformed(null);
 50          assertTrue(l.changed());
 51          assertTrue(a2.getBooleanState());
 52          a2.removePropertyChangeListener(l);
 53      }
 54
 55      public static final class SimpleBooleanAction1 extends BooleanStateAction {
 56          public String
  getName() { 57              return "SimpleBooleanAction1";
 58          }
 59          public HelpCtx getHelpCtx() {
 60              return null;
 61          }
 62          protected boolean asynchronous() {
 63              return false;
 64          }
 65      }
 66
 67      public static final class SimpleBooleanAction2 extends BooleanStateAction {
 68          protected void initialize() {
 69              super.initialize();
 70              setBooleanState(false);
 71          }
 72          public String
  getName() { 73              return "SimpleBooleanAction2";
 74          }
 75          public HelpCtx getHelpCtx() {
 76              return null;
 77          }
 78          protected boolean asynchronous() {
 79              return false;
 80          }
 81      }
 82
 83  }
 84
                                                                                                                                                                                                             |                                                                       
 
 
 
 
 
                                                                                   Popular Tags                                                                                                                                                                                              |