KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > ExpandNodesWebProjectsView


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 org.netbeans.jellytools.ProjectsTabOperator;
23
24 import org.netbeans.jellytools.actions.MaximizeWindowAction;
25 import org.netbeans.jellytools.actions.RestoreWindowAction;
26
27 import org.netbeans.jellytools.nodes.Node;
28
29 import org.netbeans.jemmy.operators.ComponentOperator;
30 import org.netbeans.test.web.performance.WebPerformanceTestCase;
31
32
33 /**
34  * Test of expanding nodes/folders in the Explorer.
35  *
36  * @author mmirilovic@netbeans.org
37  */

38 public class ExpandNodesWebProjectsView extends WebPerformanceTestCase {
39     /** Name of the folder which test creates and expands */
40     private static String JavaDoc project;
41     /** Path to the folder which test creates and expands */
42     private static String JavaDoc pathToFolderNode;
43     /** Node represantation of the folder which test creates and expands */
44     private static Node nodeToBeExpanded;
45     /** Projects tab */
46     private static ProjectsTabOperator projectTab;
47     /** Project with data for these tests */
48     private static String JavaDoc testDataProject = "PerformanceTestFolderWebApp";
49     /**
50      * Creates a new instance of ExpandNodesInExplorer
51      * @param testName the name of the test
52      */

53     public ExpandNodesWebProjectsView(String JavaDoc testName) {
54         super(testName);
55         init();
56     }
57     
58     /**
59      * Creates a new instance of ExpandNodesInExplorer
60      * @param testName the name of the test
61      * @param performanceDataName measured values will be saved under this name
62      */

63     public ExpandNodesWebProjectsView(String JavaDoc testName, String JavaDoc performanceDataName) {
64         super(testName, performanceDataName);
65     }
66     
67     protected void init() {
68         super.init();
69         project = testDataProject;
70         expectedTime = WINDOW_OPEN;
71         WAIT_AFTER_OPEN = 1000;
72         WAIT_AFTER_PREPARE = 2000;
73     }
74
75     public void testExpandProjectNode(){
76         pathToFolderNode = "";
77         doMeasurement();
78     }
79
80     public void testExpandSourcePackagesNode(){
81         pathToFolderNode = "Source Packages";
82         doMeasurement();
83     }
84     
85     public void testExpandFolderWith50JspFiles(){
86         pathToFolderNode = "Web Pages|jsp50";
87         doMeasurement();
88     }
89     
90     public void testExpandFolderWith100JspFiles(){
91         pathToFolderNode = "Web Pages|jsp100";
92         doMeasurement();
93     }
94     
95     public void initialize(){
96         projectTab = new ProjectsTabOperator();
97         new MaximizeWindowAction().performAPI(projectTab);
98         projectTab.getProjectRootNode("PerformanceTestData").collapse();
99         projectTab.getProjectRootNode("TestWebProject").collapse();
100         projectTab.getProjectRootNode("PerformanceTestFoldersData").collapse();
101         System.setProperty("perf.dont.resolve.java.badges", "true");
102     }
103         
104     public void prepare() {
105         if(pathToFolderNode.equals(""))
106             nodeToBeExpanded = projectTab.getProjectRootNode(project);
107         else
108         nodeToBeExpanded = new Node(projectTab.getProjectRootNode(project), pathToFolderNode);
109         repaintManager().setOnlyExplorer(true);
110         nodeToBeExpanded.select();
111     }
112     
113     public ComponentOperator open(){
114         nodeToBeExpanded.expand();
115         return null;
116     }
117     
118     public void close(){
119         repaintManager().setOnlyExplorer(false);
120         nodeToBeExpanded.collapse();
121     }
122     
123     public void shutdown() {
124         super.shutdown();
125         System.setProperty("perf.dont.resolve.java.badges", "false");
126         projectTab.getProjectRootNode(testDataProject).collapse();
127         new RestoreWindowAction().performAPI(projectTab);
128     }
129 }
130
Popular Tags