KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ui > customizer > AddModulePanelTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.ui.customizer;
21
22 import javax.swing.JFrame JavaDoc;
23 import javax.swing.ListModel JavaDoc;
24 import javax.swing.SwingUtilities JavaDoc;
25 import org.netbeans.modules.apisupport.project.NbModuleProject;
26 import org.netbeans.modules.apisupport.project.TestBase;
27
28 /**
29  * Tests {@link AddModulePanel}.
30  *
31  * @author Martin Krauskopf
32  */

33 public class AddModulePanelTest extends TestBase {
34
35     private AddModulePanel amp;
36
37     public AddModulePanelTest(String JavaDoc name) {
38         super(name);
39     }
40
41     public void testDependenciesFiltering() throws Exception JavaDoc {
42         NbModuleProject p = generateStandaloneModule("module1");
43         final SingleModuleProperties props = SingleModulePropertiesTest.loadProperties(p);
44         SwingUtilities.invokeAndWait(new Runnable JavaDoc() {
45             public void run() {
46                 amp = new AddModulePanel(props);
47                 JFrame JavaDoc f = new JFrame JavaDoc();
48                 f.getContentPane().add(amp);
49                 f.pack();
50                 //f.setVisible(true);
51
}
52         });
53         while (amp == null || !amp.filterValue.isEnabled()) {
54             Thread.sleep(400);
55         }
56         int all = amp.moduleList.getModel().getSize();
57         SwingUtilities.invokeAndWait(new Runnable JavaDoc() {
58             public void run() {
59                 // fire multiple events to EQ
60
amp.filterValue.setText("o");
61                 amp.filterValue.setText("or");
62                 amp.filterValue.setText("org");
63                 amp.filterValue.setText("org.");
64                 amp.filterValue.setText("org.o");
65                 amp.filterValue.setText("org.op");
66             }
67         });
68         // wait until filter is applied
69
while (CustomizerComponentFactory.isWaitModel(amp.moduleList.getModel())) {
70             Thread.sleep(200);
71         }
72         ListModel JavaDoc model = amp.moduleList.getModel();
73         int filtered = model.getSize();
74         final int EXPECTED_MAX = 50; // XXX really should be computed
75
assertTrue("filter was successfull (" + all + " > " + filtered + ")", all > filtered);
76         assertTrue("filter was successfull (" + filtered + " > " + EXPECTED_MAX + ")", filtered < EXPECTED_MAX);
77         assertTrue("non-wait model", !CustomizerComponentFactory.isWaitModel(amp.moduleList.getModel()));
78         assertTrue("non-empty model", !CustomizerComponentFactory.hasOnlyValue(amp.moduleList.getModel(), CustomizerComponentFactory.EMPTY_VALUE));
79     }
80     
81 }
82
Popular Tags