KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > validation > IDEValidation


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package validation;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.Toolkit JavaDoc;
24 import java.awt.Window JavaDoc;
25 import java.awt.datatransfer.DataFlavor JavaDoc;
26 import java.awt.datatransfer.UnsupportedFlavorException JavaDoc;
27 import java.awt.event.KeyEvent JavaDoc;
28 import java.io.File JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.lang.Object JavaDoc;
31 import javax.swing.JTextField JavaDoc;
32 import javax.swing.KeyStroke JavaDoc;
33 import javax.swing.tree.TreePath JavaDoc;
34 import junit.textui.TestRunner;
35 import org.netbeans.jellytools.Bundle;
36 import org.netbeans.jellytools.EditorOperator;
37 import org.netbeans.jellytools.FavoritesOperator;
38 import org.netbeans.jellytools.FilesTabOperator;
39 import org.netbeans.jellytools.HelpOperator;
40 import org.netbeans.jellytools.JellyTestCase;
41 import org.netbeans.jellytools.MainWindowOperator;
42 import org.netbeans.jellytools.NbDialogOperator;
43 import org.netbeans.jellytools.NewFileNameLocationStepOperator;
44 import org.netbeans.jellytools.NewFileWizardOperator;
45 import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
46 import org.netbeans.jellytools.NewProjectWizardOperator;
47 import org.netbeans.jellytools.OptionsOperator;
48 import org.netbeans.jellytools.OutputOperator;
49 import org.netbeans.jellytools.OutputTabOperator;
50 import org.netbeans.jellytools.ProjectsTabOperator;
51 import org.netbeans.jellytools.RuntimeTabOperator;
52 import org.netbeans.jellytools.TopComponentOperator;
53 import org.netbeans.jellytools.TreeTableOperator;
54 import org.netbeans.jellytools.WizardOperator;
55 import org.netbeans.jellytools.actions.Action;
56 import org.netbeans.jellytools.actions.ActionNoBlock;
57 import org.netbeans.jellytools.actions.AttachWindowAction;
58 import org.netbeans.jellytools.actions.CompileAction;
59 import org.netbeans.jellytools.actions.CopyAction;
60 import org.netbeans.jellytools.actions.CutAction;
61 import org.netbeans.jellytools.actions.DeleteAction;
62 import org.netbeans.jellytools.actions.NewFileAction;
63 import org.netbeans.jellytools.actions.PasteAction;
64 import org.netbeans.jellytools.actions.ViewAction;
65 import org.netbeans.jellytools.modules.debugger.actions.ContinueAction;
66 import org.netbeans.jellytools.modules.debugger.actions.DebugAction;
67 import org.netbeans.jellytools.modules.debugger.actions.FinishDebuggerAction;
68 import org.netbeans.jellytools.modules.debugger.actions.NewBreakpointAction;
69 import org.netbeans.jellytools.modules.debugger.actions.ToggleBreakpointAction;
70 import org.netbeans.jellytools.nodes.JavaNode;
71 import org.netbeans.jellytools.nodes.Node;
72 import org.netbeans.jellytools.nodes.SourcePackagesNode;
73 import org.netbeans.jellytools.properties.Property;
74 import org.netbeans.jellytools.properties.PropertySheetOperator;
75
76 import org.netbeans.jemmy.ComponentChooser;
77 import org.netbeans.jemmy.EventTool;
78 import org.netbeans.jemmy.JemmyException;
79 import org.netbeans.jemmy.JemmyProperties;
80 import org.netbeans.jemmy.QueueTool;
81 import org.netbeans.jemmy.TestOut;
82 import org.netbeans.jemmy.TimeoutExpiredException;
83 import org.netbeans.jemmy.Waitable;
84 import org.netbeans.jemmy.Waiter;
85 import org.netbeans.jemmy.operators.JButtonOperator;
86 import org.netbeans.jemmy.operators.JDialogOperator;
87 import org.netbeans.jemmy.operators.JLabelOperator;
88 import org.netbeans.jemmy.operators.JRadioButtonOperator;
89 import org.netbeans.jemmy.operators.JTableOperator;
90 import org.netbeans.jemmy.operators.JTextFieldOperator;
91 import org.netbeans.jemmy.operators.JTreeOperator;
92 import org.netbeans.jemmy.operators.Operator;
93 import org.netbeans.jemmy.operators.WindowOperator;
94 import org.netbeans.jemmy.util.PNGEncoder;
95
96 import org.netbeans.junit.NbTestSuite;
97 import org.netbeans.junit.ide.ProjectSupport;
98 import org.openide.windows.Mode;
99 import org.openide.windows.TopComponent;
100 import org.openide.windows.WindowManager;
101
102 /**
103  * Overall validation suite for IDE.
104  *
105  * @author Jiri.Skrivanek@sun.com
106  */

107 public class IDEValidation extends JellyTestCase {
108     
109     /** Need to be defined because of JUnit */
110     public IDEValidation(String JavaDoc name) {
111         super(name);
112     }
113
114     public static NbTestSuite suite() {
115         NbTestSuite suite = new NbTestSuite();
116         suite.addTest(new IDEValidation("testMainMenu"));
117         suite.addTest(new IDEValidation("testHelp"));
118         suite.addTest(new IDEValidation("testOptions"));
119         suite.addTest(new IDEValidation("testOptionsClassicView"));
120         suite.addTest(new IDEValidation("testNewProject"));
121         // sample project must exist before testShortcuts
122
suite.addTest(new IDEValidation("testShortcuts"));
123         suite.addTest(new IDEValidation("testNewFile"));
124         suite.addTest(new IDEValidation("testCVSLite"));
125         suite.addTest(new IDEValidation("testProjectsView"));
126         suite.addTest(new IDEValidation("testFilesView"));
127         suite.addTest(new IDEValidation("testEditor"));
128         suite.addTest(new IDEValidation("testBuildAndRun"));
129         suite.addTest(new IDEValidation("testDebugging"));
130         suite.addTest(new IDEValidation("testJUnit"));
131         suite.addTest(new IDEValidation("testXML"));
132         suite.addTest(new IDEValidation("testUpdateCenter"));
133         suite.addTest(new IDEValidation("testDb"));
134         suite.addTest(new IDEValidation("testWindowSystem"));
135         suite.addTest(new IDEValidation("testSeparateWindowsMode"));
136         suite.addTest(new IDEValidation("testModuleInstallation"));
137         return suite;
138     }
139     
140     /** Use for execution inside IDE */
141     public static void main(java.lang.String JavaDoc[] args) {
142         // run whole suite
143
TestRunner.run(suite());
144         // run only selected test case
145
//junit.textui.TestRunner.run(new IDEValidation("testMainMenu"));
146
}
147     
148     public void setUp() {
149         System.out.println("######## "+getName()+" #######");
150         // Close help window if any - it should not stay open between test cases.
151
// Otherwise it can break next tests.
152
closeHelpWindow();
153     }
154     
155     public void tearDown() {
156     }
157     
158     // name of class created from template and used in tests
159
private static final String JavaDoc JAVA_CLASS_NAME = "Main"; // NOI18N
160
// name of sample frame created and used in tests
161
private static final String JavaDoc SAMPLE_FRAME_NAME = "SampleFrame"; // NOI18N
162
// name of sample project
163
private static final String JavaDoc SAMPLE_PROJECT_NAME = "SampleProject"; // NOI18N
164
// name of first sample package
165
private static final String JavaDoc SAMPLE1_PACKAGE_NAME = "sample1"; //NOI18N
166
// name of second sample package
167
private static final String JavaDoc SAMPLE2_PACKAGE_NAME = "sample2"; //NOI18N
168
// name of sample class
169
private static final String JavaDoc SAMPLE1_CLASS_NAME = "SampleClass1"; // NOI18N
170
// name of sample file
171
private static final String JavaDoc SAMPLE1_FILE_NAME = SAMPLE1_CLASS_NAME+".java"; // NOI18N
172
// name of sample class 2
173
private static final String JavaDoc SAMPLE2_CLASS_NAME = "SampleClass2"; // NOI18N
174
// name of sample file 2
175
private static final String JavaDoc SAMPLE2_FILE_NAME = SAMPLE2_CLASS_NAME+".java"; // NOI18N
176
// name of sample web application project
177
private static final String JavaDoc SAMPLE_WEB_PROJECT_NAME = "SampleWebProject"; //NOI18N
178

179     /** Test creation of java project.
180      * - open New Project wizard from main menu (File|New Project)
181      * - select Java Application project from Standard category
182      * - in the next panel type project name and project location in
183      * - finish the wizard
184      * - wait until project appears in projects view
185      * - wait classpath scanning finished
186      */

187     public void testNewProject() {
188         NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
189         // "Standard"
190
String JavaDoc standardLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard");
191         npwo.selectCategory(standardLabel);
192         // "Java Application"
193
String JavaDoc javaApplicationLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard/emptyJ2SE.xml");
194         npwo.selectProject(javaApplicationLabel);
195         npwo.next();
196         NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
197         npnlso.txtProjectName().setText(SAMPLE_PROJECT_NAME);
198         npnlso.txtProjectLocation().setText(System.getProperty("netbeans.user")); // NOI18N
199
npnlso.finish();
200         // Opening Projects
201
String JavaDoc openingProjectsTitle = Bundle.getString("org.netbeans.modules.project.ui.Bundle", "LBL_Opening_Projects_Progress");
202         try {
203             // wait at most 60 second until progress dialog dismiss
204
JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000);
205             new NbDialogOperator(openingProjectsTitle).waitClosed();
206         } catch (TimeoutExpiredException e) {
207             // ignore when progress dialog was closed before we started to wait for it
208
}
209         // wait project appear in projects view
210
new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME);
211         // wait classpath scanning finished
212
ProjectSupport.waitScanFinished();
213     }
214     
215     /** Test new file wizard.
216      * - open New File wizard from main menu (File|New File)
217      * - select sample project as target
218      * - select Java Classes|Java Package file type
219      * - in the next panel type package name in
220      * - finish the wizard
221      * - open New File wizard from context menu on created package node (New|File)
222      * - select Java Classes|Java Main Class file type
223      * - in the next panel type class name in
224      * - finish the wizard
225      * - check class is open in editor and close all opened documents
226      */

