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 gui.actions;
043:
044: import gui.MPUtilities;
045: import gui.window.MIDletEditorOperator;
046: import org.netbeans.jellytools.ProjectsTabOperator;
047: import org.netbeans.jellytools.nodes.Node;
048: import org.netbeans.jemmy.operators.ComponentOperator;
049: import org.netbeans.jemmy.operators.JPopupMenuOperator;
050: import org.netbeans.performance.test.guitracker.ActionTracker;
051:
052: /**
053: *
054: * @author mkhramov@netbeans.org
055: */
056: public class MIDletViewsSwitch extends
057: org.netbeans.performance.test.utilities.PerformanceTestCase {
058:
059: public String fromView;
060: public String toView;
061:
062: private String targetProject;
063: private String midletName;
064: private Node openNode;
065: protected static String OPEN = org.netbeans.jellytools.Bundle
066: .getStringTrimmed("org.openide.actions.Bundle", "Open");
067:
068: private MIDletEditorOperator targetMIDletEditor;
069: private static ActionTracker tr;
070:
071: public MIDletViewsSwitch(String testName) {
072: super (testName);
073: expectedTime = WINDOW_OPEN;
074: WAIT_AFTER_PREPARE = 10000;
075: WAIT_AFTER_CLOSE = 5000;
076: }
077:
078: public MIDletViewsSwitch(String testName, String performanceDataName) {
079: super (testName, performanceDataName);
080: expectedTime = WINDOW_OPEN;
081: WAIT_AFTER_PREPARE = 10000;
082: WAIT_AFTER_CLOSE = 5000;
083: }
084:
085: public void initialize() {
086: log(":: initialize");
087: tr = ActionTracker.getInstance();
088: targetProject = "MobileApplicationVisualMIDlet";
089: midletName = "VisualMIDletMIDP20.java";
090:
091: String documentPath = MPUtilities.SOURCE_PACKAGES + "|"
092: + "allComponents" + "|" + midletName;
093: openNode = new Node(new ProjectsTabOperator()
094: .getProjectRootNode(targetProject), documentPath);
095:
096: if (this .openNode == null) {
097: throw new Error("Cannot find expected node ");
098: }
099: openNode.select();
100:
101: JPopupMenuOperator popup = this .openNode.callPopup();
102: if (popup == null) {
103: throw new Error("Cannot get context menu for node ");
104: }
105: log("------------------------- after popup invocation ------------");
106: popup.getTimeouts().setTimeout("JMenuOperator.PushMenuTimeout",
107: 90000);
108: try {
109: popup.pushMenu(OPEN);
110: } catch (org.netbeans.jemmy.TimeoutExpiredException tee) {
111: throw new Error("Cannot push menu item ");
112: }
113: targetMIDletEditor = MIDletEditorOperator
114: .findMIDletEditorOperator(midletName);
115: }
116:
117: public void prepare() {
118: log(":: prepare");
119: tr.add(ActionTracker.TRACK_TRACE_MESSAGE, "TEST:PREPARE");
120: targetMIDletEditor.switchToViewByName(fromView);
121:
122: }
123:
124: public ComponentOperator open() {
125: log(":: open");
126: tr.add(ActionTracker.TRACK_TRACE_MESSAGE, "TEST:OPEN");
127: targetMIDletEditor.switchToViewByName(toView);
128: return null;
129: }
130:
131: public void close() {
132: log(":: close");
133: tr.add(ActionTracker.TRACK_TRACE_MESSAGE, "TEST:CLOSE");
134: }
135:
136: public void shutdown() {
137: log(":: shutdown");
138: targetMIDletEditor.closeDiscard();
139: }
140:
141: public void testFlowToDesignSwitch() {
142: fromView = "Flow";
143: toView = "Screen";
144: setJavaEditorCaretFilteringOn();
145: doMeasurement();
146: }
147:
148: public void testDesignToFlowSwitch() {
149: fromView = "Screen";
150: toView = "Flow";
151: setJavaEditorCaretFilteringOn();
152: doMeasurement();
153: }
154:
155: public void testFlowToSourceSwitch() {
156: fromView = "Flow";
157: toView = "Source";
158: setJavaEditorCaretFilteringOn();
159: doMeasurement();
160: }
161:
162: public void testSourceToFlowSwitch() {
163: fromView = "Source";
164: toView = "Flow";
165: setJavaEditorCaretFilteringOn();
166: doMeasurement();
167:
168: }
169: }
|