1 19 20 package org.netbeans.modules.uihandler; 21 22 import java.awt.Dialog ; 23 import java.util.Locale ; 24 import java.util.logging.Level ; 25 import java.util.logging.Logger ; 26 import org.netbeans.junit.Log; 27 import org.netbeans.junit.MockServices; 28 import org.netbeans.junit.NbTestCase; 29 import org.netbeans.modules.uihandler.api.Activated; 30 import org.netbeans.modules.uihandler.api.Deactivated; 31 import org.openide.DialogDescriptor; 32 import org.openide.DialogDisplayer; 33 import org.openide.NotifyDescriptor; 34 35 39 public class ActivatedDeativatedTest extends NbTestCase { 40 private Installer o; 41 42 public ActivatedDeativatedTest(String testName) { 43 super(testName); 44 } 45 46 protected boolean runInEQ() { 47 return true; 48 } 49 50 protected void setUp() throws Exception { 51 Locale.setDefault(new Locale ("te", "ST")); 52 o = Installer.findObject(Installer.class, true); 53 assertNotNull("Installer created", o); 54 MockServices.setServices(A.class, D.class, DD.class); 55 } 56 57 protected void tearDown() throws Exception { 58 } 59 60 public void testActivatedAndDeativated() { 61 CharSequence log = Log.enable("org.netbeans.ui", Level.ALL); 62 63 o.restored(); 64 if (log.toString().indexOf("A start") == -1) { 65 fail("A shall start: " + log); 66 } 67 68 assertTrue("Allowed to close", o.closing()); 69 if (log.toString().indexOf("D stop") == -1) { 70 fail("D shall stop: " + log); 71 } 72 } 73 74 75 public static final class A implements Activated { 76 public void activated(Logger uiLogger) { 77 uiLogger.config("A started"); 78 } 79 } 80 public static final class D implements Deactivated { 81 public void deactivated(Logger uiLogger) { 82 uiLogger.config("D stopped"); 83 } 84 } 85 public static final class DD extends DialogDisplayer { 86 public Object notify(NotifyDescriptor descriptor) { 87 return descriptor.getOptions()[descriptor.getOptions().length - 1]; 89 } 90 91 public Dialog createDialog(DialogDescriptor descriptor) { 92 fail("Not implemented"); 93 return null; 94 } 95 96 } 97 } 98 | Popular Tags |