227     public void testNewFile() {
228         // create a new package
229
// "Java Classes"
230
String JavaDoc javaClassesLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes");
231         // "Java Package"
232
String JavaDoc packageLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes/Package");
233         NewFileWizardOperator.create(SAMPLE_PROJECT_NAME, javaClassesLabel, packageLabel, null, SAMPLE1_PACKAGE_NAME);
234         // wait package node is created
235
Node sample1Node = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), SAMPLE1_PACKAGE_NAME);
236         
237         // create a new classes
238

239         // "Java Main Class"
240
String JavaDoc mainClassLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes/Main.java"); // NOI18N
241
NewFileWizardOperator.invoke(sample1Node, javaClassesLabel, mainClassLabel);
242         NewFileNameLocationStepOperator nameStepOper = new NewFileNameLocationStepOperator();
243         nameStepOper.setObjectName(SAMPLE1_CLASS_NAME);
244         nameStepOper.finish();
245         // check class is opened in Editor
246
new EditorOperator(SAMPLE1_FILE_NAME);
247         NewFileWizardOperator.invoke(sample1Node, javaClassesLabel, mainClassLabel);
248         nameStepOper = new NewFileNameLocationStepOperator();
249         nameStepOper.setObjectName(SAMPLE2_CLASS_NAME);
250         nameStepOper.finish();
251         // check class is opened in Editor and then close all documents
252
new EditorOperator(SAMPLE2_FILE_NAME).closeAllDocuments();
253     }
254     
255     /** Test Projects view
256      * - expand source hierarchy and find sample class (SampleClass1.java)
257      * - copy sample class and paste it to the same package
258      * - confirm refactoring dialog
259      * - verify creation of NewClass.java node
260      * - cut NewClass.java
261      * - paste it to another package
262      * - confirm refactoring dialog
263      * - delete NewClass.java node
264      */

265     public void testProjectsView() {
266         ProjectsTabOperator.invoke();
267         // needed for slower machines
268
JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
269
SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
270         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
271         Node sampleClass1Node = new Node(sample1Node, SAMPLE1_FILE_NAME);
272         // test pop-up menu actions
273
// "Copy"
274
CopyAction copyAction = new CopyAction();
275         copyAction.perform(sampleClass1Node);
276         // "Paste"
277
PasteAction pasteAction = new PasteAction();
278         // "Refactor"
279
String JavaDoc refactorItem = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "LBL_Action");
280         // "Copy..."
281
String JavaDoc copyItem = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "LBL_CopyAction");
282         new ActionNoBlock(null, pasteAction.getPopupPath()+"|"+refactorItem+" "+copyItem).perform(sample1Node);
283         
284         String JavaDoc copyClassTitle = Bundle.getString("org.netbeans.modules.refactoring.java.ui.Bundle", "LBL_CopyClass");
285         NbDialogOperator copyClassDialog = new NbDialogOperator(copyClassTitle);
286         // "Refactor"
287
String JavaDoc refactorLabel = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "CTL_Finish");
288         new JButtonOperator(copyClassDialog, refactorLabel).push();
289         
290         Node newClassNode = new Node(sample1Node, "SampleClass11"); // NOI18N
291
newClassNode.select();
292         // "Cut"
293
CutAction cutAction = new CutAction();
294         cutAction.perform(newClassNode);
295         // package created by default when the sample project was created
296
Node sampleProjectPackage = new Node(sourcePackagesNode, SAMPLE_PROJECT_NAME.toLowerCase());
297         // "Move..."
298
String JavaDoc moveItem = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "LBL_MoveAction");
299         new ActionNoBlock(null, pasteAction.getPopupPath()+"|"+refactorItem+" "+moveItem).perform(sampleProjectPackage);
300         // confirm refactoring
301
// "Move Class"
302
String JavaDoc moveClassTitle = Bundle.getString("org.netbeans.modules.refactoring.java.ui.Bundle", "LBL_MoveClass");
303         NbDialogOperator moveClassDialog = new NbDialogOperator(moveClassTitle);
304         new JButtonOperator(moveClassDialog, refactorLabel).push();
305         // "Delete"
306
newClassNode = new Node(sampleProjectPackage, "SampleClass11"); // NOI18N
307
DeleteAction deleteAction = new DeleteAction();
308         deleteAction.perform(newClassNode);
309         // "Confirm Object Deletion"
310
String JavaDoc confirmTitle = Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); // NOI18N
311
new NbDialogOperator(confirmTitle).yes();
312     }
313
314     /** Test Files view
315      * - expand files hierarchy and find sample class (SampleClass1.java)
316      * and select main method node.
317      */

318     public void testFilesView() {
319         FilesTabOperator filesTabOper = FilesTabOperator.invoke();
320         // needed for slower machines
321
JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
322
Node sourcePackagesNode = new Node(filesTabOper.getProjectNode(SAMPLE_PROJECT_NAME), "src"); // NOI18N
323
Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME); // NOI18N
324
Node sampleClass1Node = new Node(sample1Node, SAMPLE1_FILE_NAME);
325         // It is possible to test also pop-up menu actions as in testProjectsView, but
326
// it is redundant IMO
327
}
328
329     
330     /** Test of DB module.
331      * It only tests whether the Databases node is present in Runtime view,
332      * Add Driver action is enabled on Drivers node and Connect action is available
333      * on default JDBC-ODBC Bridge node.
334      * - find Databases|Drivers node in Runtime tab
335      * - open and close Add Driver dialog from context menu on Drivers node
336      * - open and close Connect Using dialog on JDBC-ODBC Bridge node
337      */

338     public void testDb() {
339         // "Databases"
340
String JavaDoc databasesLabel = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NDN_Databases");
341         Node databasesNode = new Node(RuntimeTabOperator.invoke().getRootNode(), databasesLabel);
342         // "Please wait..."
343
String JavaDoc waitNodeLabel = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "WaitNode");
344         // wait until the wait node dismiss and after that start waiting for Drivers node
345
// (see issue http://www.netbeans.org/issues/show_bug.cgi?id=43910 - Creation of
346
// children under Databases node is not properly synchronized)
347
try {
348             databasesNode.waitChildNotPresent(waitNodeLabel);
349         } catch (JemmyException e) {
350             // Ignore and try to continue. Sometimes it happens "Please, wait" node
351
// is still available (maybe some threading issue).
352
log("Timeout expired: "+e.getMessage());
353         }
354         // "Drivers"
355
String JavaDoc driversLabel = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NDN_Drivers");
356         Node driversNode = new Node(RuntimeTabOperator.invoke().getRootNode(), databasesLabel+"|"+driversLabel);
357         // "Add Driver ..."
358
String JavaDoc addDriverItem = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "AddNewDriver");
359         // open a dialog to add a new JDBC driver
360
new ActionNoBlock(null, addDriverItem).perform(driversNode);
361         String JavaDoc addDriverTitle = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "AddDriverDialogTitle");
362         new NbDialogOperator(addDriverTitle).cancel();
363         
364         // wait until the wait node dismiss and after that start waiting for JDBC_ODBC Bridge node
365
// (see issue http://www.netbeans.org/issues/show_bug.cgi?id=43910 - Creation of
366
// children under Databases node is not properly synchronized)
367
try {
368             driversNode.waitChildNotPresent(waitNodeLabel);
369         } catch (JemmyException e) {
370             // Ignore and try to continue. Sometimes it happens "Please, wait" node
371
// is still available (maybe some threading issue).
372
log("Timeout expired: "+e.getMessage());
373         }
374         if(System.getProperty("os.name").toLowerCase().indexOf("mac") == -1) { // NOI18N
375
// node JDBC-ODBC Bridge should be present always but not on mac
376
Node jdbcOdbcNode = new Node(driversNode, "JDBC-ODBC Bridge"); // NOI18N
377
// "Connect Using ..."
378
String JavaDoc connectUsingItem = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "ConnectUsing");
379             // open a dialog to create a new connection
380
new ActionNoBlock(null, connectUsingItem).perform(jdbcOdbcNode);
381             String JavaDoc newDatabaseConnectionTitle = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NewConnectionDialogTitle");
382             new NbDialogOperator(newDatabaseConnectionTitle).cancel();
383         }
384     }
385     
386     /** Test Help
387      * - open Help window from main menu (Help|Help Contents)
388      */

