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-2006 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 startup;
043:
044: import java.io.PrintStream;
045:
046: import org.netbeans.jellytools.*;
047: import org.netbeans.jellytools.actions.EditAction;
048: import org.netbeans.jellytools.actions.OpenAction;
049: import org.netbeans.jellytools.nodes.Node;
050: import org.netbeans.jellytools.nodes.SourcePackagesNode;
051:
052: import org.netbeans.jemmy.operators.*;
053:
054: import junit.framework.Test;
055: import junit.framework.TestSuite;
056:
057: import org.netbeans.junit.NbTestSuite;
058: import org.netbeans.junit.ide.ProjectSupport;
059:
060: /**
061: * Prepare user directory for measurement of startup time of IDE with opened files.
062: * Open 10 java files and shut down ide.
063: * Created user directory will be used to measure startup time of IDE with opened files.
064: *
065: * @author Marian.Mirilovic@sun.com
066: */
067: public class MeasureNB40WebStartupTimeOpenedFilesPrepare extends
068: JellyTestCase {
069:
070: /** Error output from the test. */
071: protected static PrintStream err;
072:
073: /** Logging output from the test. */
074: protected static PrintStream log;
075:
076: /** Define testcase
077: * @param testName name of the testcase
078: */
079: public MeasureNB40WebStartupTimeOpenedFilesPrepare(String testName) {
080: super (testName);
081: }
082:
083: /** Testsuite
084: * @return testuite
085: */
086: public static Test suite() {
087: TestSuite suite = new NbTestSuite();
088: suite.addTest(new IDESetupTest("testCloseMemoryToolbar"));
089: suite.addTest(new IDESetupTest("testCloseWelcome"));
090: suite.addTest(new MeasureNB40WebStartupTimeOpenedFilesPrepare(
091: "testOpenProjects"));
092: suite.addTest(new MeasureNB40WebStartupTimeOpenedFilesPrepare(
093: "openFiles"));
094: return suite;
095: }
096:
097: public void setUp() {
098: // err = System.out;
099: err = getLog();
100: log = getRef();
101: }
102:
103: public void testOpenProjects() {
104: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
105: + "/startup_nb40/TestWebApp");
106: ProjectSupport.waitScanFinished();
107: //waitForScan();
108: }
109:
110: private void waitForScan() {
111: // "Scanning Project Classpaths"
112: String titleScanning = Bundle.getString(
113: "org.netbeans.modules.javacore.Bundle",
114: "TXT_ApplyingPathsTitle");
115: NbDialogOperator scanningDialogOper = new NbDialogOperator(
116: titleScanning);
117: // scanning can last for a long time => wait max. 5 minutes
118: scanningDialogOper.getTimeouts().setTimeout(
119: "ComponentOperator.WaitStateTimeout", 300000);
120: scanningDialogOper.waitClosed();
121: }
122:
123: /**
124: * Open 10 selected files from jEdit project.
125: */
126: public void openFiles() {
127:
128: new org.netbeans.jemmy.EventTool().waitNoEvent(10000);
129:
130: String[] files_path = { "Web Pages|index.jsp",
131: "Source Packages|test|TestServlet.java" };
132:
133: Node root = new ProjectsTabOperator()
134: .getProjectRootNode("TestWebApp");
135: Node[] openFileNodes = new Node[files_path.length];
136:
137: for (int i = 0; i < files_path.length; i++) {
138:
139: openFileNodes[i] = new Node(root, files_path[i]);
140: // open file one by one, opening all files at once causes never ending loop (java+mdr)
141: //new OpenAction().performAPI(openFileNodes[i]);
142: }
143:
144: // try to come back and open all files at-once, rises another problem with refactoring, if you do open file and next expand folder,
145: // it doesn't finish in the real-time -> hard to reproduced by hand
146: new EditAction().performAPI(new Node(root,
147: "Web Pages|WEB-INF|web.xml"));
148: new org.netbeans.jemmy.EventTool().waitNoEvent(1000);
149: new OpenAction().performAPI(openFileNodes);
150:
151: new org.netbeans.jemmy.EventTool().waitNoEvent(60000);
152:
153: }
154:
155: public static void main(java.lang.String[] args) {
156: junit.textui.TestRunner.run(suite());
157: }
158: }
|