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.OpenAction;
049: import org.netbeans.jellytools.actions.SaveAction;
050: import org.netbeans.jellytools.nodes.Node;
051: import org.netbeans.jemmy.operators.ComponentOperator;
052:
053: /**
054: *
055: * @author mkhramov@netbeans.org
056: */
057: public class SaveModifiedScriptingFiles extends
058: org.netbeans.performance.test.utilities.PerformanceTestCase {
059:
060: /** Editor with opened file */
061: public static EditorOperator editorOperator;
062:
063: protected Node fileToBeOpened;
064: protected String testProject;
065: protected String docName;
066: protected String pathName;
067: protected static ProjectsTabOperator projectsTab = null;
068:
069: public SaveModifiedScriptingFiles(String testName) {
070: super (testName);
071: expectedTime = WINDOW_OPEN;
072: WAIT_AFTER_PREPARE = 2000;
073: }
074:
075: public SaveModifiedScriptingFiles(String testName,
076: String performanceDataName) {
077: super (testName, performanceDataName);
078: expectedTime = WINDOW_OPEN;
079: WAIT_AFTER_PREPARE = 2000;
080: }
081:
082: public void test_SaveRuby_File() {
083: testProject = Projects.RUBY_PROJECT;
084: pathName = "Source Files" + "|";
085: docName = "ruby20kb.rb";
086: doMeasurement();
087: }
088:
089: public void test_SaveRHTML_File() {
090: testProject = Projects.RAILS_PROJECT;
091: pathName = "Views" + "|";
092: docName = "rhtml20kb.rhtml";
093: doMeasurement();
094: }
095:
096: public void test_SaveJS_File() {
097: testProject = Projects.SCRIPTING_PROJECT;
098: pathName = "web" + "|";
099: docName = "javascript20kb.js";
100: doMeasurement();
101: }
102:
103: public void test_SaveJSON_File() {
104: testProject = Projects.SCRIPTING_PROJECT;
105: pathName = "web" + "|";
106: docName = "json20kb.json";
107: doMeasurement();
108: }
109:
110: public void test_SaveCSS_File() {
111: testProject = Projects.SCRIPTING_PROJECT;
112: pathName = "web" + "|";
113: docName = "css20kb.css";
114: doMeasurement();
115: }
116:
117: public void test_SaveYML_File() {
118: testProject = Projects.RAILS_PROJECT;
119: pathName = "Configuration" + "|";
120: docName = "yaml20kb.yml";
121: doMeasurement();
122: }
123:
124: public void test_SaveBAT_File() {
125: testProject = Projects.SCRIPTING_PROJECT;
126: pathName = "web" + "|";
127: docName = "bat20kb.bat";
128: doMeasurement();
129: }
130:
131: public void test_SaveDIFF_File() {
132: testProject = Projects.SCRIPTING_PROJECT;
133: pathName = "web" + "|";
134: docName = "diff20kb.diff";
135: doMeasurement();
136: }
137:
138: public void test_SaveMANIFEST_File() {
139: testProject = Projects.SCRIPTING_PROJECT;
140: pathName = "web" + "|";
141: docName = "manifest20kb.mf";
142: doMeasurement();
143: }
144:
145: public void test_SaveSH_File() {
146: testProject = Projects.SCRIPTING_PROJECT;
147: pathName = "web" + "|";
148: docName = "sh20kb.sh";
149: doMeasurement();
150: }
151:
152: @Override
153: public void initialize() {
154: EditorOperator.closeDiscardAll();
155: String path = pathName + docName;
156: fileToBeOpened = new Node(getProjectNode(testProject), path);
157: new OpenAction().performAPI(fileToBeOpened);
158: editorOperator = EditorWindowOperator.getEditor(docName);
159: }
160:
161: protected Node getProjectNode(String projectName) {
162: if (projectsTab == null)
163: projectsTab = new ProjectsTabOperator();
164: return projectsTab.getProjectRootNode(projectName);
165: }
166:
167: @Override
168: public void prepare() {
169: editorOperator.setCaretPosition(1, 3);
170: editorOperator.txtEditorPane().typeText("XXX");
171: editorOperator.pushKey(java.awt.event.KeyEvent.VK_BACK_SPACE);
172: editorOperator.pushKey(java.awt.event.KeyEvent.VK_BACK_SPACE);
173: editorOperator.pushKey(java.awt.event.KeyEvent.VK_BACK_SPACE);
174:
175: }
176:
177: @Override
178: public ComponentOperator open() {
179: new SaveAction().performShortcut(editorOperator);
180: editorOperator.waitModified(false);
181: return null;
182: }
183:
184: @Override
185: public void shutdown() {
186: EditorOperator.closeDiscardAll();
187: }
188:
189: }
|