389     public void testHelp() {
390         // increasing time because opening of help window can last longer on slower machines
391
JemmyProperties.setCurrentTimeout("JMenuOperator.PushMenuTimeout", 60000);
392         // open "Help|Contents"
393
HelpOperator helpOper = HelpOperator.invoke();
394         // check help window opened
395
// title is "Help - All"
396
helpOper.close();
397     }
398     
399    /** Test Main Menu
400      * - close Welcome screen to not harm menu actions
401      * - open and close New Project wizard (main menu item File|New Project...)
402      * - open and close Javadoc Index Search top component (main menu item Tools|Javadoc Index Search)
403      */

404     public void testMainMenu() {
405         // close Welcome screen to not harm menu actions
406
// "Welcome
407
String JavaDoc welcomeTitle = Bundle.getString("org.netbeans.modules.welcome.Bundle", "LBL_Tab_Title");
408         new TopComponentOperator(welcomeTitle).close();
409         // open and close New Project wizard
410
int oldDispatchingModel = JemmyProperties.getCurrentDispatchingModel();
411         try {
412             NewProjectWizardOperator.invoke().close();
413         } catch (TimeoutExpiredException e) {
414             // if not succed try it second time in Robot mode
415
// push Escape key to ensure there is no open menu
416
MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
417             JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
418             NewProjectWizardOperator.invoke().close();
419         } finally {
420             // set previous dispatching model
421
JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
422         }
423         // open Tools|Javadoc Index Search
424
String JavaDoc toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N
425
String JavaDoc javadocItem = Bundle.getStringTrimmed("org.netbeans.modules.javadoc.search.Bundle", "CTL_SEARCH_MenuItem");
426         new Action(toolsItem+"|"+javadocItem, null).perform();
427         // "Javadoc Index Search"
428
String JavaDoc javadocTitle = Bundle.getString("org.netbeans.modules.javadoc.search.Bundle", "CTL_SEARCH_WindowTitle");
429         new TopComponentOperator(javadocTitle).close();
430     }
431     
432     /** Test global shortcuts.
433      * - open and close new file wizard (CTRL+N)
434      * - open and close Javadoc Index Search top component (Shift+F1)
435      * - open and close new breakpoint dialog (Ctrl+Shift+F8)
436      */

437     public void testShortcuts() {
438         // test global shortcuts
439
// open new wizard (Ctrl+N)
440
Node node = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
441         // push Escape key to ensure there is no thing blocking shortcut execution
442
MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
443         NewFileAction newFileAction = new NewFileAction();
444         try {
445             newFileAction.performShortcut(node);
446             new NewFileWizardOperator().close();
447             // On some linux it may happen autorepeat is activated and it
448
// opens dialog multiple times. So, we need to close all modal dialogs.
449
// See issue http://www.netbeans.org/issues/show_bug.cgi?id=56672.
450
closeAllModal();
451         } catch (TimeoutExpiredException e) {
452             // need to be realiable test => repeat action once more to be sure it is problem in IDE
453
// this time use events instead of Robot
454
node.select();
455             MainWindowOperator.getDefault().pushKey(
456                     newFileAction.getKeyStrokes()[0].getKeyCode(),
457                     newFileAction.getKeyStrokes()[0].getModifiers());
458             new NewFileWizardOperator().close();
459         }
460         // open Javadoc Index Search (Shift+F1)
461
// "Javadoc Index Search"
462
String JavaDoc javadocTitle = Bundle.getString("org.netbeans.modules.javadoc.search.Bundle",
463                                                "CTL_SEARCH_WindowTitle");
464         Action searchAction = new Action(null, null, KeyStroke.getKeyStroke(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK));
465         try {
466             searchAction.perform(MainWindowOperator.getDefault());
467             new TopComponentOperator(javadocTitle).close();
468         } catch (TimeoutExpiredException e) {
469             // need to be realiable test => repeat action once more to be sure it is problem in IDE
470
// this time use events instead of Robot
471
MainWindowOperator.getDefault().pushKey(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK);
472             new TopComponentOperator(javadocTitle).close();
473         }
474         // open new breakpoint dialog (Ctrl+Shift+F8)
475
String JavaDoc newBreakpointTitle = Bundle.getString("org.netbeans.modules.debugger.ui.actions.Bundle", "CTL_Breakpoint_Title");
476         NewBreakpointAction newBreakpointAction = new NewBreakpointAction();
477         try {
478             newBreakpointAction.performShortcut(MainWindowOperator.getDefault());
479             new NbDialogOperator(newBreakpointTitle).close();
480             // On some linux it may happen autorepeat is activated and it
481
// opens dialog multiple times. So, we need to close all modal dialogs.
482
// See issue http://www.netbeans.org/issues/show_bug.cgi?id=56672.
483
closeAllModal();
484         } catch (TimeoutExpiredException e) {
485             // need to be realiable test => repeat action once more to be sure it is problem in IDE
486
// this time use events instead of Robot
487
MainWindowOperator.getDefault().pushKey(
488                     newBreakpointAction.getKeyStrokes()[0].getKeyCode(),
489                     newBreakpointAction.getKeyStrokes()[0].getModifiers());
490             new NbDialogOperator(newBreakpointTitle).close();
491         }
492     }
493     
494     /** Test Source Editor
495      * - opens sample class in Editor (context menu Open on the node)
496      * - type abbreviation 'sout' at line 27 and then 'Hello'
497      * - verify it is written 'System.out.println("Hello");'
498      * - select the text and call copy from editor's context menu
499      * - insert dummy text at line 28 , select it and paste the text in the clipboard
500      * - select second 'Hello' and delete it by context menu
501      * - insert 'Good bye' instead
502      * - select fourth line, cut it and paste it at line 3
503      */

