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:
042: package gui.javahelp;
043:
044: import java.io.PrintStream;
045: import java.io.PrintWriter;
046:
047: import org.netbeans.jellytools.JellyTestCase;
048: import org.netbeans.jellytools.HelpOperator;
049: import org.netbeans.jellytools.MainWindowOperator;
050: import org.netbeans.jellytools.NbDialogOperator;
051: import org.netbeans.jellytools.OptionsOperator;
052: import org.netbeans.jellytools.actions.HelpAction;
053:
054: import org.netbeans.jemmy.JemmyProperties;
055: import org.netbeans.jemmy.TestOut;
056: import org.netbeans.jemmy.operators.JMenuBarOperator;
057: import org.netbeans.jemmy.operators.JTreeOperator;
058:
059: import org.netbeans.junit.NbTestSuite;
060:
061: /**
062: * JellyTestCase test case with implemented Java Help Test support stuff
063: *
064: * @author mmirilovic@netbeans.org
065: */
066: public class JavaHelpDialogTest extends JellyTestCase {
067:
068: protected static PrintStream err;
069: protected static PrintStream log;
070:
071: private HelpOperator helpWindow;
072:
073: /** Creates a new instance of JavaHelpDialogTest */
074: public JavaHelpDialogTest(String testName) {
075: super (testName);
076: }
077:
078: public static NbTestSuite suite() {
079: NbTestSuite suite = new NbTestSuite();
080: suite.addTest(new JavaHelpDialogTest("testHelpF1"));
081: suite.addTest(new JavaHelpDialogTest("testHelpFromMenu"));
082: suite
083: .addTest(new JavaHelpDialogTest(
084: "testHelpByButtonNonModal"));
085: suite.addTest(new JavaHelpDialogTest("testHelpByButtonModal"));
086: suite.addTest(new JavaHelpDialogTest("testSearchInIndex"));
087: suite.addTest(new JavaHelpDialogTest("testContextualSearch"));
088: //suite.addTest(new JavaHelpDialogTest("testHelpByButtonNestedModal"));
089: return suite;
090: }
091:
092: public void setUp() {
093: //err = System.out;
094: err = getLog();
095: log = getRef();
096:
097: JemmyProperties.getProperties().setOutput(
098: new TestOut(null, new PrintWriter(err, true),
099: new PrintWriter(err, true), null));
100: }
101:
102: public void tearDown() {
103: closeAllModal();
104:
105: if (helpWindow != null && helpWindow.isVisible())
106: helpWindow.close();
107:
108: helpWindow = null;
109: }
110:
111: public void testHelpF1() {
112: MainWindowOperator.getDefault().pressKey(
113: java.awt.event.KeyEvent.VK_F1);
114: new org.netbeans.jemmy.EventTool().waitNoEvent(7000);
115: helpWindow = new HelpOperator();
116: }
117:
118: public void testHelpFromMenu() {
119: new HelpAction().performMenu();
120: helpWindow = new HelpOperator();
121: }
122:
123: public void testHelpCoreFromMenu() {
124: String helpMenu = org.netbeans.jellytools.Bundle
125: .getStringTrimmed("org.netbeans.core.Bundle",
126: "Menu/Help"); // Help
127: String helpSetsMenu = org.netbeans.jellytools.Bundle
128: .getStringTrimmed(
129: "org.netbeans.modules.javahelp.resources.Bundle",
130: "Menu/Help/HelpShortcuts"); // Help Sets
131: String coreIDEHelpMenu = org.netbeans.jellytools.Bundle
132: .getString("org.netbeans.modules.usersguide.Bundle",
133: "Actions/Help/org-netbeans-modules-usersguide-mainpage.xml"); // Core IDE Help
134:
135: MainWindowOperator.getDefault().menuBar().pushMenu(
136: helpMenu + "|" + helpSetsMenu + "|" + coreIDEHelpMenu,
137: "|");
138: helpWindow = new HelpOperator();
139: }
140:
141: public void testHelpByButtonNonModal() {
142: OptionsOperator.invoke(); //new JMenuBarOperator(MainWindowOperator.getDefault().getJMenuBar()).pushMenuNoBlock("Tools|Options","|"); // NOI18N
143: OptionsOperator options = new OptionsOperator();
144: options.help();
145: helpWindow = new HelpOperator();
146: options.close();
147: }
148:
149: public void testHelpByButtonModal() {
150: String toolsMenu = org.netbeans.jellytools.Bundle
151: .getStringTrimmed("org.netbeans.core.Bundle",
152: "Menu/Tools"); // Tools
153: //String setupWizardMenu = org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.actions.Bundle", "LBL_SetupWizard"); // Setup Wizard
154: String javaPlatformMenu = "Java Platform Manager";
155:
156: new JMenuBarOperator(MainWindowOperator.getDefault()
157: .getJMenuBar()).pushMenuNoBlock(toolsMenu + "|"
158: + javaPlatformMenu, "|");
159: //new NbDialogOperator(org.netbeans.jellytools.Bundle.getStringTrimmed("org.netbeans.core.ui.Bundle", "CTL_SetupWizardTitle")).help(); // Setup Wizard
160: new NbDialogOperator("Java Platform Manager").help(); // Java Platform Manager
161: helpWindow = new HelpOperator();
162: }
163:
164: public void testHelpByButtonNestedModal() {
165: //TBD
166: }
167:
168: public void testContextualSearch() {
169: new HelpAction().perform();
170: helpWindow = new HelpOperator();
171: helpWindow.selectPageSearch();
172: helpWindow.searchFind("compile");
173:
174: try {
175: Thread.sleep(5000);
176: } catch (Exception exc) {
177: exc.printStackTrace(err);
178: }
179:
180: JTreeOperator tree = helpWindow.treeSearch();
181: err.println("Selection path=" + tree.getSelectionPath());
182: err.println("Selection count=" + tree.getSelectionCount());
183:
184: if (tree.getSelectionCount() < 1)
185: fail("None founded text in the help, it isn't obvious");
186: }
187:
188: }
|