KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > menu > WebRuntimeViewPopupMenu


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.menu;
21 import java.awt.Point JavaDoc;
22 import java.awt.event.KeyEvent JavaDoc;
23 import org.netbeans.jellytools.Bundle;
24 import org.netbeans.jellytools.actions.ActionNoBlock;
25 import org.netbeans.jellytools.RuntimeTabOperator;
26 import org.netbeans.jellytools.actions.Action.Shortcut;
27 import org.netbeans.jellytools.nodes.Node;
28
29 import org.netbeans.jemmy.operators.ComponentOperator;
30 import org.netbeans.performance.test.guitracker.ActionTracker;
31 import org.netbeans.test.web.performance.Macros;
32 import org.netbeans.test.web.performance.WebPerformanceTestCase;
33
34 /**
35  * Test of typing in opened source editor.
36  *
37  * @author mschovanek@netbeans.org
38  */

39 public class WebRuntimeViewPopupMenu extends WebPerformanceTestCase {
40     private Node dataObjectNode;
41     private RuntimeTabOperator runtimeTab = null;
42     private boolean isTomcatRunning = false;
43     
44     // strings
45
private static String JavaDoc SERVERS = Bundle.getStringTrimmed(
46         "org.netbeans.modules.j2ee.deployment.impl.ui.Bundle",
47         "SERVER_REGISTRY_NODE");
48     private static String JavaDoc BUNDLED_TOMCAT = "Bundled Tomcat"; // not in a bundle
49
private static String JavaDoc WEB_APPLICATIONS = Bundle.getStringTrimmed(
50         "org.netbeans.modules.tomcat5.nodes.Bundle",
51         "LBL_WebApps");
52     
53     /** Creates a new instance of TypingInEditor */
54     public WebRuntimeViewPopupMenu(String JavaDoc testName) {
55         super(testName);
56         init();
57     }
58     
59     /** Creates a new instance of TypingInEditor */
60     public WebRuntimeViewPopupMenu(String JavaDoc testName, String JavaDoc performanceDataName) {
61         super(testName, performanceDataName);
62         init();
63     }
64     
65     protected void init() {
66         super.init();
67         expectedTime = UI_RESPONSE;
68         track_mouse_event = ActionTracker.TRACK_MOUSE_PRESS;
69         WAIT_AFTER_PREPARE = 500;
70         WAIT_AFTER_OPEN = 1000;
71     }
72     
73     public void testServerRegistryPopupMenuRuntime(){
74         testMenu(SERVERS, false);
75     }
76     
77     public void testTomcatPopupMenuRuntime(){
78         testMenu(SERVERS+"|"+BUNDLED_TOMCAT, false);
79     }
80     
81     public void testWebModulesPopupMenuRuntime(){
82         testMenu(SERVERS+"|"+BUNDLED_TOMCAT+"|"+WEB_APPLICATIONS, true);
83     }
84     
85     public void testWebModulePopupMenuRuntime(){
86         testMenu(SERVERS+"|"+BUNDLED_TOMCAT+"|"+WEB_APPLICATIONS+"|/manager", true);
87     }
88     
89     
90     private void testMenu(String JavaDoc path, boolean startTomcat){
91         if (startTomcat) {
92             Macros.startBundledTomact();
93             isTomcatRunning = true;
94         }
95         RuntimeTabOperator runtimeTab = RuntimeTabOperator.invoke();
96         dataObjectNode = new Node(runtimeTab.getRootNode(), path);
97         doMeasurement();
98     }
99     
100     protected void initialize() {
101         System.out.println("=== " + this.getClass().getName() + " ===");
102     }
103     
104     public void prepare() {
105         dataObjectNode.select();
106         eventTool().waitNoEvent(1000);
107     }
108     
109     public ComponentOperator open(){
110         Point JavaDoc point = dataObjectNode.tree().getPointToClick(dataObjectNode
111             .getTreePath());
112         int button = dataObjectNode.tree().getPopupMouseButton();
113         dataObjectNode.tree().clickMouse(point.x, point.y, 1, button);
114         return null;
115     }
116     
117     public void close() {
118         new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_ESCAPE)).
119             perform();
120     }
121     
122     protected void shutdown() {
123         if (isTomcatRunning) {
124             Macros.stopBundledTomact();
125         }
126         super.shutdown();
127     }
128 }
129
Popular Tags