1 19 20 package org.openide.loaders; 21 22 import javax.swing.Action ; 23 import javax.swing.SwingUtilities ; 24 import org.netbeans.junit.NbTestCase; 25 import org.openide.actions.OpenAction; 26 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.FileSystem; 28 import org.openide.filesystems.FileUtil; 29 import org.openide.modules.ModuleInfo; 30 import org.openide.nodes.Node; 31 import org.openide.util.Lookup; 32 33 38 public final class DefaultDataObjectHasOpenActionTest extends NbTestCase { 39 40 private DataObject obj; 41 42 public DefaultDataObjectHasOpenActionTest(String name) { 43 super(name); 44 } 45 46 protected void setUp() throws Exception { 47 super.setUp(); 48 49 Lookup.getDefault().lookup(ModuleInfo.class); 51 52 FileSystem fs = FileUtil.createMemoryFileSystem(); 53 FileObject fo = fs.getRoot().createData("x.test"); 54 obj = DataObject.find(fo); 55 56 assertEquals("The right class", obj.getClass(), DefaultDataObject.class); 57 58 assertFalse("Designed to run outside of AWT", SwingUtilities.isEventDispatchThread()); 59 } 60 61 public void testOpenActionIsAlwaysFirst() throws Exception { 62 Node n = obj.getNodeDelegate(); 63 64 assertEquals( 65 "Open action is the default one", 66 OpenAction.get(OpenAction.class), 67 n.getPreferredAction() 68 ); 69 70 Action [] actions = n.getActions(false); 71 assertTrue("There are some actions", actions.length > 1); 72 73 assertEquals( 74 "First one is open", 75 OpenAction.get(OpenAction.class), 76 actions[0] 77 ); 78 } 79 80 } 81 | Popular Tags |