504     public void testEditor() {
505         // open sample file in Editor
506
SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
507         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
508         JavaNode sampleClass1Node = new JavaNode(sample1Node, SAMPLE1_FILE_NAME);
509         sampleClass1Node.open();
510         // find open file in editor
511
EditorOperator eo = new EditorOperator(SAMPLE1_FILE_NAME);
512         eo.insert("\n", 27, 1); // NOI18N
513
// Need to disable verification because shortcut "sout" is replaced
514
// by "System.out.println("");" and "sout" is not found in Editor
515
eo.setCaretPositionToLine(27);
516         eo.txtEditorPane().setVerification(false);
517         eo.txtEditorPane().typeText("sout"); // NOI18N
518
eo.txtEditorPane().typeKey('\t');
519         eo.txtEditorPane().setVerification(true);
520         eo.insert("Hello"); // NOI18N
521
//eo.insert("System.out.println(\"Hello\");\n", 28, 1); // NOI18N
522
final String JavaDoc textToCopy = "System.out.println(\"Hello\");"; // NOI18N
523
eo.select(textToCopy);
524         int oldDispatchingModel = JemmyProperties.getCurrentDispatchingModel();
525         // "Copy"
526
CopyAction copyAction = new CopyAction();
527         try {
528             copyAction.perform(eo);
529         } catch (TimeoutExpiredException e) {
530             // if not succed try it second time in Robot mode
531
JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
532             copyAction.perform(eo);
533         } finally {
534             // set previous dispatching model
535
JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
536         }
537         // wait until clipboard contains text to copy
538
try {
539             new Waiter(new Waitable() {
540                 public Object JavaDoc actionProduced(Object JavaDoc obj) {
541                     try {
542                         String JavaDoc text = Toolkit.getDefaultToolkit().getSystemClipboard().
543                                         getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
544                         return textToCopy.equals(text) ? Boolean.TRUE:null;
545                     } catch (UnsupportedFlavorException JavaDoc e) {
546                         // The following exception can be thrown when clipboard is empty.
547
// java.awt.datatransfer.UnsupportedFlavorException: Unicode String
548
// at org.openide.util.datatransfer.ExTransferable$Empty.getTransferData(ExTransferable.java:461)
549
// Ignore this exception.
550
return null;
551                     } catch (IOException JavaDoc ioe) {
552                         throw new JemmyException("Failed getting clipboard content.", ioe);
553                     }
554                 }
555                 public String JavaDoc getDescription() {
556                     return("Clipboard contains "+textToCopy); // NOI18N
557
}
558             }).waitAction(null);
559         } catch (Exception JavaDoc ie) {
560             throw new JemmyException("Interrupted.", ie);
561         }
562         eo.insert("int xxxx;\n", 28, 1); // NOI18N
563
eo.select("int xxxx;"); // NOI18N
564
PasteAction pasteAction = new PasteAction();
565         try {
566             pasteAction.perform(eo);
567         } catch (TimeoutExpiredException e) {
568             // if not succed try it second time in Robot mode
569
JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
570             pasteAction.perform(eo);
571         } finally {
572             // set previous dispatching model
573
JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
574         }
575         eo.select("Hello", 1); // NOI18N
576
// "Delete"
577
DeleteAction deleteAction = new DeleteAction();
578         deleteAction.performMenu(eo);
579         // wait Hello is deleted
580
eo.txtEditorPane().waitText("System.out.println(\"\");"); // NOI18N
581
eo.insert("Good bye"); // NOI18N
582
// test cut action
583
eo.select(4);
584         // "Cut"
585
CutAction cutAction = new CutAction();
586         try {
587             cutAction.perform(eo);
588         } catch (TimeoutExpiredException e) {
589             // if not succed try it second time in Robot mode
590
JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
591             cutAction.perform(eo);
592         } finally {
593             // set previous dispatching model
594
JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
595         }
596         // need to wait a little until editor content is refreshed after cut action
597
new EventTool().waitNoEvent(500);
598         // select from column 1 to 2 at line 3
599
eo.select(3, 1, 2);
600         try {
601             pasteAction.perform(eo);
602         } catch (TimeoutExpiredException e) {
603             // if not succed try it second time in Robot mode
604
JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
605             pasteAction.perform(eo);
606         } finally {
607             // set previous dispatching model
608
JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
609         }
610     }
611     
612     /** Test build and run.
613      * - select sample class node and call "Build|Compile "SampleClass1.java"" main menu item
614      * - wait until compilation finishes (track status bar)
615      * - select sample class node and call "Run|Run File|Run "SampleClass1.java"" main menu item
616      * - wait until run finishes
617      * - from context menu set sample project as main project
618      * - call "Build|Build Main Project" main menu item
619      * - wait until build finishes
620      * - call "Run|Run Main Project" main menu item
621      * - wait until run finishes
622      */

623     public void testBuildAndRun() {
624         SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
625         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
626         JavaNode sampleClass1Node = new JavaNode(sample1Node, SAMPLE1_FILE_NAME);
627         // increase timeout to 60 seconds
628
MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 60000);
629         // start to track Main Window status bar
630
MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
631         stt.start();
632         // call Build|Compile main menu item
633
new CompileAction().perform(sampleClass1Node);
634         /* We cannot get this bundle - ti is probably loaded by a different classLoader
635         // "Finished building SampleProject (run)"
636         String finishedLabel = Bundle.getString("org.apache.tools.ant.module.bridge.impl.Bundle",
637                                                 "FMT_finished_target_status",
638                                                 new String[] {SAMPLE_PROJECT_NAME});
639          */

640         // wait message "Building SampleProject (compile-single)..."
641
stt.waitText("compile-single", true); // NOI18N
642
// wait message "Finished building SampleProject (compile-single)"
643
stt.waitText("compile-single", true); // NOI18N
644

645         // "Run"
646
String JavaDoc runItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject");
647         // "Run File"
648
String JavaDoc runOtherItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject/RunOther");
649         // "Run File"
650
String JavaDoc runFileItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle",
651                                                      "LBL_RunSingleAction_Name",
652                                                      new Object JavaDoc[] {new Integer JavaDoc(1), SAMPLE1_FILE_NAME});
653         // call "Run|Run File|Run "SampleClass1.java""
654
new Action(runItem+"|"+runOtherItem+"|"+runFileItem, null).perform(sampleClass1Node);
655         // wait message "Building SampleProject (run-single)..."
656
stt.waitText("run-single", true); // NOI18N
657
// wait message "Finished building SampleProject (run-single)"
658
stt.waitText("run-single", true); // NOI18N
659
// check Hello and Good bye was printed out to the output window
660

661         OutputTabOperator outputOper = new OutputTabOperator("run-single"); //NOI18N
662
outputOper.waitText("Hello"); //NOI18N
663
outputOper.waitText("Good bye"); //NOI18N
664

665         // "Set as Main Project"
666
String JavaDoc setAsMainProjectItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", "LBL_SetAsMainProjectAction_Name");
667         new Action(null, setAsMainProjectItem).perform(new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME));
668         // "Build"
669
String JavaDoc buildItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Build");
670         // "Build Main Project"
671
String JavaDoc buildMainProjectItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", "LBL_BuildMainProjectAction_Name");
672         // call "Build|Build Main Project" main menu item
673
new Action(buildItem+"|"+buildMainProjectItem, null).perform();
674         // wait message "Building SampleProject (jar)..."
675
stt.waitText("jar", true); // NOI18N
676
// wait message "Finished building SampleProject (jar)"
677
stt.waitText("jar", true); // NOI18N
678

679         // Run Main Project
680
String JavaDoc runMainProjectItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", "LBL_RunMainProjectAction_Name");
681         // call "Run|Run Main Project" main menu item
682
new Action(runItem+"|"+runMainProjectItem, null).perform();
683         // wait message "Building SampleProject (run)..."
684
stt.waitText("run", true); // NOI18N
685
// wait message "Finished building SampleProject (run)"
686
stt.waitText("run", true); // NOI18N
687

688         stt.stop();
689     }
690     
691     /** Test JUnit support
692      * - add methods to sample class
693      * - from context menu on sample class node call "Tools|Create JUnit Tests" item
694      * - confirm Create Tests dialog and wait until progress dialog disappears
695      * - find generated test under "Test Packages"
696      * - check whether test was open in editor and if includes test of public,
697      * protected, default but not private methods
698      * - run single test from main menu "Run|Run File|Test SampleClass2.java"
699      * - check status bar that test was executed
700      * - run test project from main menu "Run|Test SampleProject"
701      * - check status bar that test was executed
702      * - from context menu on sample package call "Tools|Create JUnit Tests" item
703      * - confirm Create Tests dialog and wait until progress dialog disappears
704      * - find generated suite under "Test Packages"
705      * - call main menu "Navigate|Go to Test" on sample package
706      * - check if generated suite was opened and if contains generated test class
707      * - close all documents in editor
708      */

709     public void testJUnit() throws InterruptedException JavaDoc {
710         // open sample file in Editor
711
SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
712         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
713         JavaNode sampleClass2Node = new JavaNode(sample1Node, SAMPLE2_FILE_NAME);
714         sampleClass2Node.open();
715         // find open sample file in editor
716
EditorOperator eo = new EditorOperator(SAMPLE2_FILE_NAME);
717         // add methods declarations to sample file
718
String JavaDoc publicMethod = "\n public void publicMethod() {\n }\n"; // NOI18N
719
eo.insert(publicMethod, 29, 1);
720         String JavaDoc privateMethod = "\n private void privateMethod() {\n }\n"; //NOI18N
721
eo.insert(privateMethod, 32, 1);
722         String JavaDoc protectedMethod = "\n protected void protectedMethod() {\n }\n"; //NOI18N
723
eo.insert(protectedMethod, 35, 1);
724         String JavaDoc defaultMethod = "\n void defaultMethod() {\n }\n"; //NOI18N
725
eo.insert(defaultMethod, 38, 1);
726         eo.save();
727
728         // "Tools"
729
String JavaDoc toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N
730
// "Create JUnit Tests"
731
String JavaDoc createTestsItem = Bundle.getString("org.netbeans.modules.junit.Bundle", "LBL_Action_CreateTest"); // NOI18N
732
ActionNoBlock createTestsAction = new ActionNoBlock(null, toolsItem+"|"+createTestsItem);
733         createTestsAction.perform(sampleClass2Node);
734         // "Create Tests"
735
String JavaDoc createTestsTitle = Bundle.getString("org.netbeans.modules.junit.Bundle", "JUnitCfgOfCreate.Title");
736         new NbDialogOperator(createTestsTitle).ok();
737         // "Unit tests generation in progress ..."
738
String JavaDoc progressTitle = Bundle.getString("org.netbeans.modules.junit.Bundle", "LBL_generator_progress_title");
739         // wait until progress dialog is closed
740
new NbDialogOperator(progressTitle).waitClosed();
741         // wait until test node is created
742
// "Test Packages"
743
String JavaDoc testPackagesLabel = Bundle.getString("org.netbeans.modules.java.j2seproject.Bundle", "NAME_test.src.dir");
744         Node testPackagesNode = new Node(new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME), testPackagesLabel);
745         // Test Packages|sample1|SampleClass1Test.java
746
JavaNode testNode = new JavaNode(testPackagesNode, SAMPLE1_PACKAGE_NAME+"|"+SAMPLE2_CLASS_NAME+"Test.java"); // NOI18N
747

