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.actions;
043:
044: import java.io.File;
045:
046: import javax.swing.tree.TreePath;
047:
048: import org.netbeans.jellytools.ProjectsTabOperator;
049: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
050: import org.netbeans.jellytools.nodes.Node;
051: import org.netbeans.jellytools.NbDialogOperator;
052:
053: import org.netbeans.junit.ide.ProjectSupport;
054:
055: import org.netbeans.jemmy.operators.JTreeOperator;
056: import org.netbeans.jemmy.operators.JPopupMenuOperator;
057: import org.netbeans.jemmy.EventTool;
058: import org.netbeans.jemmy.operators.ComponentOperator;
059: import org.netbeans.jemmy.operators.JListOperator;
060: import org.netbeans.jemmy.operators.JButtonOperator;
061: import org.netbeans.jemmy.operators.JComboBoxOperator;
062:
063: /**
064: * Measure UI-RESPONSIVENES and WINDOW_OPENING.
065: *
066: * @author rashid@netbeans.org
067: *
068: */
069: public class CreateClassDiagramFromMultipleNodes extends
070: org.netbeans.performance.test.utilities.PerformanceTestCase {
071:
072: private static String testProjectName = "jEdit-Model";
073: private static String testDiagramName = "AbbrevEditor";
074: private Node diag;
075: private NbDialogOperator create_diag;
076:
077: /** Creates a new instance of CreateClassDiagramFromMultipleNodes */
078: public CreateClassDiagramFromMultipleNodes(String testName) {
079: super (testName);
080: //TODO: Adjust expectedTime value
081: expectedTime = 5000;
082: WAIT_AFTER_OPEN = 4000;
083: }
084:
085: public CreateClassDiagramFromMultipleNodes(String testName,
086: String performanceDataName) {
087: super (testName, performanceDataName);
088: //TODO: Adjust expectedTime value
089: expectedTime = 5000;
090: WAIT_AFTER_OPEN = 4000;
091: }
092:
093: public void initialize() {
094: log(":: initialize");
095:
096: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
097: + File.separator + testProjectName);
098: // new CloseAllDocumentsAction().performAPI();
099:
100: }
101:
102: public void prepare() {
103: log(":: prepare");
104: Node pNode = new ProjectsTabOperator()
105: .getProjectRootNode(testProjectName);
106: diag = new Node(pNode, "Model" + "|" + "org" + "|" + "gjt"
107: + "|" + "sp" + "|" + "jedit" + "|" + "gui" + "|"
108: + testDiagramName);
109: diag.select();
110: new EventTool().waitNoEvent(1000);
111: JTreeOperator projectTree = new ProjectsTabOperator().tree();
112:
113: TreePath[] arrTreePath;
114: arrTreePath = new TreePath[40];
115: for (int i = 0; i < arrTreePath.length; i++) {
116: arrTreePath[i] = projectTree.getPathForRow(22 + i);
117: }
118: projectTree.callPopupOnPaths(arrTreePath);
119: JPopupMenuOperator selectMenu = new JPopupMenuOperator();
120: selectMenu.pushMenu("Create Diagram From Selected Elements");
121:
122: create_diag = new NbDialogOperator("Create New Diagram");
123: new EventTool().waitNoEvent(1000);
124: JListOperator diag_type = new JListOperator(create_diag, 1);
125: diag_type.selectItem("Class Diagram");
126: JComboBoxOperator spaceCombo = new JComboBoxOperator(
127: create_diag);
128: spaceCombo.selectItem("jEdit-Model");
129:
130: }
131:
132: public ComponentOperator open() {
133: log("::open");
134:
135: JButtonOperator finishButton = new JButtonOperator(create_diag,
136: "Finish");
137: finishButton.push();
138:
139: return null;
140: }
141:
142: protected void shutdown() {
143: log("::shutdown");
144: ProjectSupport.closeProject(testProjectName);
145: // new CloseAllDocumentsAction().performAPI();
146: }
147:
148: public void close() {
149: log("::close");
150: new CloseAllDocumentsAction().performAPI();
151:
152: }
153:
154: public static void main(java.lang.String[] args) {
155: junit.textui.TestRunner
156: .run(new CreateClassDiagramFromMultipleNodes(
157: "measureTime"));
158: }
159:
160: }
|