1 19 20 package org.netbeans.modules.apisupport.project.ui.customizer; 21 22 import javax.swing.JFrame ; 23 import javax.swing.ListModel ; 24 import javax.swing.SwingUtilities ; 25 import org.netbeans.modules.apisupport.project.NbModuleProject; 26 import org.netbeans.modules.apisupport.project.TestBase; 27 28 33 public class AddModulePanelTest extends TestBase { 34 35 private AddModulePanel amp; 36 37 public AddModulePanelTest(String name) { 38 super(name); 39 } 40 41 public void testDependenciesFiltering() throws Exception { 42 NbModuleProject p = generateStandaloneModule("module1"); 43 final SingleModuleProperties props = SingleModulePropertiesTest.loadProperties(p); 44 SwingUtilities.invokeAndWait(new Runnable () { 45 public void run() { 46 amp = new AddModulePanel(props); 47 JFrame f = new JFrame (); 48 f.getContentPane().add(amp); 49 f.pack(); 50 } 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 () { 58 public void run() { 59 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 while (CustomizerComponentFactory.isWaitModel(amp.moduleList.getModel())) { 70 Thread.sleep(200); 71 } 72 ListModel model = amp.moduleList.getModel(); 73 int filtered = model.getSize(); 74 final int EXPECTED_MAX = 50; 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 |