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.action;
043:
044: import gui.Projects;
045: import org.netbeans.jellytools.EditorOperator;
046: import org.netbeans.jellytools.EditorWindowOperator;
047: import org.netbeans.jellytools.ProjectsTabOperator;
048: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
049: import org.netbeans.jellytools.actions.OpenAction;
050: import org.netbeans.jellytools.nodes.Node;
051: import org.netbeans.jemmy.operators.ComponentOperator;
052: import org.netbeans.jemmy.operators.JPopupMenuOperator;
053: import org.netbeans.junit.NbTestSuite;
054:
055: /**
056: *
057: * @author mkhramov@netbeans.org
058: */
059:
060: public class EditorMenuPopup extends
061: org.netbeans.performance.test.utilities.PerformanceTestCase {
062:
063: protected Node fileToBeOpened;
064: protected String testProject;
065: protected String docName;
066: protected String pathName;
067: protected static ProjectsTabOperator projectsTab = null;
068: private EditorOperator editorOperator;
069:
070: private JPopupMenuOperator pom;
071:
072: private int XPopup;
073: private int YPopup;
074:
075: public EditorMenuPopup(String testName) {
076: super (testName);
077:
078: expectedTime = UI_RESPONSE;
079: WAIT_AFTER_PREPARE = 1000;
080:
081: }
082:
083: public EditorMenuPopup(String testName, String performanceDataName) {
084: super (testName, performanceDataName);
085: expectedTime = UI_RESPONSE;
086: WAIT_AFTER_PREPARE = 1000;
087: }
088:
089: protected Node getProjectNode(String projectName) {
090: if (projectsTab == null)
091: projectsTab = new ProjectsTabOperator();
092:
093: return projectsTab.getProjectRootNode(projectName);
094: }
095:
096: @Override
097: public void initialize() {
098: super .initialize();
099: log("::initialize");
100: String path = pathName + docName;
101: fileToBeOpened = new Node(getProjectNode(testProject), path);
102: }
103:
104: @Override
105: public void prepare() {
106: log("::prepare");
107: new OpenAction().performAPI(fileToBeOpened);
108: editorOperator = EditorWindowOperator.getEditor(docName);
109: }
110:
111: @Override
112: public ComponentOperator open() {
113: log("::open");
114: editorOperator.clickForPopup();
115: pom = new JPopupMenuOperator();
116:
117: return null;
118: }
119:
120: @Override
121: public void close() {
122: log("::close");
123: editorOperator.pushKey(java.awt.event.KeyEvent.VK_ESCAPE);
124: new CloseAllDocumentsAction().performAPI(); //avoid issue 68671 - editors are not closed after closing project by ProjectSupport
125: }
126:
127: @Override
128: public void shutdown() {
129: log("::shutdown");
130: }
131:
132: public void test_RB_EditorPopup() {
133: testProject = Projects.RUBY_PROJECT;
134: pathName = "Source Files" + "|";
135: docName = "ruby20kb.rb";
136: doMeasurement();
137: }
138:
139: public void test_RHTML_EditorPopup() {
140: testProject = Projects.RAILS_PROJECT;
141: pathName = "Views" + "|";
142: docName = "rhtml20kb.rhtml";
143: doMeasurement();
144: }
145:
146: public void test_JS_EditorPopup() {
147: testProject = Projects.SCRIPTING_PROJECT;
148: pathName = "Web Pages" + "|";
149: docName = "javascript20kb.js";
150: doMeasurement();
151: }
152:
153: public void test_JSON_EditorPopup() {
154: testProject = Projects.SCRIPTING_PROJECT;
155: pathName = "Web Pages" + "|";
156: docName = "json20kb.json";
157: doMeasurement();
158: }
159:
160: public void test_CSS_EditorPopup() {
161: testProject = Projects.SCRIPTING_PROJECT;
162: pathName = "Web Pages" + "|";
163: docName = "css20kb.css";
164: doMeasurement();
165: }
166:
167: public void test_YML_EditorPopup() {
168: testProject = Projects.RAILS_PROJECT;
169: pathName = "Configuration" + "|";
170: docName = "yaml20kb.yml";
171: doMeasurement();
172: }
173:
174: public void test_BAT_EditorPopup() {
175: testProject = Projects.SCRIPTING_PROJECT;
176: pathName = "Web Pages" + "|";
177: docName = "bat20kb.bat";
178: doMeasurement();
179: }
180:
181: public void test_DIFF_EditorPopup() {
182: testProject = Projects.SCRIPTING_PROJECT;
183: pathName = "Web Pages" + "|";
184: docName = "diff20kb.diff";
185: doMeasurement();
186: }
187:
188: public void test_MANIFEST_EditorPopup() {
189: testProject = Projects.SCRIPTING_PROJECT;
190: pathName = "Web Pages" + "|";
191: docName = "manifest20kb.mf";
192: doMeasurement();
193: }
194:
195: public void test_SH_EditorPopup() {
196: testProject = Projects.SCRIPTING_PROJECT;
197: pathName = "Web Pages" + "|";
198: docName = "sh20kb.sh";
199: doMeasurement();
200: }
201:
202: public static NbTestSuite suite() {
203: NbTestSuite suite = new NbTestSuite();
204:
205: return suite;
206: }
207:
208: /** Test could be executed internaly in IDE without XTest
209: * @param args arguments from command line
210: */
211: public static void main(String[] args) {
212: junit.textui.TestRunner.run(suite());
213: }
214:
215: }
|