001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package gui.action;
043:
044: import org.netbeans.jellytools.ProjectsTabOperator;
045:
046: import org.netbeans.jellytools.actions.MaximizeWindowAction;
047: import org.netbeans.jellytools.actions.RestoreWindowAction;
048:
049: import org.netbeans.jellytools.nodes.Node;
050:
051: import org.netbeans.jemmy.operators.ComponentOperator;
052:
053: /**
054: * Test of expanding nodes/folders in the Explorer.
055: *
056: * @author mmirilovic@netbeans.org
057: */
058: public class ExpandNodesProjectsView extends
059: org.netbeans.performance.test.utilities.PerformanceTestCase {
060:
061: /** Name of the folder which test creates and expands */
062: protected String project;
063:
064: /** Path to the folder which test creates and expands */
065: protected String pathToFolderNode;
066:
067: /** Node represantation of the folder which test creates and expands */
068: protected Node nodeToBeExpanded;
069:
070: /** Projects tab */
071: protected ProjectsTabOperator projectTab;
072:
073: /**
074: * Creates a new instance of ExpandNodesInExplorer
075: * @param testName the name of the test
076: */
077: public ExpandNodesProjectsView(String testName) {
078: super (testName);
079: expectedTime = WINDOW_OPEN;
080: }
081:
082: /**
083: * Creates a new instance of ExpandNodesInExplorer
084: * @param testName the name of the test
085: * @param performanceDataName measured values will be saved under this name
086: */
087: public ExpandNodesProjectsView(String testName,
088: String performanceDataName) {
089: super (testName, performanceDataName);
090: expectedTime = WINDOW_OPEN;
091: }
092:
093: public void testExpandProjectNode() {
094: WAIT_AFTER_OPEN = 3000;
095: WAIT_AFTER_PREPARE = 2000;
096: project = "jEdit";
097: pathToFolderNode = "";
098: doMeasurement();
099: }
100:
101: public void testExpandSourcePackagesNode() {
102: WAIT_AFTER_OPEN = 3000;
103: WAIT_AFTER_PREPARE = 2000;
104: project = "jEdit";
105: pathToFolderNode = gui.Utilities.SOURCE_PACKAGES;
106: doMeasurement();
107: }
108:
109: public void testExpandFolderWith50JavaFiles() {
110: WAIT_AFTER_OPEN = 3000;
111: WAIT_AFTER_PREPARE = 2000;
112: project = "PerformanceTestFoldersData";
113: pathToFolderNode = gui.Utilities.SOURCE_PACKAGES
114: + "|folders.javaFolder50";
115: doMeasurement();
116: }
117:
118: public void testExpandFolderWith100JavaFiles() {
119: WAIT_AFTER_OPEN = 3000;
120: WAIT_AFTER_PREPARE = 2000;
121: project = "PerformanceTestFoldersData";
122: pathToFolderNode = gui.Utilities.SOURCE_PACKAGES
123: + "|folders.javaFolder100";
124: doMeasurement();
125: }
126:
127: public void testExpandFolderWith100XmlFiles() {
128: WAIT_AFTER_OPEN = 3000;
129: WAIT_AFTER_PREPARE = 500;
130: project = "PerformanceTestFoldersData";
131: pathToFolderNode = gui.Utilities.SOURCE_PACKAGES
132: + "|folders.xmlFolder100";
133: doMeasurement();
134: }
135:
136: public void testExpandFolderWith100TxtFiles() {
137: WAIT_AFTER_OPEN = 3000;
138: WAIT_AFTER_PREPARE = 500;
139: project = "PerformanceTestFoldersData";
140: pathToFolderNode = gui.Utilities.SOURCE_PACKAGES
141: + "|folders.txtFolder100";
142: doMeasurement();
143: }
144:
145: public void initialize() {
146: projectTab = new ProjectsTabOperator();
147: new MaximizeWindowAction().performAPI(projectTab);
148:
149: projectTab.getProjectRootNode("jEdit").collapse();
150: projectTab.getProjectRootNode("PerformanceTestFoldersData")
151: .collapse();
152:
153: turnBadgesOff();
154: repaintManager().addRegionFilter(
155: repaintManager().EXPLORER_FILTER);
156: }
157:
158: public void prepare() {
159: log("====== Path to folder: {" + project + "|"
160: + pathToFolderNode + "}");
161: if (pathToFolderNode.equals(""))
162: nodeToBeExpanded = projectTab.getProjectRootNode(project);
163: else
164: nodeToBeExpanded = new Node(projectTab
165: .getProjectRootNode(project), pathToFolderNode);
166: log("====== Node to be expanded: {"
167: + nodeToBeExpanded.getPath() + "}");
168: }
169:
170: public ComponentOperator open() {
171: // nodeToBeExpanded.tree().clickOnPath(nodeToBeExpanded.getTreePath(), 2);
172: nodeToBeExpanded.tree().doExpandPath(
173: nodeToBeExpanded.getTreePath());
174: // nodeToBeExpanded.tree().clickMouse(2);
175: // nodeToBeExpanded.waitExpanded();
176: nodeToBeExpanded.expand();
177: return null;
178: }
179:
180: public void close() {
181: nodeToBeExpanded.collapse();
182: }
183:
184: public void shutdown() {
185: repaintManager().resetRegionFilters();
186: turnBadgesOn();
187: projectTab.getProjectRootNode(project).collapse();
188: new RestoreWindowAction().performAPI(projectTab);
189: }
190:
191: /**
192: * turn badges off
193: */
194: protected void turnBadgesOff() {
195: System.setProperty("perf.dont.resolve.java.badges", "true");
196: }
197:
198: /**
199: * turn badges on
200: */
201: protected void turnBadgesOn() {
202: System.setProperty("perf.dont.resolve.java.badges", "false");
203: }
204:
205: public static void main(java.lang.String[] args) {
206: junit.textui.TestRunner.run(new ExpandNodesProjectsView(
207: "testExpandFolderWith100XmlFiles"));
208: }
209:
210: }
|