KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gui > action > ExpandNodesJavaProjectsView


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 ExpandNodesJavaProjectsView 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 = "PerformanceTestFoldersData";
49     
50     /**
51      * Creates a new instance of ExpandNodesInExplorer
52      * @param testName the name of the test
53      */

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

64     public ExpandNodesJavaProjectsView(String JavaDoc testName, String JavaDoc performanceDataName) {
65         super(testName, performanceDataName);
66         init();
67     }
68     
69     protected void init() {
70         super.init();
71         project = testDataProject;
72         expectedTime = WINDOW_OPEN;
73         WAIT_AFTER_OPEN = 1000;
74         WAIT_AFTER_PREPARE = 2000;
75     }
76     
77     public void testExpandProjectNode(){
78         pathToFolderNode = "";
79         doMeasurement();
80     }
81     
82     public void testExpandSourcePackagesNode(){
83         pathToFolderNode = "Source Packages";
84         doMeasurement();
85     }
86     
87     public void testExpandFolderWith50JavaFiles(){
88         pathToFolderNode = "Source Packages|javaFolder50";
89         doMeasurement();
90     }
91     
92     public void testExpandFolderWith100JavaFiles(){
93         pathToFolderNode = "Source Packages|javaFolder100";
94         doMeasurement();
95     }
96     
97     public void testExpandFolderWith100XmlFiles(){
98         pathToFolderNode = "Source Packages|xmlFolder100";
99         doMeasurement();
100     }
101     
102     public void testExpandFolderWith100TxtFiles(){
103         pathToFolderNode = "Source Packages|txtFolder100";
104         doMeasurement();
105     }
106     
107     public void initialize(){
108         projectTab = new ProjectsTabOperator();
109         new MaximizeWindowAction().performAPI(projectTab);
110         projectTab.getProjectRootNode("PerformanceTestData").collapse();
111         projectTab.getProjectRootNode("TestWebProject").collapse();
112         projectTab.getProjectRootNode("PerformanceTestFolderWebApp").collapse();
113         // turn badges on
114
System.setProperty("perf.dont.resolve.java.badges", "true");
115     }
116     
117     
118     public void prepare() {
119         if(pathToFolderNode.equals(""))
120             nodeToBeExpanded = projectTab.getProjectRootNode(project);
121         else
122             nodeToBeExpanded = new Node(projectTab.getProjectRootNode(project), pathToFolderNode);
123         repaintManager().setOnlyExplorer(true);
124     }
125     
126     public ComponentOperator open(){
127         //nodeToBeExpanded.tree().clickOnPath(nodeToBeExpanded.getTreePath(), 2);
128
nodeToBeExpanded.expand();
129         return null;
130     }
131     
132     public void close(){
133         repaintManager().setOnlyExplorer(true);
134         nodeToBeExpanded.collapse();
135     }
136     
137     public void shutdown() {
138         super.shutdown();
139         // turn badges off
140
System.setProperty("perf.dont.resolve.java.badges", "false");
141         projectTab.getProjectRootNode(testDataProject).collapse();
142         new RestoreWindowAction().performAPI(projectTab);
143     }
144 }
145
Popular Tags