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 org.netbeans.jellytools.EditorOperator;
045: import org.netbeans.jellytools.ProjectsTabOperator;
046: import org.netbeans.jellytools.nodes.Node;
047:
048: import org.netbeans.jemmy.operators.ComponentOperator;
049: import org.netbeans.jemmy.operators.JPopupMenuOperator;
050:
051: /**
052: *
053: * @author mkhramov@netbeans.org, mmirilovic@netbeans.org
054: */
055: public class OpenBeanFiles extends
056: org.netbeans.performance.test.utilities.PerformanceTestCase {
057:
058: private String beanName;
059: private String beanFileName;
060: private String beanPath;
061: /** Node to be opened/edited */
062: public static Node openNode;
063:
064: protected static String OPEN = org.netbeans.jellytools.Bundle
065: .getStringTrimmed("org.openide.actions.Bundle", "Open");
066:
067: /** Creates a new instance of OpenBeanFiles */
068: public OpenBeanFiles(String testName) {
069: super (testName);
070: expectedTime = WINDOW_OPEN;
071: WAIT_AFTER_OPEN = 2000;
072: WAIT_AFTER_PREPARE = 3000;
073: }
074:
075: public OpenBeanFiles(String testName, String performanceDataName) {
076: super (testName, performanceDataName);
077: expectedTime = WINDOW_OPEN;
078: WAIT_AFTER_OPEN = 2000;
079: WAIT_AFTER_PREPARE = 3000;
080: }
081:
082: public void testApplicationBean() {
083: beanName = "ApplicationBean1.java"; //NOI18N
084: beanFileName = "ApplicationBean1.java";
085: setJavaEditorCaretFilteringOn();
086: doMeasurement();
087: }
088:
089: public void testRequestBean() {
090: beanName = "RequestBean1.java"; //NOI18N
091: beanFileName = "RequestBean1.java";
092: setJavaEditorCaretFilteringOn();
093: doMeasurement();
094: }
095:
096: public void testSessionBean() {
097: beanName = "SessionBean1.java"; //NOI18N
098: beanFileName = "SessionBean1.java";
099: setJavaEditorCaretFilteringOn();
100: doMeasurement();
101: }
102:
103: public void initialize() {
104: log("::initialize");
105: EditorOperator.closeDiscardAll();
106: repaintManager()
107: .addRegionFilter(repaintManager().EDITOR_FILTER);
108: }
109:
110: public void prepare() {
111: log("::prepare");
112: beanPath = "Source Packages" + "|" + "visualwebproject" + "|"
113: + beanName;
114: log("Bean Path = " + beanPath);
115: Node projectRoot = null;
116: try {
117: projectRoot = new ProjectsTabOperator()
118: .getProjectRootNode("VisualWebProject");
119: projectRoot.select();
120:
121: } catch (org.netbeans.jemmy.TimeoutExpiredException ex) {
122: fail("Cannot find and select project root node");
123: }
124:
125: try {
126: this .openNode = new Node(projectRoot, beanPath);
127: this .openNode.select();
128:
129: } catch (org.netbeans.jemmy.TimeoutExpiredException ex) {
130: fail("Cannot find and select bean node");
131: }
132:
133: if (this .openNode == null) {
134: throw new Error("Cannot find node " + beanPath);
135: }
136: log("========== Open file path =" + this .openNode.getPath());
137: }
138:
139: public ComponentOperator open() {
140: JPopupMenuOperator popup = this .openNode.callPopup();
141: if (popup == null) {
142: throw new Error("Cannot get context menu for node "
143: + beanPath);
144: }
145: log("------------------------- after popup invocation ------------");
146: try {
147: popup.pushMenu(OPEN);
148: } catch (org.netbeans.jemmy.TimeoutExpiredException tee) {
149: throw new Error("Cannot push menu item Open on node "
150: + beanPath);
151: }
152: log("------------------------- after open ------------");
153:
154: return new EditorOperator(beanFileName);
155: }
156:
157: public void close() {
158: log(":: close");
159: if (testedComponentOperator != null) {
160: ((EditorOperator) testedComponentOperator).close();
161: testedComponentOperator = null;
162: }
163:
164: }
165:
166: protected void shutdown() {
167: log(":: shutdown");
168: EditorOperator.closeDiscardAll();
169: repaintManager().resetRegionFilters();
170: }
171:
172: }
|