001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package gui.menu;
043:
044: import org.netbeans.performance.test.guitracker.ActionTracker;
045:
046: import org.netbeans.jellytools.Bundle;
047: import org.netbeans.jellytools.ProjectsTabOperator;
048: import org.netbeans.jellytools.nodes.Node;
049:
050: import org.netbeans.jemmy.drivers.MouseDriver;
051: import org.netbeans.jemmy.operators.ComponentOperator;
052: import org.netbeans.jemmy.operators.JMenuItemOperator;
053: import org.netbeans.jemmy.operators.JPopupMenuOperator;
054:
055: import org.netbeans.junit.NbTestSuite;
056:
057: /**
058: * Test of submenu in popup menu on nodes in Projects View.
059: * @author mmirilovic@netbeans.org
060: */
061: public class ProjectsViewSubMenus extends
062: org.netbeans.performance.test.utilities.PerformanceTestCase {
063:
064: private static ProjectsTabOperator projectsTab = null;
065:
066: private String testedSubmenu;
067:
068: protected static Node dataObjectNode;
069:
070: private static final int repeat_original = Integer.getInteger(
071: "org.netbeans.performance.repeat", 1).intValue(); // initialize original value
072:
073: private JMenuItemOperator mio;
074: private MouseDriver mdriver;
075:
076: /** Creates a new instance of ProjectsViewPopupMenu */
077: public ProjectsViewSubMenus(String testName) {
078: super (testName);
079: expectedTime = 250;
080: WAIT_AFTER_OPEN = 1000;
081: track_mouse_event = ActionTracker.TRACK_MOUSE_MOVED;
082: }
083:
084: /** Creates a new instance of ProjectsViewPopupMenu */
085: public ProjectsViewSubMenus(String testName,
086: String performanceDataName) {
087: super (testName, performanceDataName);
088: expectedTime = 250;
089: WAIT_AFTER_OPEN = 1000;
090: track_mouse_event = ActionTracker.TRACK_MOUSE_MOVED;
091: }
092:
093: public static NbTestSuite suite() {
094: NbTestSuite suite = new NbTestSuite();
095: suite.addTest(new ProjectsViewSubMenus(
096: "testProjectNodeCVSsubmenu",
097: "CVS Submenu over projects node in Projects View"));
098: suite.addTest(new ProjectsViewSubMenus(
099: "testProjectNodeNewSubmenu",
100: "New Submenu over projects node in Projects View"));
101: return suite;
102: }
103:
104: public void testProjectNodeCVSsubmenu() {
105: testedSubmenu = Bundle
106: .getStringTrimmed(
107: "org.netbeans.modules.versioning.system.cvss.ui.actions.Bundle",
108: "CTL_MenuItem_CVSCommands_Label"); //CVS
109: testNode(getProjectNode("PerformanceTestData"));
110: }
111:
112: public void testProjectNodeNewSubmenu() {
113: testedSubmenu = Bundle.getStringTrimmed(
114: "org.openide.actions.Bundle", "NewFromTemplate"); //New
115: testNode(getProjectNode("PerformanceTestData"));
116: }
117:
118: public void testNode(Node node) {
119: dataObjectNode = node;
120: doMeasurement();
121: }
122:
123: private Node getProjectNode(String projectName) {
124: if (projectsTab == null)
125: projectsTab = new ProjectsTabOperator();
126:
127: return projectsTab.getProjectRootNode(projectName);
128: }
129:
130: public void prepare() {
131: JPopupMenuOperator popupMenu = dataObjectNode.callPopup();
132: mio = new JMenuItemOperator(popupMenu, testedSubmenu);
133: assertNotNull("Can not find " + testedSubmenu
134: + " menu item in pop up menu over ["
135: + dataObjectNode.getPath() + "]", mio);
136:
137: mdriver = org.netbeans.jemmy.drivers.DriverManager
138: .getMouseDriver(mio);
139: }
140:
141: public ComponentOperator open() {
142: mdriver.moveMouse(mio, mio.getCenterXForClick(), mio
143: .getCenterYForClick());
144: // mio.pushKey(java.awt.event.KeyEvent.VK_RIGHT);
145: return mio;
146: }
147:
148: public void close() {
149: testedComponentOperator
150: .pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
151: testedComponentOperator
152: .pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
153: }
154:
155: public void setUp() {
156: super .setUp();
157: repeat = 1; // only first use is interesting
158: }
159:
160: public void tearDown() {
161: super .tearDown();
162: repeat = repeat_original; // initialize original value
163: }
164:
165: /** Test could be executed internaly in IDE without XTest
166: * @param args arguments from command line
167: */
168: public static void main(String[] args) {
169: junit.textui.TestRunner.run(new ProjectsViewSubMenus(
170: "testProjectNodeNewSubmenu"));
171: }
172:
173: }
|