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.TopComponentOperator;
046:
047: import org.netbeans.jemmy.operators.ComponentOperator;
048: import org.netbeans.jemmy.operators.JPopupMenuOperator;
049:
050: /**
051: * Test of opening files, where CloneableEditor isn't super class of their editor.
052: *
053: * @author mmirilovic@netbeans.org
054: */
055: public class OpenFilesNoCloneableEditor extends OpenFiles {
056:
057: private String compName;
058:
059: /**
060: * Creates a new instance of OpenFilesNoCloneableEditor
061: * @param testName the name of the test
062: */
063: public OpenFilesNoCloneableEditor(String testName) {
064: super (testName);
065: }
066:
067: /**
068: * Creates a new instance of OpenFilesNoCloneableEditor
069: * @param testName the name of the test
070: * @param performanceDataName measured values will be saved under this name
071: */
072: public OpenFilesNoCloneableEditor(String testName,
073: String performanceDataName) {
074: super (testName, performanceDataName);
075: }
076:
077: public void testOpening20kBPropertiesFile() {
078: WAIT_AFTER_OPEN = 2500;
079: fileProject = "PerformanceTestData";
080: filePackage = "org.netbeans.test.performance";
081: fileName = "Bundle20kB.properties";
082: compName = "Bundle20kB.properties";
083: menuItem = OPEN;
084: doMeasurement();
085: }
086:
087: public void testOpening20kBPictureFile() {
088: WAIT_AFTER_OPEN = 2000;
089: fileProject = "PerformanceTestData";
090: filePackage = "org.netbeans.test.performance";
091: fileName = "splash.gif";
092: compName = "splash.gif";
093: menuItem = OPEN;
094: doMeasurement();
095: }
096:
097: @Override
098: protected void initialize() {
099: EditorOperator.closeDiscardAll();
100: }
101:
102: @Override
103: protected void shutdown() {
104: EditorOperator.closeDiscardAll();
105: }
106:
107: public ComponentOperator open() {
108: JPopupMenuOperator popup = this .openNode.callPopup();
109: if (popup == null) {
110: throw new Error("Cannot get context menu for node ["
111: + openNode.getPath() + "] in project ["
112: + fileProject + "]");
113: }
114: log("------------------------- after popup invocation ------------");
115:
116: try {
117: popup.pushMenu(this .menuItem);
118: } catch (org.netbeans.jemmy.TimeoutExpiredException tee) {
119: tee.printStackTrace(getLog());
120: throw new Error("Cannot push menu item [" + this .menuItem
121: + "] of node [" + openNode.getPath()
122: + "] in project [" + fileProject + "]");
123: }
124: log("------------------------- after open ------------");
125: return new TopComponentOperator(compName);
126: }
127:
128: public void close() {
129: /* if (testedComponentOperator != null) {
130: ((TopComponentOperator)testedComponentOperator).close();
131: }
132: else {
133: throw new Error ("no component to close");
134: }
135: */}
136: }
|