748         // check default, protected and public method tests created and private is not created
749
EditorOperator eoTest = new EditorOperator(SAMPLE2_CLASS_NAME+"Test.java"); // NOI18N
750
// wait code is generated
751
new Waiter(new Waitable() {
752             public Object JavaDoc actionProduced(Object JavaDoc editorOper) {
753                 return ((EditorOperator)editorOper).contains("testDefaultMethod") ? Boolean.TRUE : null;
754             }
755             public String JavaDoc getDescription() {
756                 return("Created test should include test of default method."); // NOI18N
757
}
758         }).waitAction(eoTest);
759         new Waiter(new Waitable() {
760             public Object JavaDoc actionProduced(Object JavaDoc editorOper) {
761                 return ((EditorOperator)editorOper).contains("testProtectedMethod") ? Boolean.TRUE : null;
762             }
763             public String JavaDoc getDescription() {
764                 return("Created test should include test of protected method."); // NOI18N
765
}
766         }).waitAction(eoTest);
767         new Waiter(new Waitable() {
768             public Object JavaDoc actionProduced(Object JavaDoc editorOper) {
769                 return ((EditorOperator)editorOper).contains("testPublicMethod") ? Boolean.TRUE : null;
770             }
771             public String JavaDoc getDescription() {
772                 return("Created test should include test of public method."); // NOI18N
773
}
774         }).waitAction(eoTest);
775         assertFalse("Created test should not include test of private method.", eoTest.contains("testPrivateMethod")); // NOI18N
776

777         // run generated test
778

779         // "Run"
780
String JavaDoc runItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject");
781         // "Run File"
782
String JavaDoc runOtherItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject/RunOther");
783         // "Test File"
784
String JavaDoc testFileItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle",
785                                                      "LBL_TestSingleAction_Name",
786                                                      new Object JavaDoc[] {new Integer JavaDoc(1), SAMPLE2_FILE_NAME});
787         // "Test Project"
788
String JavaDoc testProjectItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle",
789                                                      "LBL_TestProjectAction_Name",
790                                                      new Object JavaDoc[] {new Integer JavaDoc(1), SAMPLE_PROJECT_NAME});
791                                                      
792         // increase timeout to 60 seconds
793
MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 60000); // NOI18N
794
// start to track Main Window status bar
795
MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
796         stt.start();
797          // call "Run|Run File|Test "SampleClass2.java""
798
new Action(runItem+"|"+runOtherItem+"|"+testFileItem, null).perform(sampleClass2Node);
799         // wait message "Building SampleProject (test-single)..."
800
stt.waitText("test-single", true); // NOI18N
801
// wait message "Build of SampleProject (test-single) failed."
802
stt.waitText("test-single", true); // NOI18N
803

804          // call "Run|Test "SampleProject""
805
new Action(runItem+"|"+testProjectItem, null).perform(sampleClass2Node);
806          // wait message "Building SampleProject (test)..."
807
stt.waitText("test", true); // NOI18N
808
// wait message "Build of SampleProject (test) failed."
809
stt.waitText("test", true); // NOI18N
810
stt.stop();
811         
812         // test JUnit on folder
813
createTestsAction.perform(sample1Node);
814         new NbDialogOperator(createTestsTitle).ok();
815         // wait until progress dialog is closed
816
new NbDialogOperator(progressTitle).waitClosed();
817         // wait until test node is created
818
// Test Packages|sample1|Sample1Suite.java
819
JavaNode suiteNode = new JavaNode(testPackagesNode, SAMPLE1_PACKAGE_NAME+"|Suite.java"); // NOI18N
820
// go to test suite
821
// "Navigate"
822
String JavaDoc navigateItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/GoTo"); // NOI18N
823
// "Go to Test"
824
String JavaDoc goToTestItem = Bundle.getString("org.netbeans.modules.junit.Bundle", "LBL_Action_GoToTest"); // NOI18N
825
// go to test ("Navigate|Go to Test") - main menu action
826
Action gotoTestAction = new Action(navigateItem+"|"+goToTestItem, null);
827         gotoTestAction.perform(sample1Node);
828         // check suite is open in editor and it conteins generated test class
829
assertTrue("Created suite should include test of public method.",
830                    new EditorOperator("Suite").contains(SAMPLE2_CLASS_NAME+"Test")); // NOI18N
831
EditorOperator.closeDiscardAll();
832     }
833
834     /** Test Debugging
835      * - find sample class in editor
836      * - select text 'System.out.println("Hello");' and push Shift+F8 to toggle breakpoint
837      * - select text 'System.out.println("Good bye");' and call 'Toggle Breakpoint" context menu item
838      * - run debugger from main menu ("Run "SampleClass1.java" in Debugger")
839      * - wait until first breakpoint is reached and call Continue from main menu
840      * - wait until second breakpoint is reached and check 'Hello' is printed to output
841      * - finish debugger by main menu action (Finish Debugger Session)
842      * - delete sample class
843      */

844     public void testDebugging() throws Throwable JavaDoc {
845         // Status bar tracer
846
MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
847         SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
848         JavaNode sampleClass1Node = new JavaNode(sourcePackagesNode, SAMPLE1_PACKAGE_NAME+"|"+SAMPLE1_FILE_NAME);
849         try {
850             // find sample file in Editor
851
EditorOperator eo = new EditorOperator(SAMPLE1_FILE_NAME);
852
853             // if file not contains brpText from previous test cases, insert it
854
String JavaDoc brpText = "System.out.println(\"Hello\");"; // NOI18N
855
if(!eo.contains(brpText)) {
856                 eo.insert(brpText+"\n", 27, 1);
857             }
858             eo.select(brpText);
859             
860             ToggleBreakpointAction toggleBreakpointAction = new ToggleBreakpointAction();
861             // toggle breakpoint via Shift+F8
862
toggleBreakpointAction.performShortcut(eo);
863
864             // wait breakpoint established
865
new Waiter(new Waitable() {
866                 public Object JavaDoc actionProduced(Object JavaDoc editorOper) {
867                     Object JavaDoc[] annotations = ((EditorOperator)editorOper).getAnnotations(27);
868                     for (int i = 0; i < annotations.length; i++) {
869                         if("Breakpoint".equals(((EditorOperator)editorOper).getAnnotationType(annotations[i]))) { // NOI18N
870
return Boolean.TRUE;
871                         }
872                     }
873                     return null;
874                 }
875                 public String JavaDoc getDescription() {
876                     return("Wait breakpoint established on line 27"); // NOI18N
877
}
878             }).waitAction(eo);
879             
880             // if file not contains second brpText from previous test cases, insert it
881
brpText = "System.out.println(\"Good bye\");"; // NOI18N
882
if(!eo.contains(brpText)) {
883                 eo.insert(brpText+"\n", 28, 1);
884             }
885             eo.select(brpText);
886             // toggle breakpoint via pop-up menu
887
// clickForPopup(0, 0) used in the past sometimes caused that menu
888
// was opened outside editor area because editor roll up after
889
// text was selected
890
toggleBreakpointAction.perform(eo.txtEditorPane());
891             // wait second breakpoint established
892
new Waiter(new Waitable() {
893                 public Object JavaDoc actionProduced(Object JavaDoc editorOper) {
894                     Object JavaDoc[] annotations = ((EditorOperator)editorOper).getAnnotations(28);
895                     for (int i = 0; i < annotations.length; i++) {
896                         if("Breakpoint".equals(((EditorOperator)editorOper).getAnnotationType(annotations[i]))) { // NOI18N
897
return Boolean.TRUE;
898                         }
899                     }
900                     return null;
901                 }
902                 public String JavaDoc getDescription() {
903                     return("Wait breakpoint established on line 28"); // NOI18N
904
}
905             }).waitAction(eo);
906             // start to track Main Window status bar
907
stt.start();
908             // start debugging
909
new DebugAction().performMenu(sampleClass1Node);
910             // check the first breakpoint reached
911
// wait status text "Thread main stopped at SampleClass1.java:27"
912
// increase timeout to 60 seconds
913
MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 60000);
914             String JavaDoc label27 = Bundle.getString("org.netbeans.modules.debugger.jpda.ui.Bundle",
915                     "CTL_Thread_stopped",
916                     new String JavaDoc[] {"main", SAMPLE1_FILE_NAME, null, "27"}); // NOI18N
917
stt.waitText(label27);
918             // continue debugging
919
new ContinueAction().perform();
920             // check the second breakpoint reached
921
// wait status text "Thread main stopped at SampleClass1.java:28"
922
String JavaDoc label28 = Bundle.getString("org.netbeans.modules.debugger.jpda.ui.Bundle",
923                     "CTL_Thread_stopped",
924                     new String JavaDoc[] {"main", SAMPLE1_FILE_NAME, null, "28"}); // NOI18N
925
stt.waitText(label28);
926             // check "Hello" was printed out in Output
927
OutputTabOperator oto = new OutputTabOperator("debug-single"); // NOI18N
928
// wait until text Hello is not written in to the Output
929
oto.waitText("Hello"); // NOI18N
930
} catch (Throwable JavaDoc th) {
931             try {
932                 // capture screen before cleanup in finally clause is completed
933
PNGEncoder.captureScreen(getWorkDir().getAbsolutePath()+File.separator+"screenBeforeCleanup.png");
934             } catch (Exception JavaDoc e1) {
935                 // ignore it
936
}
937             throw th;
938         } finally {
939             // finish debugging
940
new FinishDebuggerAction().perform();
941             // check status line
942
// "SampleProject (debug-single)"
943
String JavaDoc outputTarget = Bundle.getString(
944                     "org.apache.tools.ant.module.run.Bundle",
945                     "TITLE_output_target",
946                     new Object JavaDoc[] {SAMPLE_PROJECT_NAME, null, "debug-single"}); // NOI18N
947
// "Finished building SampleProject (debug-single)"
948
String JavaDoc finishedMessage = Bundle.getString(
949                     "org.apache.tools.ant.module.run.Bundle",
950                     "FMT_finished_target_status",
951                     new Object JavaDoc[] {outputTarget});
952             stt.waitText(finishedMessage);
953             stt.stop();
954             // delete sample class
955
sampleClass1Node.delete();
956             String JavaDoc confirmTitle = Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); // NOI18N
957
// "Confirm Object Deletion"
958
new NbDialogOperator(confirmTitle).yes();
959         }
960     }
961
962      /** Test Options
963       * - open Options window from main menu Tools|Options
964       * - select General category
965       * - pick HTTP Proxy
966       * - set Proxy Host to webcache
967       * - set Proxy Port to 8080
968       * - click OK to confirm and close Options window
969       */

