ide.kit/test/qa-functional/src/org/netbeans/test/ide/IDEValidation.java
author Alexander Kouznetsov <mrkam@netbeans.org>
Wed Jul 02 20:20:34 2008 +0400 (30 hours ago)
changeset 87504 133e90708757
parent 87295e91b8435cbd4
permissions -rw-r--r--
Fix for testBlacklistedClassesHandler testcase
        1 /*
        2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
        3  *
        4  * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
        5  *
        6  * The contents of this file are subject to the terms of either the GNU
        7  * General Public License Version 2 only ("GPL") or the Common
        8  * Development and Distribution License("CDDL") (collectively, the
        9  * "License"). You may not use this file except in compliance with the
       10  * License. You can obtain a copy of the License at
       11  * http://www.netbeans.org/cddl-gplv2.html
       12  * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
       13  * specific language governing permissions and limitations under the
       14  * License.  When distributing the software, include this License Header
       15  * Notice in each file and include the License file at
       16  * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
       17  * particular file as subject to the "Classpath" exception as provided
       18  * by Sun in the GPL Version 2 section of the License file that
       19  * accompanied this code. If applicable, add the following below the
       20  * License Header, with the fields enclosed by brackets [] replaced by
       21  * your own identifying information:
       22  * "Portions Copyrighted [year] [name of copyright owner]"
       23  *
       24  * Contributor(s):
       25  *
       26  * The Original Software is NetBeans. The Initial Developer of the Original
       27  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
       28  * Microsystems, Inc. All Rights Reserved.
       29  *
       30  * If you wish your version of this file to be governed by only the CDDL
       31  * or only the GPL Version 2, indicate your decision by adding
       32  * "[Contributor] elects to include this software in this distribution
       33  * under the [CDDL or GPL Version 2] license." If you do not indicate a
       34  * single choice of license, a recipient has the option to distribute
       35  * your version of this file under either the CDDL, the GPL Version 2 or
       36  * to extend the choice of license to its licensees as provided above.
       37  * However, if you add GPL Version 2 code and therefore, elected the GPL
       38  * Version 2 license, then the option applies only if the new code is
       39  * made subject to such option by the copyright holder.
       40  */
       41 
       42 package org.netbeans.test.ide;
       43 
       44 import java.awt.Component;
       45 import java.awt.Toolkit;
       46 import java.awt.Window;
       47 import java.awt.datatransfer.DataFlavor;
       48 import java.awt.datatransfer.UnsupportedFlavorException;
       49 import java.awt.event.KeyEvent;
       50 import java.io.File;
       51 import java.io.IOException;
       52 import javax.swing.JTextField;
       53 import javax.swing.KeyStroke;
       54 import javax.swing.UIManager;
       55 import org.netbeans.jellytools.Bundle;
       56 import org.netbeans.jellytools.EditorOperator;
       57 import org.netbeans.jellytools.FavoritesOperator;
       58 import org.netbeans.jellytools.FilesTabOperator;
       59 import org.netbeans.jellytools.HelpOperator;
       60 import org.netbeans.jellytools.JellyTestCase;
       61 import org.netbeans.jellytools.MainWindowOperator;
       62 import org.netbeans.jellytools.NbDialogOperator;
       63 import org.netbeans.jellytools.NewFileNameLocationStepOperator;
       64 import org.netbeans.jellytools.NewFileWizardOperator;
       65 import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
       66 import org.netbeans.jellytools.NewProjectWizardOperator;
       67 import org.netbeans.jellytools.OptionsOperator;
       68 import org.netbeans.jellytools.OutputOperator;
       69 import org.netbeans.jellytools.OutputTabOperator;
       70 import org.netbeans.jellytools.PluginsOperator;
       71 import org.netbeans.jellytools.ProjectsTabOperator;
       72 import org.netbeans.jellytools.RuntimeTabOperator;
       73 import org.netbeans.jellytools.TopComponentOperator;
       74 import org.netbeans.jellytools.actions.Action;
       75 import org.netbeans.jellytools.actions.ActionNoBlock;
       76 import org.netbeans.jellytools.actions.AttachWindowAction;
       77 import org.netbeans.jellytools.actions.CompileAction;
       78 import org.netbeans.jellytools.actions.CopyAction;
       79 import org.netbeans.jellytools.actions.CutAction;
       80 import org.netbeans.jellytools.actions.DeleteAction;
       81 import org.netbeans.jellytools.actions.NewFileAction;
       82 import org.netbeans.jellytools.actions.PasteAction;
       83 import org.netbeans.jellytools.actions.ViewAction;
       84 import org.netbeans.jellytools.modules.debugger.actions.ContinueAction;
       85 import org.netbeans.jellytools.modules.debugger.actions.DebugAction;
       86 import org.netbeans.jellytools.modules.debugger.actions.FinishDebuggerAction;
       87 import org.netbeans.jellytools.modules.debugger.actions.NewBreakpointAction;
       88 import org.netbeans.jellytools.modules.debugger.actions.ToggleBreakpointAction;
       89 import org.netbeans.jellytools.nodes.JavaNode;
       90 import org.netbeans.jellytools.nodes.Node;
       91 import org.netbeans.jellytools.nodes.SourcePackagesNode;
       92 import org.netbeans.jellytools.properties.Property;
       93 import org.netbeans.jellytools.properties.PropertySheetOperator;
       94 
       95 import org.netbeans.jemmy.ComponentChooser;
       96 import org.netbeans.jemmy.EventTool;
       97 import org.netbeans.jemmy.JemmyException;
       98 import org.netbeans.jemmy.JemmyProperties;
       99 import org.netbeans.jemmy.QueueTool;
      100 import org.netbeans.jemmy.TestOut;
      101 import org.netbeans.jemmy.TimeoutExpiredException;
      102 import org.netbeans.jemmy.Waitable;
      103 import org.netbeans.jemmy.Waiter;
      104 import org.netbeans.jemmy.operators.JButtonOperator;
      105 import org.netbeans.jemmy.operators.JDialogOperator;
      106 import org.netbeans.jemmy.operators.JLabelOperator;
      107 import org.netbeans.jemmy.operators.JRadioButtonOperator;
      108 import org.netbeans.jemmy.operators.JTextFieldOperator;
      109 import org.netbeans.jemmy.operators.JTreeOperator;
      110 import org.netbeans.jemmy.operators.Operator;
      111 import org.netbeans.jemmy.operators.WindowOperator;
      112 import org.netbeans.jemmy.util.PNGEncoder;
      113 
      114 import org.netbeans.junit.NbTestSuite;
      115 import org.openide.windows.Mode;
      116 import org.openide.windows.TopComponent;
      117 import org.openide.windows.WindowManager;
      118 
      119 
      120 /**
      121  * Overall validation suite for IDE.
      122  *
      123  * @author Jiri.Skrivanek@sun.com
      124  */
      125 public class IDEValidation extends JellyTestCase {
      126     
      127     /** Need to be defined because of JUnit */
      128     public IDEValidation(String name) {
      129         super(name);
      130     }
      131 
      132     public static NbTestSuite suite() {
      133         NbTestSuite suite = new NbTestSuite();
      134         suite.addTest(new IDEValidation("testInitGCProjects"));
      135         suite.addTest(new IDEValidation("testMainMenu"));
      136         suite.addTest(new IDEValidation("testHelp"));
      137         suite.addTest(new IDEValidation("testOptions"));
      138         suite.addTest(new IDEValidation("testOptionsClassicView"));
      139         suite.addTest(new IDEValidation("testNewProject"));
      140         // sample project must exist before testShortcuts
      141         suite.addTest(new IDEValidation("testShortcuts"));
      142         suite.addTest(new IDEValidation("testNewFile"));
      143         suite.addTest(new IDEValidation("testCVSLite"));
      144         suite.addTest(new IDEValidation("testProjectsView"));
      145         suite.addTest(new IDEValidation("testFilesView"));
      146         suite.addTest(new IDEValidation("testEditor"));
      147         suite.addTest(new IDEValidation("testBuildAndRun"));
      148         suite.addTest(new IDEValidation("testDebugging"));
      149         suite.addTest(new IDEValidation("testJUnit"));
      150         suite.addTest(new IDEValidation("testXML"));
      151         suite.addTest(new IDEValidation("testDb"));
      152         suite.addTest(new IDEValidation("testWindowSystem"));
      153         suite.addTest(new IDEValidation("testPlugins"));
      154         return suite;
      155     }
      156     
      157     /** Setup called before every test case. */
      158     @Override
      159     public void setUp() {
      160         System.out.println("########  "+getName()+"  #######");
      161         // Close help window if any - it should not stay open between test cases.
      162         // Otherwise it can break next tests.
      163         closeHelpWindow();
      164     }
      165     
      166     /** Tear down called after every test case. */
      167     @Override
      168     public void tearDown() {
      169     }
      170     
      171     // name of sample project
      172     private static final String SAMPLE_PROJECT_NAME = "SampleProject"; // NOI18N
      173     // name of first sample package
      174     private static final String SAMPLE1_PACKAGE_NAME = "sample1"; //NOI18N
      175     // name of sample class
      176     private static final String SAMPLE1_CLASS_NAME = "SampleClass1"; // NOI18N
      177     // name of sample file
      178     private static final String SAMPLE1_FILE_NAME = SAMPLE1_CLASS_NAME+".java"; // NOI18N
      179     // name of sample class 2
      180     private static final String SAMPLE2_CLASS_NAME = "SampleClass2"; // NOI18N
      181     // name of sample file 2
      182     private static final String SAMPLE2_FILE_NAME = SAMPLE2_CLASS_NAME+".java"; // NOI18N
      183 
      184     /** Test creation of java project. 
      185      * - open New Project wizard from main menu (File|New Project)
      186      * - select Java Application project from Standard category
      187      * - in the next panel type project name and project location in
      188      * - finish the wizard
      189      * - wait until project appears in projects view
      190      * - wait classpath scanning finished
      191      */
      192     public void testNewProject() {
      193         NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
      194         // "Standard"
      195         String standardLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard");
      196         npwo.selectCategory(standardLabel);
      197         // "Java Application"
      198         String javaApplicationLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard/emptyJ2SE.xml");
      199         npwo.selectProject(javaApplicationLabel);
      200         npwo.next();
      201         NewProjectNameLocationStepOperator npnlso = new NewProjectNameLocationStepOperator();
      202         npnlso.txtProjectName().setText(SAMPLE_PROJECT_NAME);
      203         npnlso.txtProjectLocation().setText(System.getProperty("netbeans.user")); // NOI18N
      204         npnlso.btFinish().pushNoBlock();
      205         npnlso.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 120000);
      206         npnlso.waitClosed();
      207         // Opening Projects
      208         String openingProjectsTitle = Bundle.getString("org.netbeans.modules.project.ui.Bundle", "LBL_Opening_Projects_Progress");
      209         try {
      210             // wait at most 120 second until progress dialog dismiss
      211             NbDialogOperator openingOper = new NbDialogOperator(openingProjectsTitle);
      212             openingOper.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 120000);
      213             openingOper.waitClosed();
      214         } catch (TimeoutExpiredException e) {
      215             // ignore when progress dialog was closed before we started to wait for it
      216         }
      217         // wait project appear in projects view
      218         new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME);
      219         // wait classpath scanning finished
      220         WatchProjects.waitScanFinished();
      221     }
      222     
      223     /** Test new file wizard. 
      224      * - open New File wizard from main menu (File|New File)
      225      * - select sample project as target
      226      * - select Java Classes|Java Package file type
      227      * - in the next panel type package name in
      228      * - finish the wizard
      229      * - open New File wizard from context menu on created package node (New|File)
      230      * - select Java Classes|Java Main Class file type
      231      * - in the next panel type class name in
      232      * - finish the wizard
      233      * - check class is open in editor and close all opened documents
      234      */
      235     public void testNewFile() {
      236         // create a new package
      237         // "Java Classes"
      238         String javaClassesLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes");
      239         // "Java Package"
      240         String packageLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes/Package");
      241         NewFileWizardOperator.create(SAMPLE_PROJECT_NAME, javaClassesLabel, packageLabel, null, SAMPLE1_PACKAGE_NAME);
      242         // wait package node is created
      243         Node sample1Node = new Node(new SourcePackagesNode(SAMPLE_PROJECT_NAME), SAMPLE1_PACKAGE_NAME);
      244         
      245         // create a new classes
      246         
      247         // "Java Main Class"
      248         String mainClassLabel = Bundle.getString("org.netbeans.modules.java.project.Bundle", "Templates/Classes/Main.java"); // NOI18N
      249         NewFileWizardOperator.invoke(sample1Node, javaClassesLabel, mainClassLabel);
      250         NewFileNameLocationStepOperator nameStepOper = new NewFileNameLocationStepOperator();
      251         nameStepOper.setObjectName(SAMPLE1_CLASS_NAME);
      252         nameStepOper.finish();
      253         // check class is opened in Editor
      254         new EditorOperator(SAMPLE1_FILE_NAME);
      255         NewFileWizardOperator.invoke(sample1Node, javaClassesLabel, mainClassLabel);
      256         nameStepOper = new NewFileNameLocationStepOperator();
      257         nameStepOper.setObjectName(SAMPLE2_CLASS_NAME);
      258         nameStepOper.finish();
      259         // check class is opened in Editor and then close all documents
      260         new EditorOperator(SAMPLE2_FILE_NAME).closeAllDocuments();
      261     }
      262     
      263     /** Test Projects view 
      264      * - expand source hierarchy and find sample class (SampleClass1.java)
      265      * - copy sample class and paste it to the same package
      266      * - confirm refactoring dialog
      267      * - verify creation of NewClass.java node
      268      * - cut NewClass.java
      269      * - paste it to another package
      270      * - confirm refactoring dialog
      271      * - delete NewClass.java node
      272      */
      273     public void testProjectsView() {
      274         ProjectsTabOperator.invoke();
      275         // needed for slower machines
      276         JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
      277         SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
      278         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
      279         Node sampleClass1Node = new Node(sample1Node, SAMPLE1_FILE_NAME);
      280         // test pop-up menu actions
      281         // "Copy"
      282         CopyAction copyAction = new CopyAction();
      283         copyAction.perform(sampleClass1Node);
      284         // "Paste"
      285         PasteAction pasteAction = new PasteAction();
      286         // "Refactor"
      287         String refactorItem = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "LBL_Action");
      288         // "Copy..."
      289         String copyItem = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "LBL_CopyAction");
      290         new ActionNoBlock(null, pasteAction.getPopupPath()+"|"+refactorItem+" "+copyItem).perform(sample1Node);
      291         
      292         String copyClassTitle = Bundle.getString("org.netbeans.modules.refactoring.java.ui.Bundle", "LBL_CopyClass");
      293         NbDialogOperator copyClassDialog = new NbDialogOperator(copyClassTitle);
      294         // "Refactor"
      295         String refactorLabel = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "CTL_Finish");
      296         new JButtonOperator(copyClassDialog, refactorLabel).push();
      297         // refactoring is done asynchronously => need to wait until dialog dismisses
      298         copyClassDialog.waitClosed();
      299         
      300         Node newClassNode = new Node(sample1Node, "SampleClass11"); // NOI18N
      301         newClassNode.select();
      302         // "Cut"
      303         CutAction cutAction = new CutAction();
      304         cutAction.perform(newClassNode);
      305         // package created by default when the sample project was created
      306         Node sampleProjectPackage = new Node(sourcePackagesNode, SAMPLE_PROJECT_NAME.toLowerCase());
      307         // "Move..."
      308         String moveItem = Bundle.getStringTrimmed("org.netbeans.modules.refactoring.spi.impl.Bundle", "LBL_MoveAction");
      309         new ActionNoBlock(null, pasteAction.getPopupPath()+"|"+refactorItem+" "+moveItem).perform(sampleProjectPackage);
      310         // confirm refactoring
      311         // "Move Class"
      312         String moveClassTitle = Bundle.getString("org.netbeans.modules.refactoring.java.ui.Bundle", "LBL_MoveClass");
      313         NbDialogOperator moveClassDialog = new NbDialogOperator(moveClassTitle);
      314         new JButtonOperator(moveClassDialog, refactorLabel).push();
      315         // refactoring is done asynchronously => need to wait until dialog dismisses
      316         moveClassDialog.waitClosed();
      317         // "Delete"
      318         newClassNode = new Node(sampleProjectPackage, "SampleClass11"); // NOI18N
      319         new DeleteAction().perform(newClassNode);
      320         // "Safe Delete"
      321         String safeDeleteTitle = Bundle.getString("org.netbeans.modules.refactoring.spi.impl.Bundle", "LBL_SafeDel"); // NOI18N
      322         NbDialogOperator safeDeleteOper = new NbDialogOperator(safeDeleteTitle);
      323         try {
      324             safeDeleteOper.ok();
      325         } catch (TimeoutExpiredException e) {
      326             // It is "classpath scanning in progress" dialog, wait until it dismiss,
      327             // and then wait for regular Safe Delete dialog
      328             safeDeleteOper.waitClosed();
      329             safeDeleteOper = new NbDialogOperator(safeDeleteTitle);
      330             safeDeleteOper.ok();
      331         }
      332         safeDeleteOper.waitClosed();
      333     }
      334 
      335     /** Test Files view 
      336      * - expand files hierarchy and find sample class (SampleClass1.java) 
      337      * and select main method node.
      338      */
      339     public void testFilesView() {
      340         FilesTabOperator filesTabOper = FilesTabOperator.invoke();
      341         // needed for slower machines
      342         JemmyProperties.setCurrentTimeout("JTreeOperator.WaitNextNodeTimeout", 30000); // NOI18N
      343         Node sourcePackagesNode = new Node(filesTabOper.getProjectNode(SAMPLE_PROJECT_NAME), "src"); // NOI18N
      344         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME); // NOI18N
      345         Node sampleClass1Node = new Node(sample1Node, SAMPLE1_FILE_NAME);
      346         // It is possible to test also pop-up menu actions as in testProjectsView, but
      347         // it is redundant IMO
      348     }
      349 
      350     
      351     /** Test of DB module.
      352      * It only tests whether the Databases node is present in Runtime view, 
      353      * Add Driver action is enabled on Drivers node and Connect action is available
      354      * on default JDBC-ODBC Bridge node.
      355      * - find Databases|Drivers node in Runtime tab
      356      * - open and close Add Driver dialog from context menu on Drivers node
      357      * - open and close Connect Using dialog on JDBC-ODBC Bridge node
      358      */
      359     public void testDb() {
      360         // "Databases"
      361         String databasesLabel = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NDN_Databases");
      362         Node databasesNode = new Node(RuntimeTabOperator.invoke().getRootNode(), databasesLabel);
      363         // "Please wait..."
      364         String waitNodeLabel = Bundle.getString("org.openide.nodes.Bundle", "LBL_WAIT");
      365         // wait until the wait node dismiss and after that start waiting for Drivers node
      366         // (see issue http://www.netbeans.org/issues/show_bug.cgi?id=43910 - Creation of 
      367         // children under Databases node is not properly synchronized)
      368         try {
      369             databasesNode.waitChildNotPresent(waitNodeLabel);
      370         } catch (JemmyException e) {
      371             // Ignore and try to continue. Sometimes it happens "Please, wait" node
      372             // is still available (maybe some threading issue).
      373             log("Timeout expired: "+e.getMessage());
      374         }
      375         // "Drivers"
      376         String driversLabel = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NDN_Drivers");
      377         Node driversNode = new Node(RuntimeTabOperator.invoke().getRootNode(), databasesLabel+"|"+driversLabel);
      378         // "Add Driver ..."
      379         String addDriverItem = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "AddNewDriver");
      380         // open a dialog to add a new JDBC driver
      381         new ActionNoBlock(null, addDriverItem).perform(driversNode);
      382         String addDriverTitle = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "AddDriverDialogTitle");
      383         new NbDialogOperator(addDriverTitle).cancel();
      384         
      385         // wait until the wait node dismiss and after that start waiting for JDBC_ODBC Bridge node
      386         // (see issue http://www.netbeans.org/issues/show_bug.cgi?id=43910 - Creation of 
      387         // children under Databases node is not properly synchronized)
      388         try {
      389             driversNode.waitChildNotPresent(waitNodeLabel);
      390         } catch (JemmyException e) {
      391             // Ignore and try to continue. Sometimes it happens "Please, wait" node
      392             // is still available (maybe some threading issue).
      393             log("Timeout expired: "+e.getMessage());
      394         }
      395         if(System.getProperty("os.name").toLowerCase().indexOf("mac") == -1) { // NOI18N
      396             // node JDBC-ODBC Bridge should be present always but not on mac
      397             Node jdbcOdbcNode = new Node(driversNode, "JDBC-ODBC Bridge"); // NOI18N
      398             // "Connect Using ..."
      399             String connectUsingItem = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "ConnectUsing");
      400             // open a dialog to create a new connection
      401             new ActionNoBlock(null, connectUsingItem).perform(jdbcOdbcNode);
      402             String newDatabaseConnectionTitle = Bundle.getString("org.netbeans.modules.db.resources.Bundle", "NewConnectionDialogTitle");
      403             new NbDialogOperator(newDatabaseConnectionTitle).cancel();
      404         }
      405     }
      406     
      407     /** Test Help 
      408      * - open Help window from main menu (Help|Help Contents)
      409      */
      410     public void testHelp() {
      411         // increasing time because opening of help window can last longer on slower machines
      412         JemmyProperties.setCurrentTimeout("JMenuOperator.PushMenuTimeout", 60000);
      413         // open "Help|Contents"
      414         HelpOperator helpOper = HelpOperator.invoke();
      415         // check help window opened
      416         // title is "Help - All"
      417         helpOper.close();
      418     }
      419     
      420    /** Test Main Menu 
      421      * - close Welcome screen to not harm menu actions
      422      * - open and close New Project wizard (main menu item File|New Project...)
      423      * - open and close Javadoc Index Search top component (main menu item Tools|Javadoc Index Search)
      424      */
      425     public void testMainMenu() {
      426         // close Welcome screen to not harm menu actions
      427         // "Welcome
      428         String welcomeTitle = Bundle.getString("org.netbeans.modules.welcome.Bundle", "LBL_Tab_Title");
      429         new TopComponentOperator(welcomeTitle).close();
      430         // open and close New Project wizard
      431         int oldDispatchingModel = JemmyProperties.getCurrentDispatchingModel();
      432         try {
      433             NewProjectWizardOperator.invoke().close();
      434         } catch (TimeoutExpiredException e) {
      435             // if not succed try it second time in Robot mode
      436             // push Escape key to ensure there is no open menu
      437             MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
      438             JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
      439             NewProjectWizardOperator.invoke().close();
      440         } finally {
      441             // set previous dispatching model
      442             JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
      443         }
      444         /*
      445         // open Tools|Javadoc Index Search
      446         String toolsItem = Bundle.getStringTrimmed("org.netbeans.core.ui.resources.Bundle", "Menu/Tools"); // NOI18N
      447         String javadocItem = Bundle.getStringTrimmed("org.netbeans.modules.javadoc.search.Bundle", "CTL_SEARCH_MenuItem");
      448         new Action(toolsItem+"|"+javadocItem, null).perform();
      449         // "Javadoc Index Search"
      450         String javadocTitle = Bundle.getString("org.netbeans.modules.javadoc.search.Bundle", "CTL_SEARCH_WindowTitle");
      451         new TopComponentOperator(javadocTitle).close();
      452          */
      453     }
      454     
      455     /** Test global shortcuts. 
      456      * - open and close new file wizard (CTRL+N)
      457      * - open and close Javadoc Index Search top component (Shift+F1)
      458      * - open and close new breakpoint dialog (Ctrl+Shift+F8)
      459      */
      460     public void testShortcuts() {
      461         // test global shortcuts
      462         // open new wizard (Ctrl+N)
      463         Node node = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
      464         // push Escape key to ensure there is no thing blocking shortcut execution
      465         MainWindowOperator.getDefault().pushKey(KeyEvent.VK_ESCAPE);
      466         NewFileAction newFileAction = new NewFileAction();
      467         try {
      468             newFileAction.performShortcut(node);
      469             new NewFileWizardOperator().close();
      470             // On some linux it may happen autorepeat is activated and it 
      471             // opens dialog multiple times. So, we need to close all modal dialogs.
      472             // See issue http://www.netbeans.org/issues/show_bug.cgi?id=56672.
      473             closeAllModal();
      474         } catch (TimeoutExpiredException e) {
      475             // need to be realiable test => repeat action once more to be sure it is problem in IDE
      476             // this time use events instead of Robot
      477             node.select();
      478             MainWindowOperator.getDefault().pushKey(
      479                     newFileAction.getKeyStrokes()[0].getKeyCode(),
      480                     newFileAction.getKeyStrokes()[0].getModifiers());
      481             new NewFileWizardOperator().close();
      482         }
      483         // open Javadoc Index Search (Shift+F1)
      484         // "Javadoc Index Search"
      485         String javadocTitle = Bundle.getString("org.netbeans.modules.javadoc.search.Bundle", 
      486                                                "CTL_SEARCH_WindowTitle");
      487         Action searchAction = new Action(null, null, KeyStroke.getKeyStroke(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK));
      488         try {
      489             searchAction.perform(MainWindowOperator.getDefault());
      490             new TopComponentOperator(javadocTitle).close();
      491         } catch (TimeoutExpiredException e) {
      492             // need to be realiable test => repeat action once more to be sure it is problem in IDE
      493             // this time use events instead of Robot
      494             MainWindowOperator.getDefault().pushKey(KeyEvent.VK_F1, KeyEvent.SHIFT_MASK);
      495             new TopComponentOperator(javadocTitle).close();
      496         }
      497         // open new breakpoint dialog (Ctrl+Shift+F8)
      498         String newBreakpointTitle = Bundle.getString("org.netbeans.modules.debugger.ui.actions.Bundle", "CTL_Breakpoint_Title");
      499         NewBreakpointAction newBreakpointAction = new NewBreakpointAction();
      500         try {
      501             newBreakpointAction.performShortcut(MainWindowOperator.getDefault());
      502             new NbDialogOperator(newBreakpointTitle).close();
      503             // On some linux it may happen autorepeat is activated and it 
      504             // opens dialog multiple times. So, we need to close all modal dialogs.
      505             // See issue http://www.netbeans.org/issues/show_bug.cgi?id=56672.
      506             closeAllModal();
      507         } catch (TimeoutExpiredException e) {
      508             // need to be realiable test => repeat action once more to be sure it is problem in IDE
      509             // this time use events instead of Robot
      510             MainWindowOperator.getDefault().pushKey(
      511                     newBreakpointAction.getKeyStrokes()[0].getKeyCode(),
      512                     newBreakpointAction.getKeyStrokes()[0].getModifiers());
      513             new NbDialogOperator(newBreakpointTitle).close();
      514         }
      515     }
      516     
      517     /** Test Source Editor
      518      * - opens sample class in Editor (context menu Open on the node)
      519      * - type abbreviation 'sout' into main method and then 'Hello'
      520      * - verify it is written 'System.out.println("Hello");'
      521      * - select the text and call copy from editor's context menu
      522      * - insert dummy text at next line , select it and paste the text in the clipboard
      523      * - select second 'Hello' and delete it by context menu
      524      * - insert 'Good bye' instead
      525      * - select fourth line, cut it and paste it at line 3
      526      */
      527     public void testEditor() {
      528         // open sample file in Editor
      529         SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
      530         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
      531         JavaNode sampleClass1Node = new JavaNode(sample1Node, SAMPLE1_FILE_NAME);
      532         sampleClass1Node.open();
      533         // find open file in editor
      534         EditorOperator eo = new EditorOperator(SAMPLE1_FILE_NAME);
      535         eo.setCaretPosition("public static void main", true);
      536         int insertLine = eo.getLineNumber()+2;
      537         eo.insert("\n", insertLine, 1); // NOI18N
      538         // Need to disable verification because shortcut "sout" is replaced
      539         // by "System.out.println("");" and "sout" is not found in Editor
      540         eo.setCaretPositionToLine(insertLine);
      541         eo.txtEditorPane().setVerification(false);
      542         eo.txtEditorPane().typeText("sout"); // NOI18N
      543         eo.txtEditorPane().typeKey('\t');
      544         eo.txtEditorPane().setVerification(true);
      545         eo.insert("Hello"); // NOI18N
      546         //eo.insert("System.out.println(\"Hello\");\n", insertLine+1, 1); // NOI18N
      547         final String textToCopy = "System.out.println(\"Hello\");"; // NOI18N
      548         eo.select(textToCopy);
      549         int oldDispatchingModel = JemmyProperties.getCurrentDispatchingModel();
      550         // "Copy"
      551         CopyAction copyAction = new CopyAction();
      552         try {
      553             copyAction.perform(eo);
      554         } catch (TimeoutExpiredException e) {
      555             // if not succed try it second time in Robot mode
      556             JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
      557             copyAction.perform(eo);
      558         } finally {
      559             // set previous dispatching model
      560             JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
      561         }
      562         // wait until clipboard contains text to copy
      563         try {
      564             new Waiter(new Waitable() {
      565                 public Object actionProduced(Object obj) {
      566                     try {
      567                         String text = Toolkit.getDefaultToolkit().getSystemClipboard().
      568                                         getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
      569                         return textToCopy.equals(text) ? Boolean.TRUE:null;
      570                     } catch (UnsupportedFlavorException e) {
      571                         // The following exception can be thrown when clipboard is empty.
      572                         // java.awt.datatransfer.UnsupportedFlavorException: Unicode String
      573                         // at org.openide.util.datatransfer.ExTransferable$Empty.getTransferData(ExTransferable.java:461)
      574                         // Ignore this exception.
      575                         return null;
      576                     } catch (IOException ioe) {
      577                         throw new JemmyException("Failed getting clipboard content.", ioe);
      578                     }
      579                 }
      580                 public String getDescription() {
      581                     return("Clipboard contains "+textToCopy); // NOI18N
      582                 }
      583             }).waitAction(null);
      584         } catch (Exception ie) {
      585             throw new JemmyException("Interrupted.", ie);
      586         }
      587         eo.insert("int xxxx;\n", insertLine+1, 1); // NOI18N
      588         eo.select("int xxxx;"); // NOI18N
      589         PasteAction pasteAction = new PasteAction();
      590         try {
      591             pasteAction.perform(eo);
      592         } catch (TimeoutExpiredException e) {
      593             // if not succed try it second time in Robot mode
      594             JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
      595             pasteAction.perform(eo);
      596         } finally {
      597             // set previous dispatching model
      598             JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
      599         }
      600         eo.select("Hello", 1); // NOI18N
      601         // "Delete"
      602         DeleteAction deleteAction = new DeleteAction();
      603         deleteAction.performMenu(eo);
      604         // wait Hello is deleted
      605         eo.txtEditorPane().waitText("System.out.println(\"\");"); // NOI18N
      606         eo.insert("Good bye"); // NOI18N
      607         // test cut action
      608         eo.select(3);
      609         // "Cut"
      610         CutAction cutAction = new CutAction();
      611         try {
      612             cutAction.perform(eo);
      613         } catch (TimeoutExpiredException e) {
      614             // if not succed try it second time in Robot mode
      615             JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
      616             cutAction.perform(eo);
      617         } finally {
      618             // set previous dispatching model
      619             JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
      620         }
      621         // need to wait a little until editor content is refreshed after cut action
      622         new EventTool().waitNoEvent(500);
      623         // select from column 1 to 2 at line 3 
      624         eo.select(2, 1, 2);
      625         try {
      626             pasteAction.perform(eo);
      627         } catch (TimeoutExpiredException e) {
      628             // if not succed try it second time in Robot mode
      629             JemmyProperties.setCurrentDispatchingModel(JemmyProperties.ROBOT_MODEL_MASK);
      630             pasteAction.perform(eo);
      631         } finally {
      632             // set previous dispatching model
      633             JemmyProperties.setCurrentDispatchingModel(oldDispatchingModel);
      634         }
      635     }
      636     
      637     /** Test build and run.
      638      * - select sample class node and call "Build|Compile "SampleClass1.java"" main menu item
      639      * - wait until compilation finishes (track status bar)
      640      * - select sample class node and call "Run|Run File|Run "SampleClass1.java"" main menu item
      641      * - wait until run finishes
      642      * - from context menu set sample project as main project
      643      * - call "Build|Build Main Project" main menu item
      644      * - wait until build finishes
      645      * - call "Run|Run Main Project" main menu item
      646      * - wait until run finishes
      647      */
      648     public void testBuildAndRun() {
      649         SourcePackagesNode sourcePackagesNode = new SourcePackagesNode(SAMPLE_PROJECT_NAME);
      650         Node sample1Node = new Node(sourcePackagesNode, SAMPLE1_PACKAGE_NAME);
      651         JavaNode sampleClass1Node = new JavaNode(sample1Node, SAMPLE1_FILE_NAME);
      652         // increase timeout to 60 seconds
      653         MainWindowOperator.getDefault().getTimeouts().setTimeout("Waiter.WaitingTime", 60000);
      654         // start to track Main Window status bar
      655         MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
      656         stt.start();
      657         // call Build|Compile main menu item
      658         new CompileAction().perform(sampleClass1Node);
      659         // "SampleProject (compile-single)"
      660         String compileSingleTarget = Bundle.getString(
      661                 "org.apache.tools.ant.module.run.Bundle",
      662                 "TITLE_output_target",
      663                 new Object[] {SAMPLE_PROJECT_NAME, null, "compile-single"});  // NOI18N
      664         // "Finished building SampleProject (compile-single)"
      665         String finishedCompileSingleLabel = Bundle.getString(
      666                 "org.apache.tools.ant.module.run.Bundle",
      667                 "FMT_finished_target_status",
      668                 new String[] {compileSingleTarget});
      669         // wait message "Finished building SampleProject (compile-single)"
      670         stt.waitText(finishedCompileSingleLabel);
      671         
      672         // "Run" 
      673         String runItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject");
      674         // "Run File"
      675         String runOtherItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.Bundle", "Menu/RunProject/RunOther");
      676         // "Run File"
      677         String runFileItem = Bundle.getStringTrimmed("org.netbeans.modules.project.ui.actions.Bundle", 
      678                                                      "LBL_RunSingleAction_Name",
      679                                                      new Object[] {new Integer(1), SAMPLE1_FILE_NAME});
      680         // call "Run|Run File|Run "SampleClass1.java""
      681         new Action(runItem+"|"+runOtherItem+"|"+runFileItem, null).perform(sampleClass1Node);
      682         // "SampleProject (run-single)"
      683         String runSingleTarget = Bundle.getString(
      684