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-2006Sun
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 java.awt.event.KeyEvent;
045: import javax.swing.KeyStroke;
046: import org.netbeans.jemmy.EventTool;
047: import org.netbeans.jellytools.EditorOperator;
048: import org.netbeans.jellytools.EditorWindowOperator;
049: import org.netbeans.jellytools.ProjectsTabOperator;
050: import org.netbeans.jellytools.nodes.Node;
051: import org.netbeans.jellytools.actions.ActionNoBlock;
052: import org.netbeans.jellytools.actions.Action.Shortcut;
053: import org.netbeans.jellytools.actions.OpenAction;
054:
055: import org.netbeans.jemmy.operators.ComponentOperator;
056: import org.netbeans.test.web.performance.WebPerformanceTestCase;
057:
058: /**
059: * Test of typing in opened source editor.
060: *
061: * @author anebuzelsky@netbeans.org
062: */
063: public class TypingInJspEditor extends WebPerformanceTestCase {
064: private String file;
065: private int line;
066:
067: /** Creates a new instance of TypingInEditor */
068: public TypingInJspEditor(String file, int line, String testName) {
069: super (testName);
070: this .file = file;
071: this .line = line;
072: init();
073: }
074:
075: /** Creates a new instance of TypingInEditor */
076: public TypingInJspEditor(String file, int line, String testName,
077: String performanceDataName) {
078: super (testName, performanceDataName);
079: this .file = file;
080: this .line = line;
081: init();
082: }
083:
084: protected void init() {
085: super .init();
086: expectedTime = UI_RESPONSE;
087: WAIT_AFTER_PREPARE = 3000;
088: }
089:
090: private EditorOperator editorOperator;
091:
092: protected void initialize() {
093: System.out.println("=== " + this .getClass().getName() + " ===");
094: jspOptions().setCaretBlinkRate(0);
095: // delay between the caret stops and the update of his position in status bar
096: jspOptions().setStatusBarCaretDelay(0);
097: jspOptions().setFontSize(20);
098: // jspOptions().setCodeFoldingEnable(false);
099: // open a java file in the editor
100: new OpenAction().performAPI(new Node(new ProjectsTabOperator()
101: .getProjectRootNode("TestWebProject"), "Web Pages|"
102: + file));
103: editorOperator = new EditorWindowOperator().getEditor(file);
104: // go to the right place
105: editorOperator.setCaretPositionToLine(line);
106: // make the file modified
107: //XXX new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_ENTER)).perform(editorOperator);
108: //wait painting pf folds in the editor
109: new EventTool().waitNoEvent(1000);
110: }
111:
112: public void prepare() {
113: }
114:
115: public ComponentOperator open() {
116: //repaintManager().setOnlyEditor(true);
117: repaintManager()
118: .addRegionFilter(repaintManager().EDITOR_FILTER);
119: KeyStroke keyA = KeyStroke.getKeyStroke('a');
120: new ActionNoBlock(null, null, keyA).perform(editorOperator);
121: return null;
122: }
123:
124: public void close() {
125: //repaintManager().setOnlyEditor(false);
126: repaintManager().resetRegionFilters();
127:
128: }
129:
130: protected void shutdown() {
131: editorOperator.closeDiscard();
132: super.shutdown();
133: }
134: }
|