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 org.netbeans.jellytools.ProjectsTabOperator;
047: import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
048: import org.netbeans.jellytools.nodes.Node;
049: import org.netbeans.jellytools.TopComponentOperator;
050: import org.netbeans.jellytools.NbDialogOperator;
051:
052: import org.netbeans.jemmy.EventTool;
053: import org.netbeans.jemmy.operators.JButtonOperator;
054: import org.netbeans.jemmy.operators.JComboBoxOperator;
055: import org.netbeans.jemmy.operators.ComponentOperator;
056: import org.netbeans.jemmy.operators.JCheckBoxOperator;
057:
058: import org.netbeans.junit.ide.ProjectSupport;
059:
060: /**
061: * Measure UI-RESPONSIVENES and WINDOW_OPENING.
062: *
063: * @author rashid@netbeans.org
064: *
065: */
066: public class ApplyDesignPattern extends
067: org.netbeans.performance.test.utilities.PerformanceTestCase {
068:
069: private static String testProjectName = "jEdit-Model";
070: private Node diag;
071: private NbDialogOperator d_wizard;
072:
073: /** Creates a new instance of ApplyDesignPattern */
074: public ApplyDesignPattern(String testName) {
075: super (testName);
076: //TODO: Adjust expectedTime value
077: expectedTime = 5000;
078: WAIT_AFTER_OPEN = 4000;
079: }
080:
081: public ApplyDesignPattern(String testName,
082: String performanceDataName) {
083: super (testName, performanceDataName);
084: //TODO: Adjust expectedTime value
085: expectedTime = 5000;
086: WAIT_AFTER_OPEN = 4000;
087: }
088:
089: public void initialize() {
090: log(":: initialize");
091:
092: ProjectSupport.openProject(System.getProperty("xtest.tmpdir")
093: + File.separator + testProjectName);
094: // new CloseAllDocumentsAction().performAPI();
095:
096: }
097:
098: public void prepare() {
099: log(":: prepare");
100: Node pNode = new ProjectsTabOperator()
101: .getProjectRootNode(testProjectName);
102: diag = new Node(pNode, "Model");
103: diag.select();
104: diag.performPopupActionNoBlock("Apply Design Pattern");
105: NbDialogOperator a_wizard = new NbDialogOperator(
106: "Design Pattern Apply Wizard");
107: JButtonOperator a_wizard_next = new JButtonOperator(a_wizard,
108: "Next");
109: a_wizard_next.push();
110:
111: d_wizard = new NbDialogOperator("Design Pattern Wizard");
112: JButtonOperator d_wizard_next = new JButtonOperator(d_wizard,
113: "Next");
114: JComboBoxOperator projectCombo = new JComboBoxOperator(d_wizard);
115: projectCombo.selectItem("EJB2.0");
116:
117: d_wizard_next.push();
118: new EventTool().waitNoEvent(1000);
119: d_wizard_next.push();
120: new EventTool().waitNoEvent(1000);
121: d_wizard_next.push();
122: JCheckBoxOperator d_wizardCheck = new JCheckBoxOperator(
123: d_wizard, "Create class diagram");
124: d_wizardCheck.doClick();
125: d_wizard_next.push();
126: }
127:
128: public ComponentOperator open() {
129: log("::open");
130:
131: JButtonOperator d_wizard_finish = new JButtonOperator(d_wizard,
132: "Finish");
133: d_wizard_finish.push();
134:
135: return new TopComponentOperator("BeanManagedDiagram");
136:
137: }
138:
139: protected void shutdown() {
140: log("::shutdown");
141: ProjectSupport.closeProject(testProjectName);
142: }
143:
144: public void close() {
145: log("::close");
146: // new CloseAllDocumentsAction().performAPI();
147:
148: }
149:
150: public static void main(java.lang.String[] args) {
151: junit.textui.TestRunner.run(new ApplyDesignPattern(
152: "measureTime"));
153: }
154:
155: }
|