performance/test/qa-functional/src/org/netbeans/performance/uml/actions/CreateClassDiagramFromMultipleNodes.java
author Jesse Glick <jglick@netbeans.org>
Tue, 28 Jun 2011 16:36:36 -0400
changeset 38 7b6e218ca0af
permissions -rw-r--r--
Moved performance/uml out of main.
jglick@38
     1
/*
jglick@38
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jglick@38
     3
 *
jglick@38
     4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
jglick@38
     5
 *
jglick@38
     6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
jglick@38
     7
 * Other names may be trademarks of their respective owners.
jglick@38
     8
 *
jglick@38
     9
 * The contents of this file are subject to the terms of either the GNU
jglick@38
    10
 * General Public License Version 2 only ("GPL") or the Common
jglick@38
    11
 * Development and Distribution License("CDDL") (collectively, the
jglick@38
    12
 * "License"). You may not use this file except in compliance with the
jglick@38
    13
 * License. You can obtain a copy of the License at
jglick@38
    14
 * http://www.netbeans.org/cddl-gplv2.html
jglick@38
    15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jglick@38
    16
 * specific language governing permissions and limitations under the
jglick@38
    17
 * License.  When distributing the software, include this License Header
jglick@38
    18
 * Notice in each file and include the License file at
jglick@38
    19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
jglick@38
    20
 * particular file as subject to the "Classpath" exception as provided
jglick@38
    21
 * by Oracle in the GPL Version 2 section of the License file that
jglick@38
    22
 * accompanied this code. If applicable, add the following below the
jglick@38
    23
 * License Header, with the fields enclosed by brackets [] replaced by
jglick@38
    24
 * your own identifying information:
jglick@38
    25
 * "Portions Copyrighted [year] [name of copyright owner]"
jglick@38
    26
 *
jglick@38
    27
 * Contributor(s):
jglick@38
    28
 *
jglick@38
    29
 * The Original Software is NetBeans. The Initial Developer of the Original
jglick@38
    30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
jglick@38
    31
 * Microsystems, Inc. All Rights Reserved.
jglick@38
    32
 *
jglick@38
    33
 * If you wish your version of this file to be governed by only the CDDL
jglick@38
    34
 * or only the GPL Version 2, indicate your decision by adding
jglick@38
    35
 * "[Contributor] elects to include this software in this distribution
jglick@38
    36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
jglick@38
    37
 * single choice of license, a recipient has the option to distribute
jglick@38
    38
 * your version of this file under either the CDDL, the GPL Version 2 or
jglick@38
    39
 * to extend the choice of license to its licensees as provided above.
jglick@38
    40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
jglick@38
    41
 * Version 2 license, then the option applies only if the new code is
jglick@38
    42
 * made subject to such option by the copyright holder.
jglick@38
    43
 */
jglick@38
    44
package org.netbeans.performance.uml.actions;
jglick@38
    45
jglick@38
    46
import java.awt.event.InputEvent;
jglick@38
    47
jglick@38
    48
jglick@38
    49
import javax.swing.tree.TreePath;
jglick@38
    50
import org.netbeans.jellytools.ProjectsTabOperator;
jglick@38
    51
import org.netbeans.jellytools.actions.CloseAllDocumentsAction;
jglick@38
    52
import org.netbeans.jellytools.nodes.Node;
jglick@38
    53
import org.netbeans.jellytools.NbDialogOperator;
jglick@38
    54
jglick@38
    55
jglick@38
    56
jglick@38
    57
import org.netbeans.jemmy.operators.JTreeOperator;
jglick@38
    58
import org.netbeans.jemmy.operators.JPopupMenuOperator;
jglick@38
    59
import org.netbeans.jemmy.EventTool;
jglick@38
    60
import org.netbeans.jemmy.operators.ComponentOperator;
jglick@38
    61
import org.netbeans.jemmy.operators.JListOperator;
jglick@38
    62
import org.netbeans.jemmy.operators.JButtonOperator;
jglick@38
    63
import org.netbeans.jemmy.operators.JComboBoxOperator;
jglick@38
    64
import org.netbeans.modules.performance.utilities.CommonUtilities;
jglick@38
    65
import org.netbeans.modules.performance.utilities.PerformanceTestCase;
jglick@38
    66
import org.netbeans.modules.project.ui.test.ProjectSupport;
jglick@38
    67
jglick@38
    68
/**
jglick@38
    69
 * Measure UI-RESPONSIVENES and WINDOW_OPENING.
jglick@38
    70
 *
jglick@38
    71
 * @author rashid@netbeans.org
jglick@38
    72
 *
jglick@38
    73
 */
jglick@38
    74
