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.PaletteComponentOperator;
045: import gui.window.WebFormDesignerOperator;
046: import org.netbeans.jellytools.PaletteOperator;
047: import org.netbeans.jellytools.ProjectsTabOperator;
048: import org.netbeans.jellytools.TopComponentOperator;
049: import org.netbeans.jellytools.nodes.Node;
050: import org.netbeans.jellytools.properties.PropertySheetOperator;
051: import org.netbeans.jemmy.TimeoutExpiredException;
052:
053: import org.netbeans.jemmy.operators.ComponentOperator;
054:
055: import org.netbeans.junit.NbTestSuite;
056:
057: /**
058: *
059: * @author mkhramov@netbeans.org, mmirilovic@netbeans.org
060: */
061: public class ComponentAddTest extends
062: org.netbeans.performance.test.utilities.PerformanceTestCase {
063: private PaletteComponentOperator palette;
064: private WebFormDesignerOperator surface;
065: private String categoryName;
066: private String componentName;
067:
068: /**
069: * Creates a new instance of ComponentAddTest
070: *
071: * @param testName
072: *
073: */
074: public ComponentAddTest(String testName) {
075: super (testName);
076: expectedTime = WINDOW_OPEN;
077: WAIT_AFTER_OPEN = 4000;
078: }
079:
080: /**
081: * Creates a new instance of ComponentAddTest
082: *
083: * @param testName
084: * @param performanceDataName
085: *
086: */
087: public ComponentAddTest(String testName, String performanceDataName) {
088: super (testName, performanceDataName);
089: expectedTime = WINDOW_OPEN;
090: WAIT_AFTER_OPEN = 4000;
091: }
092:
093: public static NbTestSuite suite() {
094: NbTestSuite suite = new NbTestSuite();
095: suite.addTest(new ComponentAddTest("testAddTableComponent",
096: "Adding Table Component"));
097: suite.addTest(new ComponentAddTest("testAddButtonComponent",
098: "Adding Button Component"));
099: suite.addTest(new ComponentAddTest("testAddListboxComponent",
100: "Adding Listbox Component"));
101: return suite;
102: }
103:
104: public void testAddTableComponent() {
105: categoryName = "Woodstock Basic"; // NOI18N
106: componentName = "Table"; // NOI18N
107: doMeasurement();
108: }
109:
110: public void testAddButtonComponent() {
111: categoryName = "Woodstock Basic"; // NOI18N
112: componentName = "Button"; // NOI18N
113: doMeasurement();
114: }
115:
116: public void testAddListboxComponent() {
117: categoryName = "Woodstock Basic"; // NOI18N
118: componentName = "Listbox"; // NOI18N
119: doMeasurement();
120: }
121:
122: public void initialize() {
123: log("::initialize");
124:
125: Node projectRoot = null;
126: try {
127: projectRoot = new ProjectsTabOperator()
128: .getProjectRootNode("VisualWebProject");
129: projectRoot.select();
130:
131: } catch (org.netbeans.jemmy.TimeoutExpiredException ex) {
132: fail("Cannot find and select project root node");
133: }
134:
135: PaletteOperator.invoke();
136: }
137:
138: public void prepare() {
139: log("::prepare");
140: surface = gui.VWPUtilities.openedWebDesignerForJspFile(
141: "VisualWebProject", "Page1");
142: log("Surface is visible now: " + surface.isVisible());
143:
144: palette = new PaletteComponentOperator();
145: palette.getCategoryListOperator(categoryName).selectItem(
146: componentName);
147: }
148:
149: public ComponentOperator open() {
150: log("::open");
151: surface.clickOnSurface(20, 20);
152: return null;
153: }
154:
155: public void close() {
156: log("::close");
157: surface.closeDiscard();
158:
159: //new SaveAllAction().performAPI(); // Save
160: //new org.netbeans.jellytools.actions.CloseAllDocumentsAction().performAPI(); // Close;
161: log(":: close passed");
162: }
163:
164: protected void shutdown() {
165: log("::shutdown");
166: try {
167: //new TopComponentOperator(org.netbeans.jellytools.Bundle.getString("org.netbeans.modules.visualweb.ravehelp.dynamichelp.Bundle", "MSG_DynamicHelpTab_name")).close();
168: new PropertySheetOperator("Page1").close();
169: } catch (TimeoutExpiredException timeoutExpiredException) {
170: //do nothing...can be not opened properties and help tabs
171: }
172: }
173:
174: public static void main(java.lang.String[] args) {
175: junit.textui.TestRunner.run(suite());
176: }
177:
178: }
|