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.action;
043:
044: import gui.window.WebFormDesignerOperator;
045:
046: import org.netbeans.jellytools.EditorOperator;
047: import org.netbeans.jellytools.ProjectsTabOperator;
048: import org.netbeans.jellytools.nodes.Node;
049: import org.netbeans.jemmy.TimeoutExpiredException;
050:
051: import org.netbeans.jemmy.operators.ComponentOperator;
052: import org.netbeans.jemmy.operators.JDialogOperator;
053: import org.netbeans.jemmy.operators.JPopupMenuOperator;
054:
055: /**
056: *
057: * @author mkhramov@netbeans.org, mmirilovic@netbeans.org
058: */
059:
060: public class OpenProjectFirstPage extends
061: org.netbeans.performance.test.utilities.PerformanceTestCase {
062:
063: private Node openNode;
064: private String targetProject;
065: private ProjectsTabOperator pto;
066:
067: protected static String OPEN = org.netbeans.jellytools.Bundle
068: .getStringTrimmed("org.openide.actions.Bundle", "Open");
069:
070: /** Creates a new instance of OpenProjectFirstPage */
071: public OpenProjectFirstPage(String testName) {
072: super (testName);
073: expectedTime = 10000;
074: WAIT_AFTER_OPEN = 20000;
075: }
076:
077: /** Creates a new instance of OpenProjectFirstPage */
078: public OpenProjectFirstPage(String testName,
079: String performanceDataName) {
080: super (testName, performanceDataName);
081: expectedTime = 10000;
082: WAIT_AFTER_OPEN = 20000;
083: }
084:
085: public void testOpenSmallProjectFirstPage() {
086: targetProject = "VisualWebProject";
087: doMeasurement();
088: }
089:
090: public void testOpenLargeProjectFirstPage() {
091: targetProject = "HugeApp";
092: doMeasurement();
093: }
094:
095: @Override
096: public void initialize() {
097: log("::initialize::");
098: EditorOperator.closeDiscardAll();
099: pto = ProjectsTabOperator.invoke();
100: //Workaround for "Update data sources" dialog
101: try {
102: new JDialogOperator(
103: org.netbeans.jellytools.Bundle
104: .getString(
105: "org.netbeans.modules.visualweb.dataconnectivity.utils.Bundle",
106: "MSG_Update_Datasources_Title"))
107: .close();
108: } catch (TimeoutExpiredException tex) {
109: // Do nothing
110: log(tex.toString());
111: }
112: }
113:
114: public void prepare() {
115: log("::prepare");
116: long nodeTimeout = pto.getTimeouts().getTimeout(
117: "ComponentOperator.WaitStateTimeout");
118: pto.getTimeouts().setTimeout(
119: "ComponentOperator.WaitStateTimeout", 60000);
120: try {
121: openNode = new Node(pto.getProjectRootNode(targetProject),
122: gui.VWPUtilities.WEB_PAGES + "|" + "Page1.jsp");
123: } catch (TimeoutExpiredException tex) {
124: pto.getTimeouts().setTimeout(
125: "ComponentOperator.WaitStateTimeout", nodeTimeout);
126: throw new Error(
127: "Cannot find expected node because of Timeout");
128: }
129: pto.getTimeouts().setTimeout(
130: "ComponentOperator.WaitStateTimeout", nodeTimeout);
131:
132: if (this .openNode == null) {
133: throw new Error("Cannot find expected node");
134: }
135: openNode.select();
136: }
137:
138: public ComponentOperator open() {
139: log("::open");
140: JPopupMenuOperator popup = this .openNode.callPopup();
141: if (popup == null) {
142: throw new Error("Cannot get context menu for node ");
143: }
144: log("------------------------- after popup invocation ------------");
145: popup.getTimeouts().setTimeout("JMenuOperator.PushMenuTimeout",
146: 90000);
147: try {
148: popup.pushMenu(OPEN);
149: } catch (org.netbeans.jemmy.TimeoutExpiredException tee) {
150: throw new Error("Cannot push menu item ");
151: }
152:
153: return WebFormDesignerOperator
154: .findWebFormDesignerOperator("Page1");
155: }
156:
157: @Override
158: public void close() {
159: log("::close");
160: if (testedComponentOperator != null) {
161: ((WebFormDesignerOperator) testedComponentOperator).close();
162: testedComponentOperator = null;
163: }
164: }
165:
166: @Override
167: protected void shutdown() {
168: log("::shutdown");
169: }
170:
171: public static void main(java.lang.String[] args) {
172: junit.textui.TestRunner.run(new OpenProjectFirstPage(
173: "testOpenLargeProjectFirstPage"));
174: }
175: }
|