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: package org.netbeans.jellytools;
042:
043: import org.netbeans.jemmy.JemmyProperties;
044: import org.netbeans.jemmy.operators.JFileChooserOperator;
045: import org.netbeans.junit.NbTest;
046: import org.netbeans.junit.NbTestSuite;
047:
048: /** Test PluginsOperator.
049: *
050: * @author Jiri.Skrivanek@sun.com
051: */
052: public class PluginsOperatorTest extends JellyTestCase {
053:
054: /** Creates test case with given name.
055: * @param testName name of test case
056: */
057: public PluginsOperatorTest(String testName) {
058: super (testName);
059: }
060:
061: /** Used for internal run in IDE.
062: * @param args not used here
063: */
064: public static void main(java.lang.String[] args) {
065: junit.textui.TestRunner.run(suite());
066: }
067:
068: /** Define test suite.
069: * @return suite.
070: */
071: public static NbTest suite() {
072: NbTestSuite suite = new NbTestSuite();
073: // test cases have to be in particular order
074: suite.addTest(new PluginsOperatorTest("testInvoke"));
075: suite.addTest(new PluginsOperatorTest("testInstall"));
076: suite.addTest(new PluginsOperatorTest("testUninstall"));
077: suite.addTest(new PluginsOperatorTest("testDeactivate"));
078: suite.addTest(new PluginsOperatorTest("testSettings"));
079: suite.addTest(new PluginsOperatorTest("testDowloaded"));
080: suite.addTest(new PluginsOperatorTest("testClose"));
081: return suite;
082: }
083:
084: /** Print out test name. */
085: @Override
086: public void setUp() throws Exception {
087: System.out.println("### " + getName() + " ###");
088: }
089:
090: private static PluginsOperator pluginsOper;
091: private static final String SOURCE_BROWSER_LABEL = "netbeans.org Source Browser"; //NOI18N
092:
093: /** Test of invoke method. */
094: public void testInvoke() {
095: pluginsOper = PluginsOperator.invoke();
096: }
097:
098: /** Test install() method.
099: * - select Available Plugins tab
100: * - type "netbeans.org Source Browser" into Search text field
101: * - finish installation
102: */
103: public void testInstall() {
104: pluginsOper.selectAvailablePlugins();
105: pluginsOper.search(SOURCE_BROWSER_LABEL);
106: pluginsOper.install(SOURCE_BROWSER_LABEL);
107: }
108:
109: /** Test uninstallation
110: * - select Installed tab
111: * - select Java and "netbeans.org Source Browser" plugins
112: * - click Uninstall button
113: * - wait for "NetBeans IDE Installer" dialog
114: * - click Cancel
115: */
116: public void testUninstall() {
117: pluginsOper.selectInstalled();
118: pluginsOper.selectPlugins(new String[] { "Java",
119: SOURCE_BROWSER_LABEL });
120: pluginsOper.uninstall();
121: pluginsOper.installer().cancel();
122: }
123:
124: /** Test deactivation
125: * - select Installed tab
126: * - select "netbeans.org Source Browser" plugin
127: * - click Deactivate button
128: * - wait for "NetBeans IDE Installer" dialog
129: * - click Cancel
130: */
131: public void testDeactivate() {
132: pluginsOper.selectInstalled();
133: pluginsOper.selectPlugin(SOURCE_BROWSER_LABEL);
134: pluginsOper.deactivate();
135: pluginsOper.installer().cancel();
136: }
137:
138: /** Test settings
139: * - select Settings tab
140: */
141: public void testSettings() {
142: pluginsOper.selectSettings();
143: }
144:
145: /** Test Downloaded tab
146: * - select Downloaded tab
147: * - wait for file chooser
148: * - close file chooser
149: */
150: public void testDowloaded() {
151: pluginsOper.addPlugins();
152: new JFileChooserOperator().cancel();
153: }
154:
155: /** Close Plugins dialog. */
156: public void testClose() {
157: pluginsOper.close();
158: }
159: }
|