public class CreateClassDiagramFromMultipleNodes extends PerformanceTestCase {
jglick@38
    75
jglick@38
    76
    private static String testProjectName = "jEdit-Model";
jglick@38
    77
    private NbDialogOperator create_diag;
jglick@38
    78
jglick@38
    79
    /** Creates a new instance of CreateClassDiagramFromMultipleNodes */
jglick@38
    80
    public CreateClassDiagramFromMultipleNodes(String testName) {
jglick@38
    81
        super(testName);
jglick@38
    82
        expectedTime = 5000;
jglick@38
    83
        WAIT_AFTER_OPEN = 4000;
jglick@38
    84
    }
jglick@38
    85
jglick@38
    86
    public CreateClassDiagramFromMultipleNodes(String testName, String performanceDataName) {
jglick@38
    87
        super(testName, performanceDataName);
jglick@38
    88
        expectedTime = 5000;
jglick@38
    89
        WAIT_AFTER_OPEN = 4000;
jglick@38
    90
    }
jglick@38
    91
jglick@38
    92
    @Override
jglick@38
    93
    public void initialize() {
jglick@38
    94
        log(":: initialize");
jglick@38
    95
        ProjectSupport.openProject(CommonUtilities.getProjectsDir() + testProjectName);
jglick@38
    96
    }
jglick@38
    97
jglick@38
    98
    public void prepare() {
jglick@38
    99
        log(":: prepare");
jglick@38
   100
jglick@38
   101
        Node pNode = new ProjectsTabOperator().getProjectRootNode(testProjectName);
jglick@38
   102
        Node diag1 = new Node(pNode, "Model|org|gjt|sp|jedit|gui|AbbrevEditor");
jglick@38
   103
        Node diag2 = new Node(pNode, "Model|org|gjt|sp|jedit|gui|IOProgressMonitor");
jglick@38
   104
        JTreeOperator projectTree = new ProjectsTabOperator().tree();
jglick@38
   105
jglick@38
   106
        TreePath path1 = diag1.getTreePath();
jglick@38
   107
        TreePath path2 = diag2.getTreePath();
jglick@38
   108
jglick@38
   109
        projectTree.clickOnPath(path1, 1, InputEvent.BUTTON1_MASK);
jglick@38
   110
        new EventTool().waitNoEvent(500);
jglick@38
   111
        projectTree.clickOnPath(path2, 1, InputEvent.BUTTON1_MASK, InputEvent.SHIFT_MASK);
jglick@38
   112
        new EventTool().waitNoEvent(2000);
jglick@38
   113
        projectTree.clickOnPath(path2, 1, InputEvent.BUTTON3_MASK);
jglick@38
   114
jglick@38
   115
        log(projectTree.getSelectionCount() + " elements selected");
jglick@38
   116
jglick@38
   117
        JPopupMenuOperator selectMenu = new JPopupMenuOperator();
jglick@38
   118
jglick@38
   119
        selectMenu.pushMenu("Create Diagram From Selected Elements");
jglick@38
   120
jglick@38
   121
        create_diag = new NbDialogOperator("Create New Diagram");
jglick@38
   122
        create_diag.move(0, 0);
jglick@38
   123
        new EventTool().waitNoEvent(1000);
jglick@38
   124
        JListOperator diag_type = new JListOperator(create_diag, 1);
jglick@38
   125
        diag_type.selectItem("Class Diagram");
jglick@38
   126
        JComboBoxOperator spaceCombo = new JComboBoxOperator(create_diag);
jglick@38
   127
        spaceCombo.selectItem("jEdit-Model");
jglick@38
   128
    }
jglick@38
   129
jglick@38
   130
    public ComponentOperator open() {
jglick@38
   131
        log("::open");
jglick@38
   132
jglick@38
   133
        JButtonOperator finishButton = new JButtonOperator(create_diag, "Finish");
jglick@38
   134
        finishButton.push();
jglick@38
   135
jglick@38
   136
        return null;
jglick@38
   137
    }
jglick@38
   138
jglick@38
   139
    @Override
jglick@38
   140
    protected void shutdown() {
jglick@38
   141
        log("::shutdown");
jglick@38
   142
        ProjectSupport.closeProject(testProjectName);
jglick@38
   143
    }
jglick@38
   144
jglick@38
   145
    @Override
jglick@38
   146
    public void close() {
jglick@38
   147
        log("::close");
jglick@38
   148
        new CloseAllDocumentsAction().performAPI();
jglick@38
   149
    }
jglick@38
   150
jglick@38
   151
//    public static void main(java.lang.String[] args) {
jglick@38
   152
//        junit.textui.TestRunner.run(new CreateClassDiagramFromMultipleNodes("measureTime"));
jglick@38
   153
//    }
jglick@38
   154
}