970     public void testOptions() {
971         OptionsOperator optionsOper = OptionsOperator.invoke();
972         optionsOper.selectGeneral();
973         // "HTTP Proxy"
974
String JavaDoc hTTPProxyLabel = Bundle.getStringTrimmed(
975                 "org.netbeans.modules.options.general.Bundle", "CTL_Use_HTTP_Proxy");
976         new JRadioButtonOperator(optionsOper, hTTPProxyLabel).push();
977         // "Proxy Host:"
978
String JavaDoc proxyHostLabel = Bundle.getStringTrimmed(
979                 "org.netbeans.modules.options.general.Bundle", "CTL_Proxy_Host");
980         JLabelOperator jloHost = new JLabelOperator(optionsOper, proxyHostLabel);
981         new JTextFieldOperator((JTextField JavaDoc)jloHost.getLabelFor()).typeText("webcache"); // NOI18N
982
// "Proxy Port"
983
String JavaDoc proxyPortLabel = Bundle.getStringTrimmed(
984                 "org.netbeans.modules.options.general.Bundle", "CTL_Proxy_Port");
985         JLabelOperator jloPort = new JLabelOperator(optionsOper, proxyPortLabel);
986         new JTextFieldOperator((JTextField JavaDoc)jloPort.getLabelFor()).setText("8080"); // NOI18N
987
optionsOper.ok();
988     }
989
990      /** Test Advanced Options (former Classic view). Options in Classic view should be gradually
991       * replaced by basic options (former Modern view). When it happens this test case
992       * can be removed.
993       * - open Options window from main menu Tools|Options
994       * - select IDE Configuration|System|Print Settings node
995       * - set Page Footer Alignment to "LEFT"
996       * - set Line Ascent Correction to "2.0"
997       * - set Wrap Lines to "false"
998       * - close Options window
999       */

1000    public void testOptionsClassicView() {
1001        OptionsOperator optionsOper = OptionsOperator.invoke();
1002        optionsOper.switchToClassicView();
1003        // set exact comparator because in Japanese there is conflict with Filesystem settings
1004
optionsOper.treeTable().tree().setComparator(new Operator.DefaultStringComparator(true, true));
1005        // "IDE Configuration|System|Print Settings"
1006
String JavaDoc printSettingsPath = Bundle.getString("org.netbeans.core.Bundle", "UI/Services/IDEConfiguration") + "|" +
1007                                   Bundle.getString("org.netbeans.core.Bundle", "UI/Services/IDEConfiguration/System")+"|"+
1008                                   Bundle.getString("org.netbeans.core.Bundle", "Services/org-openide-text-PrintSettings.settings");
1009        optionsOper.selectOption(printSettingsPath);
1010        PropertySheetOperator pso = new PropertySheetOperator(optionsOper);
1011        // "Page Footer Alignment"
1012
String JavaDoc footerALLabel = Bundle.getString("org.openide.text.Bundle", "PROP_FOOTER_ALIGNMENT");
1013        // "LEFT"
1014
String JavaDoc leftLabel = Bundle.getString("org.openide.util.Bundle", "LEFT");
1015        new Property(pso, footerALLabel).setValue(leftLabel);
1016        // "Line Ascent Correction"
1017
String JavaDoc lineACLabel = Bundle.getString("org.openide.text.Bundle", "PROP_LINE_ASCENT_CORRECTION");
1018        new Property(pso, lineACLabel).setValue("2.0");
1019        // "Wrap Lines"
1020
String JavaDoc wrapLinesLabel = Bundle.getString("org.openide.text.Bundle", "PROP_WRAP");
1021        new Property(pso, wrapLinesLabel).setValue("false");
1022        optionsOper.close();
1023    }
1024    
1025    /** Test Update Center
1026     * - open Update Center Wizard from main menu Tools|Update Center
1027     * - go next
1028     * - wait until connection dialog dismiss
1029     * - in modules tree select requested module
1030     * - click right arrow button and go next
1031     * - accept license dialog
1032     * - wait until download is finished and finish the wizard
1033     */

1034    public void testUpdateCenter() {
1035        // "Tools"
1036
String JavaDoc toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N
1037
WizardOperator updateCenterWizardOper = null;
1038        long oldWaitStateTime = JemmyProperties.getCurrentTimeout("ComponentOperator.WaitStateTimeout");
1039        try {
1040            // "Update Center"
1041
String JavaDoc updateCenterItem = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "CTL_Update");
1042            new Action(toolsItem+"|"+updateCenterItem, null).perform();
1043            // "Update Center Wizard"
1044
String JavaDoc updateCenterTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Wizard");
1045            updateCenterWizardOper = new WizardOperator(updateCenterTitle);
1046            // disable Forte for Java Update Center if any
1047
JTableOperator oper = new JTableOperator(updateCenterWizardOper);
1048            // check each row
1049
for(int i=0;i<oper.getRowCount();i++) {
1050                // if Update Center matches "Forte" and it is enabled/checked then click to uncheck
1051
if(oper.getValueAt(i, 1).toString().indexOf("Forte")>-1 && ((Boolean JavaDoc)oper.getValueAt(i, 0)).booleanValue()) { // NOI18N
1052
oper.clickOnCell(i, 0);
1053                }
1054                // if Update Center matches "Sun ONE Studio" and it is enabled/checked then click to uncheck
1055
if(oper.getValueAt(i, 1).toString().indexOf("Sun")>-1 && ((Boolean JavaDoc)oper.getValueAt(i, 0)).booleanValue()) { // NOI18N
1056
oper.clickOnCell(i, 0);
1057                }
1058            }
1059
1060            // proxy is set to webcache:8080 in testOptions
1061

1062            // "Next >"
1063
updateCenterWizardOper.btNext().pushNoBlock();
1064            // wait connecting dialog appears
1065
// "Connecting"
1066
String JavaDoc connectingTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Connecting_Title");
1067            // wait at most 60 second until connecting dialog dismiss
1068
JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", 60000);
1069            new NbDialogOperator(connectingTitle).waitClosed();
1070            // wait JTree generated on next page
1071
new EventTool().waitNoEvent(500);
1072            // select Web|Applet module
1073
JTreeOperator tree = new JTreeOperator(updateCenterWizardOper);
1074            // "Development Update Center
1075
String JavaDoc devUCLabel = Bundle.getString("org.netbeans.modules.updatecenters.resources.Bundle", "Services/AutoupdateType/autoupdate_xml_type.settings");
1076            new Node(tree, devUCLabel+"|Infrastructure|Convertor").select(); // NOI18N
1077
// "Add >"
1078
String JavaDoc addLabel = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "BTN_Add_2");
1079            // add to right panel (push "Add >" button)
1080
new JButtonOperator(updateCenterWizardOper, addLabel).push();
1081            // push "Next" button
1082
updateCenterWizardOper.btNext().pushNoBlock();
1083            // accept license agreement
1084
// "License Agreement"
1085
String JavaDoc licenceTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Licence_Title");
1086            // "Accept"
1087
String JavaDoc acceptLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Licence_Accept");
1088            new JButtonOperator(new NbDialogOperator(licenceTitle), acceptLabel).push();
1089            // wait 30 s until download is done
1090
JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 30000); // NOI18N
1091
// "Done."
1092
String JavaDoc doneLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "DownloadProgressPanel.jLabel1.doneText");
1093            new JLabelOperator(updateCenterWizardOper, doneLabel);
1094            updateCenterWizardOper.next();
1095            // accept certificate if requested
1096
if(!updateCenterWizardOper.btFinish().isEnabled()) {
1097                // "View Certificate..."
1098
String JavaDoc viewCertificateLable = Bundle.getStringTrimmed("org.netbeans.modules.autoupdate.Bundle", "BTN_View");
1099                new JButtonOperator(updateCenterWizardOper, viewCertificateLable).pushNoBlock();
1100                // click on "Accept" button in dialog
1101
String JavaDoc acceptCertificateLabel = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Certificate_Accept");
1102                // "Module Certificate"
1103
String JavaDoc certificateTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Certificate_Title");
1104                new JButtonOperator(new JDialogOperator(certificateTitle), acceptCertificateLabel).push();
1105            }
1106            // "Finish"
1107
updateCenterWizardOper.btFinish().push();
1108        } catch (JemmyException e) {
1109            // close possible error dialog
1110
// "Error"
1111
String JavaDoc errorTitle = Bundle.getString("org.netbeans.modules.autoupdate.Bundle", "CTL_Error");
1112            if(JDialogOperator.findJDialog(errorTitle, true, true) != null) {
1113                new NbDialogOperator(errorTitle).close();
1114            }
1115            // close Update center dialog
1116
if(updateCenterWizardOper != null) {
1117                updateCenterWizardOper.close();
1118            }
1119            throw e;
1120        } finally {
1121            // restore default timeout
1122
JemmyProperties.setCurrentTimeout("ComponentOperator.WaitStateTimeout", oldWaitStateTime);
1123        }
1124    }
1125    
1126    /** Test CVS Lite
1127     * - from main menu invoke "Versioning|CVS|Checkout"
1128     * - wait for Checkout dialog and close it
1129     * TODO - when better support for local repository implemented, we can add more tests
1130     */

