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-2006 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 junit.textui.TestRunner;
044: import org.netbeans.jellytools.nodes.Node;
045: import org.netbeans.jellytools.properties.PropertySheetOperator;
046: import org.netbeans.junit.NbTestSuite;
047:
048: /** Tests org.netbeans.jellytools.OptionsOperator. */
049: public class OptionsOperatorTest extends JellyTestCase {
050:
051: // "IDE Configuration"
052: private static final String ideConfLabel = Bundle.getString(
053: "org.netbeans.core.Bundle", "UI/Services/IDEConfiguration");
054: // "IDE Configuration|System|File Types|HTML and XHTML files"
055: private static final String path1 = ideConfLabel
056: + "|"
057: + Bundle.getString("org.netbeans.core.Bundle",
058: "UI/Services/IDEConfiguration/System")
059: + "|"
060: + Bundle.getString("org.netbeans.core.Bundle",
061: "Services/MIMEResolver")
062: + "|"
063: + Bundle.getString("org.netbeans.modules.html.Bundle",
064: "Services/MIMEResolver/html.xml");
065: // "IDE Configuration|System|Print Settings"
066: private static final String path2 = ideConfLabel
067: + "|"
068: + Bundle.getString("org.netbeans.core.Bundle",
069: "UI/Services/IDEConfiguration/System")
070: + "|"
071: + Bundle.getString("org.netbeans.core.Bundle",
072: "Services/org-openide-text-PrintSettings.settings");
073: // "IDE Configuration|Look and Feel|Toolbars"
074: private static final String path3 = ideConfLabel
075: + "|"
076: + Bundle.getString("org.netbeans.core.Bundle",
077: "UI/Services/IDEConfiguration/LookAndFeel") + "|"
078: + Bundle.getString("org.netbeans.core.Bundle", "Toolbars");
079:
080: /** Use for internal test execution inside IDE
081: * @param args command line arguments
082: */
083: public static void main(java.lang.String[] args) {
084: TestRunner.run(suite());
085: }
086:
087: /** Method used for explicit testsuite definition
088: * @return created suite
089: */
090: public static NbTestSuite suite() {
091: NbTestSuite suite = new NbTestSuite();
092: // test classic view
093: suite.addTest(new OptionsOperatorTest("testTreeTable"));
094: suite.addTest(new OptionsOperatorTest("testLevelsShowing"));
095: suite.addTest(new OptionsOperatorTest("testLevelChanging"));
096: suite.addTest(new OptionsOperatorTest("testPopup"));
097: suite.addTest(new OptionsOperatorTest("testGetPropertySheet"));
098: suite.addTest(new OptionsOperatorTest("testSelectOption"));
099: // test modern view
100: suite
101: .addTest(new OptionsOperatorTest(
102: "testSwitchToModernView"));
103: suite.addTest(new OptionsOperatorTest("testSelectEditor"));
104: suite
105: .addTest(new OptionsOperatorTest(
106: "testSelectFontAndColors"));
107: suite.addTest(new OptionsOperatorTest("testSelectKeymap"));
108: suite
109: .addTest(new OptionsOperatorTest(
110: "testSelectMiscellaneous"));
111: suite.addTest(new OptionsOperatorTest("testSelectGeneral"));
112: suite.addTest(new OptionsOperatorTest("testClose"));
113: return suite;
114: }
115:
116: /** Constructor required by JUnit.
117: * @param testName method name to be used as testcase
118: */
119: public OptionsOperatorTest(String testName) {
120: super (testName);
121: }
122:
123: private static OptionsOperator optionsOperator = null;
124:
125: /** Setup */
126: public void setUp() {
127: System.out.println("### " + getName() + " ###");
128: // opens Options window
129: if (optionsOperator == null) {
130: optionsOperator = OptionsOperator.invoke();
131: }
132: }
133:
134: /** Tear down. */
135: public void tearDown() {
136: }
137:
138: public void testTreeTable() {
139: optionsOperator.switchToClassicView();
140: optionsOperator.selectOption(path1);
141: optionsOperator.selectOption(path2);
142: optionsOperator.selectOption(path1);
143: optionsOperator.selectOption(path2);
144: }
145:
146: public void testLevelsShowing() {
147: optionsOperator.hideLevels();
148: optionsOperator.showLevels();
149: optionsOperator.hideLevels();
150: optionsOperator.showLevels();
151: }
152:
153: public void testLevelChanging() {
154: optionsOperator.setUserLevel(path1);
155: optionsOperator.setUserLevel(path2);
156: optionsOperator.setDefaultLevel(path1);
157: optionsOperator.setUserLevel(path1);
158: optionsOperator.setDefaultLevel(path2);
159: optionsOperator.setUserLevel(path2);
160: }
161:
162: public void testPopup() {
163: // "Refresh Folder"
164: String refreshFolderLabel = Bundle.getString(
165: "org.openide.loaders.Bundle", "LAB_Refresh");
166: new Node(optionsOperator.treeTable().tree(), path3)
167: .performPopupAction(refreshFolderLabel);
168: }
169:
170: /** Test getPropertySheet() method. */
171: public void testGetPropertySheet() {
172: PropertySheetOperator pso = optionsOperator
173: .getPropertySheet(path1);
174: }
175:
176: /** Test selectOption() method. */
177: public void testSelectOption() {
178: optionsOperator.selectOption(path1);
179: String nodeName = optionsOperator.treeTable().tree()
180: .getSelectionPath().getLastPathComponent().toString();
181: PropertySheetOperator pso = new PropertySheetOperator(
182: optionsOperator);
183: assertEquals("Wrong node was selected.", nodeName, pso
184: .getDescriptionHeader()); // NOI18N
185: }
186:
187: /** Test of switchToModernView method. */
188: public void testSwitchToModernView() {
189: optionsOperator.switchToModernView();
190: }
191:
192: /** Test of selectEditor method. */
193: public void testSelectEditor() {
194: optionsOperator.selectEditor();
195: }
196:
197: /** Test of selectFontAndColors method. */
198: public void testSelectFontAndColors() {
199: optionsOperator.selectFontAndColors();
200: }
201:
202: /** Test of selectKeymap method. */
203: public void testSelectKeymap() {
204: optionsOperator.selectKeymap();
205: }
206:
207: /** Test of selectMiscellaneous method. */
208: public void testSelectMiscellaneous() {
209: optionsOperator.selectMiscellaneous();
210: }
211:
212: /** Test of selectGeneral method. */
213: public void testSelectGeneral() {
214: optionsOperator.selectGeneral();
215: }
216:
217: /** Test of close method. */
218: public void testClose() {
219: optionsOperator.close();
220: }
221:
222: }
|