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 MeasureNB40StartupTimeWithWeb extends JellyTestCase {
068:
069: /** Error output from the test. */
070: protected static PrintStream err;
071:
072: /** Logging output from the test. */
073: protected static PrintStream log;
074:
075: /** Define testcase
076: * @param testName name of the testcase
077: */
078: public MeasureNB40StartupTimeWithWeb(String testName) {
079: super (testName);
080: }
081:
082: /** Testsuite
083: * @return testuite
084: */
085: public static Test suite() {
086: TestSuite suite = new NbTestSuite();
087: suite.addTest(new IDESetupTest("testCloseMemoryToolbar"));
088: suite.addTest(new IDESetupTest("testCloseWelcome"));
089: suite.addTest(new MeasureNB40StartupTimeWithWeb(
090: "testOpenProjects"));
091: suite.addTest(new MeasureNB40StartupTimeWithWeb("openFiles"));
092: return suite;
093: }
094:
095: public void setUp() {
096: // err = System.out;
097: err = getLog();
098: log = getRef();
099: }
100:
101: public void testOpenProjects() {
102: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
103: + "/startup_nb40/TestStartupWeb1");
104: ProjectSupport.waitScanFinished();
105: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
106: + "/startup_nb40/TestStartupWeb2");
107: ProjectSupport.waitScanFinished();
108: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
109: + "/startup_nb40/TestStartupWeb3");
110: ProjectSupport.waitScanFinished();
111: waitForScan();
112: }
113:
114: private void waitForScan() {
115: // "Scanning Project Classpaths"
116: String titleScanning = Bundle.getString(
117: "org.netbeans.modules.javacore.Bundle",
118: "TXT_ApplyingPathsTitle");
119: NbDialogOperator scanningDialogOper = new NbDialogOperator(
120: titleScanning);
121: // scanning can last for a long time => wait max. 5 minutes
122: scanningDialogOper.getTimeouts().setTimeout(
123: "ComponentOperator.WaitStateTimeout", 300000);
124: scanningDialogOper.waitClosed();
125: }
126:
127: /**
128: * Open 10 selected files from jEdit project.
129: */
130: public void openFiles() {
131:
132: new org.netbeans.jemmy.EventTool().waitNoEvent(10000);
133:
134: String[][] files_path = {
135: { "TestStartupWeb1", "Web Pages|index.jsp" },
136: { "TestStartupWeb2", "Web Pages|index.jsp" },
137: { "TestStartupWeb3", "Web Pages|index.jsp" }, };
138:
139: Node[] openFileNodes = new Node[files_path.length];
140:
141: for (int i = 0; i < files_path.length; i++) {
142: Node root = new ProjectsTabOperator()
143: .getProjectRootNode(files_path[i][0]);
144: root.setComparator(new Operator.DefaultStringComparator(
145: true, true));
146: openFileNodes[i] = new Node(root, files_path[i][1]);
147: // open file one by one, opening all files at once causes never ending loop (java+mdr)
148: //new OpenAction().performAPI(openFileNodes[i]);
149: }
150:
151: // try to come back and open all files at-once, rises another problem with refactoring, if you do open file and next expand folder,
152: // it doesn't finish in the real-time -> hard to reproduced by hand
153: new OpenAction().performAPI(openFileNodes);
154:
155: new org.netbeans.jemmy.EventTool().waitNoEvent(60000);
156:
157: }
158:
159: public static void main(java.lang.String[] args) {
160: junit.textui.TestRunner.run(suite());
161: }
162: }
|