1131    // TODO: There is no CVS top level menu anymore
1132
public void testCVSLite() {
1133        // "Versioning"
1134
String JavaDoc versioningItem = Bundle.getStringTrimmed("org.netbeans.modules.versioning.Bundle", "Menu/Window/Versioning");
1135        // "CVS"
1136
String JavaDoc cvsItem = Bundle.getStringTrimmed(
1137                "org.netbeans.modules.versioning.system.cvss.ui.actions.Bundle",
1138                "CTL_MenuItem_CVSCommands_Label");
1139        // "Checkout..."
1140
String JavaDoc checkoutItem = Bundle.getStringTrimmed(
1141                "org.netbeans.modules.versioning.system.cvss.ui.actions.checkout.Bundle",
1142                "CTL_MenuItem_Checkout_Label");
1143        new ActionNoBlock(versioningItem+"|"+cvsItem+"|"+checkoutItem, null).perform();
1144
1145        String JavaDoc checkoutTitle = Bundle.getString(
1146                "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
1147                "BK0007");
1148        NbDialogOperator checkoutOper = new NbDialogOperator(checkoutTitle);
1149        checkoutOper.close();
1150    }
1151    
1152    /** Test XML
1153     * It checks XML Entity Catalogs node is present in the Runtime tab,
1154     * creates an XML document from template, checks XML, validates XML,
1155     * generates DTD, checks DTD and generates DOM Tree Scanner.
1156     */

1157    public void testXML() {
1158        // check XML Entity Catalogs
1159

1160        // "DTD and XML Schema Catalogs"
1161
String JavaDoc catalogsLabel = Bundle.getString("org.netbeans.modules.xml.catalog.Bundle", "TEXT_catalog_root");
1162        // "NetBeans Catalog"
1163
String JavaDoc netbeansCatalogLabel = Bundle.getString("org.netbeans.modules.xml.catalog.impl.Bundle", "NAME_system_catalog");
1164        String JavaDoc publicID = "-//DTD XMLCatalog//EN";
1165        Node catalogNode = new Node(RuntimeTabOperator.invoke().getRootNode(),
1166                                    catalogsLabel+"|"+
1167                                    netbeansCatalogLabel+"|"+
1168                                    publicID);
1169        // view and close it
1170
new ViewAction().perform(catalogNode);
1171        new EditorOperator(publicID).close();
1172        
1173        // create an XML file
1174

1175        Node sample1Node = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), SAMPLE1_PACKAGE_NAME);
1176        // create xml package
1177
// select Source Packages to not create xml folder in Test Packages
1178
new SourcePackagesNode(SAMPLE_PROJECT_NAME).select();
1179        // "Java Classes"
1180
String JavaDoc javaClassesLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes");
1181        // "Java Package"
1182
String JavaDoc packageLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes/Package");
1183        NewFileWizardOperator.create(SAMPLE_PROJECT_NAME, javaClassesLabel, packageLabel, null, "xml"); // NOI18N
1184
Node xmlNode = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), "xml"); //NOI18N
1185
// "XML"
1186
String JavaDoc xmlCategory = Bundle.getString("org.netbeans.api.xml.resources.Bundle", "Templates/XML");
1187        // "XML Document"
1188
String JavaDoc xmlDocument = Bundle.getString("org.netbeans.modules.xml.core.resources.Bundle", "Templates/XML/XMLDocument.xml");
1189        NewFileWizardOperator.invoke(xmlNode, xmlCategory, xmlDocument);
1190        NewFileNameLocationStepOperator nameStepOper = new NewFileNameLocationStepOperator();
1191        nameStepOper.setObjectName("XMLDocument"); // NOI18N
1192
nameStepOper.next();
1193        nameStepOper.finish();
1194        // wait node is present
1195
Node xmlDocumentNode = new Node(xmlNode, "XMLDocument.xml"); // NOI18N
1196
// wait xml document is open in editor
1197
new EditorOperator("XMLDocument.xml").close(); // NOI18N
1198

1199        // "Check XML"
1200

1201        String JavaDoc checkXMLItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.actions.Bundle", "NAME_Check_XML");
1202        // invoke context action to check xml
1203
new Action(null, checkXMLItem).perform(xmlDocumentNode);
1204        // "XML check"
1205
String JavaDoc xmlCheckTitle = Bundle.getString("org.netbeans.modules.xml.core.actions.Bundle", "TITLE_XML_check_window");
1206        // find and close an output with the result of xml check
1207
new OutputTabOperator(xmlCheckTitle).close();
1208        
1209        // "Validate XML"
1210

1211        String JavaDoc validateItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.actions.Bundle", "NAME_Validate_XML");
1212        // invoke context action to validate xml
1213
new Action(null, validateItem).perform(xmlDocumentNode);
1214        // find and close an output with the result of xml validation
1215
new OutputTabOperator(xmlCheckTitle).close();
1216        
1217        // "Generate DTD..."
1218

1219        String JavaDoc generateDTDItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.generator.Bundle", "PROP_GenerateDTD");
1220        new ActionNoBlock(null, generateDTDItem).perform(xmlDocumentNode);
1221        // "Select File Name"
1222
String JavaDoc selectTitle = Bundle.getString("org.netbeans.modules.xml.tools.generator.Bundle", "PROP_fileNameTitle");
1223        NbDialogOperator selectDialog = new NbDialogOperator(selectTitle);
1224        // name has to be set because of issue http://www.netbeans.org/issues/show_bug.cgi?id=46049
1225
new JTextFieldOperator(selectDialog).setText("DTD");
1226        String JavaDoc oKLabel = Bundle.getString("org.netbeans.core.windows.services.Bundle", "OK_OPTION_CAPTION");
1227        new JButtonOperator(selectDialog, oKLabel).push();
1228        // wait DTD is open in editor
1229
new EditorOperator("DTD.dtd").close(); // NOI18N
1230
Node dtdNode = new Node(xmlNode, "DTD.dtd"); // NOI18N
1231

1232        // "Check DTD"
1233

1234        String JavaDoc checkDTDItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.actions.Bundle", "NAME_Validate_DTD");
1235        new Action(null, checkDTDItem).perform(dtdNode);
1236        // find and close an output with the result of dtd check
1237
new OutputTabOperator(xmlCheckTitle).close();
1238        
1239        // "Generate DOM Tree Scanner"
1240

