|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ /* * */ package org.openide.explorer.view; import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.Robot; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.beans.PropertyVetoException; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import javax.swing.JList; import javax.swing.SwingUtilities; import junit.textui.TestRunner; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.NbTestSuite; import org.openide.explorer.ExplorerPanel; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.nodes.Children.Array; /** * Tests for class ContextTreeViewTest */ public class ContextTreeViewTest extends NbTestCase { private static final int NO_OF_NODES = 3; public ContextTreeViewTest(String name) { super(name); } public static void main(String args[]) { TestRunner.run(new NbTestSuite(ContextTreeViewTest.class)); } public void testLeafNodeReallyNotDisplayed () throws Exception { AbstractNode root = new AbstractNode (new Children.Array ()); root.setName ("test root"); root.getChildren ().add (new Node[] { createLeaf ("kuk"), createLeaf ("huk"), }); Panel p = new Panel (); p.getExplorerManager ().setRootContext (root); ContextTreeView ctv = new ContextTreeView (); p.add (java.awt.BorderLayout.CENTER, ctv); javax.swing.JFrame f = new javax.swing.JFrame (); f.setDefaultCloseOperation (f.EXIT_ON_CLOSE); f.getContentPane ().add (java.awt.BorderLayout.CENTER, p); f.show (); javax.swing.JTree tree = ctv.tree; // wait a while till the frame is realized and ctv.addNotify called Object r = null; for (int i = 0; i < 50; i++) { r = tree.getModel ().getRoot (); if (r != null) break; Thread.sleep (100); } assertEquals ("There is root", r, Visualizer.findVisualizer (root)); int cnt = tree.getModel ().getChildCount (r); assertEquals ("No children as they are leaves", 0, cnt); } private static Node createLeaf (String name) { AbstractNode n = new AbstractNode (Children.LEAF); n.setName (name); return n; } private static class Panel extends javax.swing.JPanel implements org.openide.explorer.ExplorerManager.Provider { private org.openide.explorer.ExplorerManager em = new org.openide.explorer.ExplorerManager (); public org.openide.explorer.ExplorerManager getExplorerManager() { return em; } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.