KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > PageUpPageDownInJspEditor


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package gui.action;
21
22 import java.awt.event.KeyEvent JavaDoc;
23
24 import org.netbeans.jellytools.EditorOperator;
25 import org.netbeans.jellytools.EditorWindowOperator;
26 import org.netbeans.jellytools.ProjectsTabOperator;
27 import org.netbeans.jellytools.nodes.Node;
28 import org.netbeans.jellytools.actions.ActionNoBlock;
29 import org.netbeans.jellytools.actions.Action.Shortcut;
30 import org.netbeans.jellytools.actions.OpenAction;
31
32 import org.netbeans.jemmy.operators.ComponentOperator;
33 import org.netbeans.modules.editor.options.BaseOptions;
34 import org.netbeans.modules.web.core.syntax.JSPKit;
35 import org.netbeans.modules.web.core.syntax.settings.JSPOptions;
36 import org.netbeans.test.web.performance.WebPerformanceTestCase;
37
38
39 /**
40  * Test of Page Up and Page Down in opened source editor.
41  *
42  * @author anebuzelsky@netbeans.org
43  */

44 public class PageUpPageDownInJspEditor extends WebPerformanceTestCase {
45     private boolean pgup;
46     private String JavaDoc file;
47     
48     /** Creates a new instance of PageUpPageDownInEditor */
49     public PageUpPageDownInJspEditor(String JavaDoc file, String JavaDoc testName) {
50         super(testName);
51         pgup = true;
52         this.file = file;
53         init();
54     }
55     
56     /** Creates a new instance of PageUpPageDownInEditor */
57     public PageUpPageDownInJspEditor(String JavaDoc file, String JavaDoc testName, String JavaDoc performanceDataName, boolean up) {
58         super(testName, performanceDataName);
59         pgup = up;
60         this.file = file;
61         init();
62     }
63     
64     protected void init() {
65         super.init();
66         expectedTime = UI_RESPONSE;
67     }
68     
69     private EditorOperator editorOperator;
70     private int statusBarCaretDelay;
71     private boolean codeFoldindEnabled;
72     
73     protected void initialize() {
74         EditorOperator.closeDiscardAll();
75         jspOptions().setCaretBlinkRate(0);
76         // delay between the caret stops and the update of his position in status bar
77
jspOptions().setStatusBarCaretDelay(0);
78         jspOptions().setCodeFoldingEnable(false);
79         // open a java file in the editor
80
new OpenAction().performAPI(new Node(new ProjectsTabOperator().getProjectRootNode("TestWebProject"),"Web Pages|"+file));
81         editorOperator = new EditorWindowOperator().getEditor(file);
82         // turn off the status bar delay
83
JSPOptions options = (JSPOptions) BaseOptions.getOptions(JSPKit.class);
84         statusBarCaretDelay = options.getStatusBarCaretDelay();
85         options.setStatusBarCaretDelay(0);
86         codeFoldindEnabled = options.getCodeFoldingEnable();
87         options.setCodeFoldingEnable(false);
88         waitNoEvent(2000);
89     }
90     
91     public void prepare() {
92         System.out.println("=== " + this.getClass().getName() + " ===");
93         // scroll to the place where we start
94
if (pgup)
95             // press CTRL+END
96
new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_END, KeyEvent.CTRL_MASK)).perform(editorOperator);
97         else
98             // go to the first line
99
editorOperator.setCaretPositionToLine(1);
100         eventTool().waitNoEvent(500);
101     }
102     
103     public ComponentOperator open(){
104         repaintManager().setOnlyEditor(true);
105         if (pgup)
106             new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_PAGE_UP)).perform(editorOperator);
107         else
108             new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_PAGE_DOWN)).perform(editorOperator);
109         return null;
110     }
111     
112     protected void shutdown() {
113         editorOperator.closeDiscard();
114         super.shutdown();
115     }
116 }
117
Popular Tags