KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > ToggleBreakpoint


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package gui.action;
21
22 import java.awt.event.KeyEvent JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.List JavaDoc;
25
26 import org.netbeans.jellytools.EditorOperator;
27 import org.netbeans.jellytools.EditorWindowOperator;
28 import org.netbeans.jellytools.ProjectsTabOperator;
29 import org.netbeans.jellytools.TopComponentOperator;
30 import org.netbeans.jellytools.actions.Action;
31 import org.netbeans.jellytools.nodes.Node;
32 import org.netbeans.jellytools.actions.ActionNoBlock;
33 import org.netbeans.jellytools.actions.OpenAction;
34 import org.netbeans.jellytools.actions.Action.Shortcut;
35
36 import org.netbeans.jemmy.operators.ComponentOperator;
37 import org.netbeans.test.web.performance.WebPerformanceTestCase;
38
39
40 /**
41  * Test of Paste text to opened source editor.
42  *
43  * @author anebuzelsky@netbeans.org, mmirilovic@netbeans.org
44  */

45 public class ToggleBreakpoint extends WebPerformanceTestCase {
46     private String JavaDoc file;
47     private List JavaDoc bpList = new ArrayList JavaDoc();
48     /** Creates a new instance of ToggleBreakpoint */
49     public ToggleBreakpoint(String JavaDoc testName) {
50         super(testName);
51         init();
52     }
53     
54     /** Creates a new instance of ToggleBreakpoint */
55     public ToggleBreakpoint(String JavaDoc file, String JavaDoc testName, String JavaDoc performanceDataName) {
56         super(testName, performanceDataName);
57         this.file = file;
58     }
59     
60     protected void init() {
61         super.init();
62         expectedTime = UI_RESPONSE;
63     }
64     private EditorOperator editorOperator1;
65     
66     protected void initialize() {
67         EditorOperator.closeDiscardAll();
68         jspOptions().setCaretBlinkRate(0);
69         // delay between the caret stops and the update of his position in status bar
70
jspOptions().setStatusBarCaretDelay(0);
71         // open file in the editor
72
new OpenAction().performAPI(new Node(new ProjectsTabOperator().getProjectRootNode("TestWebProject"),"Web Pages|"+file));
73         editorOperator1 = new EditorWindowOperator().getEditor(file);
74         eventTool().waitNoEvent(500);
75         waitNoEvent(1000);
76     }
77     
78     public void prepare() {
79         System.out.println("=== " + this.getClass().getName() + " ===");
80         editorOperator1.makeComponentVisible();
81         editorOperator1.setCaretPosition(7,1);
82         eventTool().waitNoEvent(100);
83     }
84     
85     public ComponentOperator open(){
86         // Toggle Breakpoint
87
new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_F8, KeyEvent.CTRL_MASK)).perform(editorOperator1);
88         return null;
89     }
90     
91     public void close() {
92         deleteAllBreakpoints();
93     }
94     
95     protected void shutdown() {
96         editorOperator1.closeDiscard();
97         super.shutdown();
98     }
99     
100     private void deleteAllBreakpoints() {
101         new Action("Window|Debugging|Breakpoints",null).perform();
102         TopComponentOperator tco = new TopComponentOperator("Breakpoints");
103         new Action(null,"Delete All").perform(tco);
104         tco.close();
105     }
106 }
107
Popular Tags