KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > PasteInJspEditor


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 import java.awt.event.KeyEvent JavaDoc;
22
23 import org.netbeans.jellytools.EditorOperator;
24 import org.netbeans.jellytools.EditorWindowOperator;
25 import org.netbeans.jellytools.ProjectsTabOperator;
26 import org.netbeans.jellytools.actions.CopyAction;
27 import org.netbeans.jellytools.nodes.Node;
28 import org.netbeans.jellytools.actions.ActionNoBlock;
29 import org.netbeans.jellytools.actions.OpenAction;
30 import org.netbeans.jellytools.actions.Action.Shortcut;
31
32 import org.netbeans.jemmy.operators.ComponentOperator;
33 import org.netbeans.test.web.performance.WebPerformanceTestCase;
34
35
36 /**
37  * Test of Paste text to opened source editor.
38  *
39  * @author anebuzelsky@netbeans.org, mmirilovic@netbeans.org
40  */

41 public class PasteInJspEditor extends WebPerformanceTestCase {
42     private String JavaDoc file;
43     private EditorOperator editorOperator1, editorOperator2;
44     
45     /** Creates a new instance of PasteInEditor */
46     public PasteInJspEditor(String JavaDoc testName) {
47         super(testName);
48         init();
49     }
50     
51     /** Creates a new instance of PasteInEditor */
52     public PasteInJspEditor(String JavaDoc file, String JavaDoc testName, String JavaDoc performanceDataName) {
53         super(testName, performanceDataName);
54         this.file = file;
55         init();
56     }
57     
58     protected void init() {
59         super.init();
60         expectedTime = UI_RESPONSE;
61         WAIT_AFTER_PREPARE = 3000;
62         WAIT_AFTER_OPEN = 3000;
63     }
64     
65     protected void initialize() {
66         EditorOperator.closeDiscardAll();
67         jspOptions().setCaretBlinkRate(0);
68         // delay between the caret stops and the update of his position in status bar
69
jspOptions().setStatusBarCaretDelay(0);
70         jspOptions().setFontSize(20);
71         jspOptions().setCodeFoldingEnable(false);
72         // open two java files in the editor
73
new OpenAction().performAPI(new Node(new ProjectsTabOperator().getProjectRootNode("TestWebProject"),"Web Pages|Test.jsp"));
74         editorOperator1 = new EditorWindowOperator().getEditor("Test.jsp");
75         new OpenAction().performAPI(new Node(new ProjectsTabOperator().getProjectRootNode("TestWebProject"),"Web Pages|"+file));
76         editorOperator2 = new EditorWindowOperator().getEditor(file);
77         // copy a part of the first file to the clipboard
78
editorOperator1.makeComponentVisible();
79         editorOperator1.select(12,18);
80         new CopyAction().perform();
81         // go to the end of the second file
82
editorOperator2.makeComponentVisible();
83         editorOperator2.setCaretPositionToLine(1);
84         new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_END, KeyEvent.CTRL_MASK)).perform(editorOperator2);
85         eventTool().waitNoEvent(2000);
86     }
87     
88     public void prepare() {
89         System.out.println("=== " + this.getClass().getName() + " ===");
90     }
91     
92     public ComponentOperator open(){
93         repaintManager().setOnlyEditor(true);
94         // paste the clipboard contents
95
new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_V, KeyEvent.CTRL_MASK)).perform(editorOperator2);
96         return null;
97     }
98     
99     public void close() {
100         repaintManager().setOnlyEditor(false);
101     }
102     
103     protected void shutdown() {
104         super.shutdown();
105         // close the second file without saving it
106
editorOperator1.closeDiscard();
107         editorOperator2.closeDiscard();
108     }
109 }
110
Popular Tags