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:
046: import org.netbeans.jellytools.EditorOperator;
047: import org.netbeans.jellytools.EditorWindowOperator;
048: import org.netbeans.jellytools.ProjectsTabOperator;
049: import org.netbeans.jellytools.nodes.Node;
050: import org.netbeans.jellytools.actions.ActionNoBlock;
051: import org.netbeans.jellytools.actions.Action.Shortcut;
052: import org.netbeans.jellytools.actions.OpenAction;
053:
054: import org.netbeans.jemmy.operators.ComponentOperator;
055: import org.netbeans.modules.editor.options.BaseOptions;
056: import org.netbeans.modules.web.core.syntax.JSPKit;
057: import org.netbeans.modules.web.core.syntax.settings.JSPOptions;
058: import org.netbeans.test.web.performance.WebPerformanceTestCase;
059:
060: /**
061: * Test of Page Up and Page Down in opened source editor.
062: *
063: * @author anebuzelsky@netbeans.org
064: */
065: public class PageUpPageDownInJspEditor extends WebPerformanceTestCase {
066: private boolean pgup;
067: private String file;
068:
069: /** Creates a new instance of PageUpPageDownInEditor */
070: public PageUpPageDownInJspEditor(String file, String testName) {
071: super (testName);
072: pgup = true;
073: this .file = file;
074: init();
075: }
076:
077: /** Creates a new instance of PageUpPageDownInEditor */
078: public PageUpPageDownInJspEditor(String file, String testName,
079: String performanceDataName, boolean up) {
080: super (testName, performanceDataName);
081: pgup = up;
082: this .file = file;
083: init();
084: }
085:
086: protected void init() {
087: super .init();
088: expectedTime = UI_RESPONSE;
089: }
090:
091: private EditorOperator editorOperator;
092: private int statusBarCaretDelay;
093: private boolean codeFoldindEnabled;
094:
095: protected void initialize() {
096: EditorOperator.closeDiscardAll();
097: jspOptions().setCaretBlinkRate(0);
098: // delay between the caret stops and the update of his position in status bar
099: jspOptions().setStatusBarCaretDelay(0);
100: // jspOptions().setCodeFoldingEnable(false);
101: // open a java file in the editor
102: new OpenAction().performAPI(new Node(new ProjectsTabOperator()
103: .getProjectRootNode("TestWebProject"), "Web Pages|"
104: + file));
105: editorOperator = new EditorWindowOperator().getEditor(file);
106: // turn off the status bar delay
107: JSPOptions options = (JSPOptions) BaseOptions
108: .getOptions(JSPKit.class);
109: statusBarCaretDelay = options.getStatusBarCaretDelay();
110: options.setStatusBarCaretDelay(0);
111: // codeFoldindEnabled = options.getCodeFoldingEnable();
112: // options.setCodeFoldingEnable(false);
113: waitNoEvent(2000);
114: }
115:
116: public void prepare() {
117: System.out.println("=== " + this .getClass().getName() + " ===");
118: // scroll to the place where we start
119: if (pgup)
120: // press CTRL+END
121: new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_END,
122: KeyEvent.CTRL_MASK)).perform(editorOperator);
123: else
124: // go to the first line
125: editorOperator.setCaretPositionToLine(1);
126: eventTool().waitNoEvent(500);
127: }
128:
129: public ComponentOperator open() {
130: //repaintManager().setOnlyEditor(true);
131: repaintManager()
132: .addRegionFilter(repaintManager().EDITOR_FILTER);
133: if (pgup)
134: new ActionNoBlock(null, null, new Shortcut(
135: KeyEvent.VK_PAGE_UP)).perform(editorOperator);
136: else
137: new ActionNoBlock(null, null, new Shortcut(
138: KeyEvent.VK_PAGE_DOWN)).perform(editorOperator);
139: return null;
140: }
141:
142: protected void shutdown() {
143: repaintManager().resetRegionFilters(); ///added reset filters command - possibly missing previously
144: editorOperator.closeDiscard();
145: super.shutdown();
146: }
147: }
|