1 19 20 package org.openide.windows; 21 22 import junit.framework.*; 23 import org.openide.util.Lookup; 24 import org.openide.util.lookup.AbstractLookup; 25 import org.openide.util.lookup.InstanceContent; 26 import org.openide.util.lookup.Lookups; 27 import org.openide.util.lookup.ProxyLookup; 28 29 34 public final class WindowSystemCompatibilityTest extends Object { 35 36 public static void init() { 37 System.setProperty("org.openide.util.Lookup", WindowSystemCompatibilityTest.class.getName() + "$Lkp"); 38 39 Object o = Lookup.getDefault(); 40 if (!(o instanceof Lkp)) { 41 Assert.fail("Wrong lookup object: " + o); 42 } 43 } 44 45 private WindowSystemCompatibilityTest(String testName) { 46 } 47 48 50 public static Test suite() { 51 return suite(null); 52 } 53 54 56 public static Test suite(WindowManager wm) { 57 init(); 58 59 Object o = Lookup.getDefault(); 60 Lkp l = (Lkp)o; 61 l.assignWM(wm); 62 63 if (wm != null) { 64 Assert.assertEquals("Same engine found", wm, WindowManager.getDefault()); 65 } else { 66 o = WindowManager.getDefault(); 67 Assert.assertNotNull("Engine found", o); 68 Assert.assertEquals(DummyWindowManager.class, o.getClass()); 69 } 70 71 TestSuite ts = new TestSuite(); 72 ts.addTestSuite(WindowManagerHid.class); 73 74 return ts; 75 } 76 77 79 public static final class Lkp extends ProxyLookup { 80 private InstanceContent ic; 81 82 public Lkp() { 83 super(new Lookup[0]); 84 85 ic = new InstanceContent(); 86 AbstractLookup al = new AbstractLookup(ic); 87 88 setLookups(new Lookup[] { 89 al, Lookups.metaInfServices(Lkp.class.getClassLoader()) 90 }); 91 } 92 93 final void assignWM(WindowManager executionEngine) { 94 if (executionEngine != null) { 96 ic.add(executionEngine); 97 } 98 } 99 100 101 } 102 103 } 104 | Popular Tags |