KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > TypingInJspEditor


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 import org.netbeans.jemmy.EventTool;
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.test.web.performance.WebPerformanceTestCase;
34
35 /**
36  * Test of typing in opened source editor.
37  *
38  * @author anebuzelsky@netbeans.org
39  */

40 public class TypingInJspEditor extends WebPerformanceTestCase {
41     private String JavaDoc file;
42     private int line;
43     
44     /** Creates a new instance of TypingInEditor */
45     public TypingInJspEditor(String JavaDoc file, int line, String JavaDoc testName) {
46         super(testName);
47         this.file = file;
48         this.line = line;
49         init();
50     }
51     
52     /** Creates a new instance of TypingInEditor */
53     public TypingInJspEditor(String JavaDoc file, int line, String JavaDoc testName, String JavaDoc performanceDataName) {
54         super(testName, performanceDataName);
55         this.file = file;
56         this.line = line;
57         init();
58     }
59     
60     protected void init() {
61         super.init();
62         expectedTime = UI_RESPONSE;
63         WAIT_AFTER_PREPARE = 3000;
64     }
65     
66     private EditorOperator editorOperator;
67     
68     protected void initialize() {
69         System.out.println("=== " + this.getClass().getName() + " ===");
70         jspOptions().setCaretBlinkRate(0);
71         // delay between the caret stops and the update of his position in status bar
72
jspOptions().setStatusBarCaretDelay(0);
73         jspOptions().setFontSize(20);
74         jspOptions().setCodeFoldingEnable(false);
75         // open a java file in the editor
76
new OpenAction().performAPI(new Node(new ProjectsTabOperator().getProjectRootNode("TestWebProject"),"Web Pages|"+file));
77         editorOperator = new EditorWindowOperator().getEditor(file);
78         // go to the right place
79
editorOperator.setCaretPositionToLine(line);
80         // make the file modified
81
//XXX new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_ENTER)).perform(editorOperator);
82
//wait painting pf folds in the editor
83
new EventTool().waitNoEvent(1000);
84     }
85     
86     public void prepare() {
87    }
88     
89     public ComponentOperator open(){
90         repaintManager().setOnlyEditor(true);
91         new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_A)).perform(editorOperator);
92         return null;
93     }
94     
95     public void close() {
96         repaintManager().setOnlyEditor(false);
97     }
98     
99     protected void shutdown() {
100         editorOperator.closeDiscard();
101         super.shutdown();
102     }
103 }
104
Popular Tags