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 prepare;
043:
044: import org.netbeans.jellytools.EditorOperator;
045: import org.netbeans.jellytools.ProjectsTabOperator;
046:
047: import org.netbeans.jellytools.actions.OpenAction;
048: import org.netbeans.jellytools.nodes.Node;
049: import org.netbeans.jellytools.nodes.ProjectRootNode;
050: import org.netbeans.jellytools.nodes.SourcePackagesNode;
051:
052: import org.netbeans.jemmy.operators.Operator;
053:
054: import org.netbeans.junit.NbTestSuite;
055:
056: import junit.framework.Test;
057: import junit.framework.TestSuite;
058:
059: /**
060: * Prepare user directory for complex measurements (startup time and memory consumption) of IDE with opened NB plug-in.
061: * Open 3 java files and shut down ide.
062: * Created user directory will be used to measure startup time and memory consumption of IDE with opened files.
063: *
064: * @author Marian.Mirilovic@sun.com
065: */
066: public class PrepareIDEForPluginComplexMeasurements extends
067: PrepareIDEForComplexMeasurements {
068:
069: /** Define testcase
070: * @param testName name of the testcase
071: */
072: public PrepareIDEForPluginComplexMeasurements(String testName) {
073: super (testName);
074: }
075:
076: /** Testsuite
077: * @return testuite
078: */
079: public static Test suite() {
080: TestSuite suite = new NbTestSuite();
081: suite.addTest(new PrepareIDEForComplexMeasurements(
082: "closeWelcome"));
083: suite.addTest(new PrepareIDEForComplexMeasurements(
084: "closeAllDocuments"));
085: suite.addTest(new PrepareIDEForComplexMeasurements(
086: "closeMemoryToolbar"));
087: suite.addTest(new PrepareIDEForPluginComplexMeasurements(
088: "openFiles"));
089: suite
090: .addTest(new PrepareIDEForComplexMeasurements(
091: "saveStatus"));
092: return suite;
093: }
094:
095: /**
096: * Open 3 selected files from jEdit project.
097: */
098: public void openFiles() {
099:
100: try {
101: String[][] files_path = {
102: { "org.myorg.systemproperties",
103: "AllPropsChildren.java" },
104: { "org.myorg.systemproperties", "AllPropsNode.java" },
105: { "org.myorg.systemproperties", "OnePropNode.java" },
106: { "org.myorg.systemproperties",
107: "PropertiesNotifier.java" },
108: { "org.myorg.systemproperties",
109: "RefreshPropsAction.java" } };
110:
111: Node[] openFileNodes = new Node[files_path.length];
112: Node node;
113:
114: // try to workarround problems with tooltip on Win2K & WinXP - issue 56825
115: ProjectRootNode projectNode = new ProjectsTabOperator()
116: .getProjectRootNode("SystemProperties");
117: projectNode.expand();
118:
119: SourcePackagesNode sourceNode = new SourcePackagesNode(
120: projectNode);
121: sourceNode.expand();
122:
123: // create exactly (full match) and case sensitively comparing comparator
124: Operator.DefaultStringComparator comparator = new Operator.DefaultStringComparator(
125: true, true);
126: sourceNode.setComparator(comparator);
127:
128: for (int i = 0; i < files_path.length; i++) {
129: node = new Node(sourceNode, files_path[i][0]);
130: node.expand();
131:
132: openFileNodes[i] = new Node(node, files_path[i][1]);
133:
134: //try to avoid issue 56825
135: openFileNodes[i].select();
136:
137: // open file one by one, opening all files at once causes never ending loop (java+mdr)
138: //new OpenAction().performAPI(openFileNodes[i]);
139: }
140:
141: // try to come back and open all files at-once, rises another problem with refactoring, if you do open file and next expand folder,
142: // it doesn't finish in the real-time -> hard to reproduced by hand
143: try {
144: new OpenAction().performAPI(openFileNodes);
145: } catch (Exception exc) {
146: err.println("---------------------------------------");
147: err
148: .println("issue 56825 : EXCEPTION catched during OpenAction");
149: exc.printStackTrace(err);
150: err.println("---------------------------------------");
151: err.println("issue 56825 : Try it again");
152: new OpenAction().performAPI(openFileNodes);
153: err.println("issue 56825 : Success");
154: }
155:
156: // check whether files are opened in editor
157: for (int i = 0; i < files_path.length; i++) {
158: new EditorOperator(files_path[i][1]);
159: }
160: // new org.netbeans.jemmy.EventTool().waitNoEvent(60000);
161:
162: } catch (Exception exc) {
163: test_failed = true;
164: fail(exc);
165: }
166: }
167:
168: }
|