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-2007 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 java.awt.Font;
046: import org.netbeans.jellytools.EditorOperator;
047: import org.netbeans.jellytools.EditorWindowOperator;
048: import org.netbeans.jellytools.ProjectsTabOperator;
049: import org.netbeans.jellytools.actions.OpenAction;
050: import org.netbeans.jellytools.nodes.Node;
051: import org.netbeans.jemmy.operators.ComponentOperator;
052:
053: /**
054: *
055: * @author Administrator
056: */
057: public class TypingInScriptingEditor extends
058: org.netbeans.performance.test.utilities.PerformanceTestCase {
059:
060: protected Node fileToBeOpened;
061: protected String testProject;
062: protected String fileName;
063: protected String nodePath;
064:
065: private EditorOperator editorOperator;
066: protected static ProjectsTabOperator projectsTab = null;
067:
068: private int caretBlinkRate;
069: private Font font;
070:
071: public TypingInScriptingEditor(String testName) {
072: super (testName);
073: expectedTime = UI_RESPONSE;
074: HEURISTIC_FACTOR = -1; // use default WaitAfterOpen for all iterations
075: }
076:
077: public TypingInScriptingEditor(String testName,
078: String performanceDataName) {
079: super (testName, performanceDataName);
080: expectedTime = UI_RESPONSE;
081: HEURISTIC_FACTOR = -1; // use default WaitAfterOpen for all iterations
082: }
083:
084: @Override
085: public void initialize() {
086: log("::initialize");
087: String path = nodePath + "|" + fileName;
088: log("attempting to open: " + path);
089:
090: fileToBeOpened = new Node(getProjectNode(testProject), path);
091: }
092:
093: @Override
094: public void prepare() {
095: log("::prepare");
096: new OpenAction().performAPI(fileToBeOpened);
097: editorOperator = EditorWindowOperator.getEditor(fileName);
098:
099: caretBlinkRate = editorOperator.txtEditorPane().getCaret()
100: .getBlinkRate();
101:
102: editorOperator.txtEditorPane().getCaret().setBlinkRate(0);
103: editorOperator.setCaretPosition(8, 1);
104: //repaintManager().addRegionFilter(LoggingRepaintManager.EDITOR_FILTER);
105: waitNoEvent(2000);
106: }
107:
108: @Override
109: public ComponentOperator open() {
110: log("::typing...");
111: editorOperator.typeKey('z');
112: return null;
113: }
114:
115: @Override
116: public void close() {
117: editorOperator.txtEditorPane().getCaret().setBlinkRate(
118: caretBlinkRate);
119: //repaintManager().resetRegionFilters();
120: EditorOperator.closeDiscardAll();
121:
122: }
123:
124: protected Node getProjectNode(String projectName) {
125: if (projectsTab == null)
126: projectsTab = new ProjectsTabOperator();
127:
128: return projectsTab.getProjectRootNode(projectName);
129: }
130:
131: public void test_RB_EditorTyping() {
132: testProject = Projects.RUBY_PROJECT;
133: fileName = "ruby20kb.rb";
134: nodePath = "Source Files";
135: doMeasurement();
136: }
137:
138: public void test_RHTML_EditorTyping() {
139: testProject = Projects.RAILS_PROJECT;
140: fileName = "rhtml20kb.rhtml";
141: nodePath = "Views";
142: doMeasurement();
143: }
144:
145: public void test_JScript_EditorTyping() {
146: testProject = Projects.SCRIPTING_PROJECT;
147: fileName = "javascript20kb.js";
148: nodePath = "Web Pages";
149: doMeasurement();
150: }
151: /*
152: public void test_JS_EditorTyping() {
153: testProject = "";
154: fileName = "";
155: nodePath = "";
156: doMeasurement();
157: }
158: public void test_JSON_EditorTyping() {
159: testProject = "";
160: fileName = "";
161: nodePath = "";
162: doMeasurement();
163: }
164: public void test_CSS_EditorTyping() {
165: testProject = "";
166: fileName = "";
167: nodePath = "";
168: doMeasurement();
169: }
170: public void test_YML_EditorTyping() {
171: testProject = "";
172: fileName = "";
173: nodePath = "";
174: doMeasurement();
175: }
176: public void test_BAT_EditorTyping() {
177: testProject = "";
178: fileName = "";
179: nodePath = "";
180: doMeasurement();
181: }
182: public void test_DIFF_EditorTyping() {
183: testProject = "";
184: fileName = "";
185: nodePath = "";
186: doMeasurement();
187: }
188: public void test_MANIFEST_EditorTyping() {
189: testProject = "";
190: fileName = "";
191: nodePath = "";
192: doMeasurement();
193: }
194: public void test_SH_EditorTyping() {
195: testProject = "";
196: fileName = "";
197: doMeasurement();
198: }
199: */
200: }
|