1241        String JavaDoc generateScannerItem = Bundle.getStringTrimmed("org.netbeans.modules.xml.tools.generator.Bundle", "PROP_GenerateDOMScanner");
1242        new ActionNoBlock(null, generateScannerItem).perform(dtdNode);
1243        selectDialog = new NbDialogOperator(selectTitle);
1244        new JButtonOperator(selectDialog, oKLabel).push();
1245        // wait Scanner is open in editor
1246
new EditorOperator("DTDScanner.java").close(); // NOI18N
1247
Node scannerNode = new Node(xmlNode, "DTDScanner.java"); // NOI18N
1248

1249        // clean up
1250

1251        // delete xml folder and its contents
1252
DeleteAction deleteAction = new DeleteAction();
1253        deleteAction.perform(xmlNode);
1254        // "Confirm Object Deletion"
1255
String JavaDoc confirmTitle = Bundle.getString("org.openide.explorer.Bundle", "MSG_ConfirmDeleteObjectTitle"); // NOI18N
1256
new NbDialogOperator(confirmTitle).yes();
1257        xmlNode.waitNotPresent();
1258    }
1259
1260    /** Test Window System
1261     * - open Favorites top component from main menu Window|Favorites
1262     * - attach Favorites as last tab to output mode
1263     * - attach Favorites to top of Projects tab
1264     * - attach Favorites to right of output mode
1265     * - attach Favorites as last tab to explorer mode (next to Projects)
1266     * - close Favorites
1267     * - open sample1|SampleClass2.java file
1268     * - maximize opened editor by menu item "Maximize Window" on its tab
1269     * - restore editor by menu item "Restore Window" on its tab
1270     * - close all open editors
1271     */

1272    public void testWindowSystem() {
1273        final ProjectsTabOperator projectsOper = ProjectsTabOperator.invoke();
1274        final FavoritesOperator favoritesOper = FavoritesOperator.invoke();
1275        
1276        // test attaching
1277
favoritesOper.attachTo(new OutputOperator(), AttachWindowAction.AS_LAST_TAB);
1278        favoritesOper.attachTo(projectsOper, AttachWindowAction.TOP);
1279        favoritesOper.attachTo(new OutputOperator(), AttachWindowAction.RIGHT);
1280        favoritesOper.attachTo(projectsOper, AttachWindowAction.AS_LAST_TAB);
1281        // wait until TopComponent is in new location and is showing
1282
final TopComponent projectsTc = (TopComponent)projectsOper.getSource();
1283        final TopComponent favoritesTc = (TopComponent)favoritesOper.getSource();
1284        try {
1285            new Waiter(new Waitable() {
1286                public Object JavaDoc actionProduced(Object JavaDoc tc) {
1287                    // run in dispatch thread
1288
Mode mode1 = (Mode)projectsOper.getQueueTool().invokeSmoothly(new QueueTool.QueueAction("findMode") { // NOI18N
1289
public Object JavaDoc launch() {
1290                            return WindowManager.getDefault().findMode(projectsTc);
1291                        }
1292                    });
1293                    Mode mode2 = (Mode)favoritesOper.getQueueTool().invokeSmoothly(new QueueTool.QueueAction("findMode") { // NOI18N
1294
public Object JavaDoc launch() {
1295                            return WindowManager.getDefault().findMode(favoritesTc);
1296                        }
1297                    });
1298                    return (mode1==mode2 && favoritesTc.isShowing()) ? Boolean.TRUE : null;
1299                }
1300                public String JavaDoc getDescription() {
1301                    return("Favorites TopComponent is next to Projects TopComponent."); // NOI18N
1302
}
1303            }).waitAction(null);
1304        } catch (InterruptedException JavaDoc e) {
1305            throw new JemmyException("Interrupted.", e); // NOI18N
1306
}
1307        favoritesOper.close();
1308
1309        // test maximize/restore
1310
// open sample file in Editor
1311
SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
1312        Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
1313        JavaNode sampleClass2Node = new JavaNode(sample1Node, SAMPLE2_FILE_NAME);
1314        sampleClass2Node.open();
1315        // find open file in editor
1316
EditorOperator eo = new EditorOperator(SAMPLE2_FILE_NAME);
1317        eo.maximize();
1318        eo.restore();
1319        eo.closeDiscardAll();
1320    }
1321
1322    /** Test Separate Windows Mode
1323     * - switch to separate windows mode
1324     * - check whether Projects and Output are in separate window
1325     * - switch back to the default compact windows mode
1326     * Note: It happens editor area enlarge itself to cover all main window area.
1327     * That's why it is recommended to put this test to the end of the suite.
1328     */

1329    public void testSeparateWindowsMode() {
1330        try {
1331            MainWindowOperator.getDefault().setSeparateMode();
1332            assertFalse("Projects has to be in separate frame.", new ProjectsTabOperator().getWindow() == MainWindowOperator.getDefault().getSource());
1333            assertFalse("Output has to be in separate frame.", new OutputOperator().getWindow() == MainWindowOperator.getDefault().getSource());
1334        } finally {
1335            // set back to the compact mode
1336
MainWindowOperator.getDefault().setCompactMode();
1337        }
1338    }
1339
1340    /** Test Module installation.
1341     * - open Module Manager window from main menu Tools|Module Manager
1342     * - find Image module
1343     * - disable Image module
1344     * - wait until it is turned off
1345     * - enable module again
1346     * - wait until it is enabled
1347     * - close Module Manager window
1348     */

1349    public void testModuleInstallation() {
1350        // "Tools"
1351
String JavaDoc toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N
1352
// "Module Manager"
1353
String JavaDoc moduleManagerLabel = Bundle.getString("org.netbeans.modules.autoupdate.catalog.Bundle", "LBL_ModuleCatalogName");
1354        new Action(toolsItem+"|"+moduleManagerLabel, null).perform();
1355        NbDialogOperator moduleManagerOper = new NbDialogOperator(moduleManagerLabel);
1356        // Data Files|Image
1357
String JavaDoc imageModulePath =
1358            Bundle.getString("org.netbeans.modules.image.Bundle", "OpenIDE-Module-Display-Category") + "|" + // Data Files
1359
Bundle.getString("org.netbeans.modules.image.Bundle", "OpenIDE-Module-Name"); // Image
1360
TreeTableOperator treeTableOper = new TreeTableOperator(moduleManagerOper);
1361        TreePath JavaDoc path = treeTableOper.tree().findPath(imageModulePath, "|");
1362        if(!treeTableOper.tree().isPathSelected(path)) {
1363            treeTableOper.tree().selectPath(path);
1364        }
1365        int rowNumber = treeTableOper.tree().getRowForPath(path);
1366        treeTableOper.scrollToCell(rowNumber, 0);
1367        new EventTool().waitNoEvent(500);
1368        // click check box to disable module
1369
treeTableOper.clickOnCell(rowNumber, 1);
1370        // check Status line
1371
// "Turning off modules...done."
1372
String JavaDoc turningOffLabel = Bundle.getString("org.netbeans.core.startup.Bundle", "MSG_finish_disable_modules");
1373        // increase timeout to 120 seconds
1374
MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 120000);
1375        MainWindowOperator.getDefault().waitStatusText(turningOffLabel);
1376        new EventTool().waitNoEvent(1000);
1377        // click check box to enable module
1378
treeTableOper.clickOnCell(rowNumber, 1);
1379        // check Status line
1380
// "Turning on modules...done."
1381
String JavaDoc turningOnLabel = Bundle.getString("org.netbeans.core.startup.Bundle", "MSG_finish_enable_modules");
1382        // increase timeout to 120 seconds
1383
MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 120000);
1384        MainWindowOperator.getDefault().waitStatusText(turningOnLabel);
1385        moduleManagerOper.close();
1386    }
1387
1388    /** Closes help window if any. It should not stay open between test cases.
1389     * Otherwise it can break next tests.
1390     */

1391    private static void closeHelpWindow() {
1392        Window JavaDoc helpWindow = WindowOperator.findWindow(new ComponentChooser() {
1393            public boolean checkComponent(Component JavaDoc comp) {
1394                WindowOperator winOper = new WindowOperator((Window JavaDoc)comp);
1395                winOper.setOutput(TestOut.getNullOutput());
1396                return null != winOper.findSubComponent(new ComponentChooser() {
1397                    public boolean checkComponent(Component JavaDoc comp) {
1398                        return comp.getClass().getName().startsWith("javax.help.JHelp"); //NOI18N
1399
}
1400                    public String JavaDoc getDescription() {
1401                        return("any javax.help"); //NOI18N
1402
}
1403                });
1404            }
1405            public String JavaDoc getDescription() {
1406                return "containing any javax.help.JHelp component"; //NOI18N
1407
}
1408        });
1409        if(helpWindow != null) {
1410            new WindowOperator(helpWindow).close();
1411        }
1412    }
1413}
1414
Popular Tags