|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package gui.wizards;
import java.io.PrintStream;
import java.io.PrintWriter;
import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.JellyTestCase;
import org.netbeans.jellytools.OptionsOperator;
import org.netbeans.jellytools.SetupWizardOperator;
import org.netbeans.jellytools.TreeTableOperator;
import org.netbeans.jellytools.nodes.Node;
import org.netbeans.jellytools.properties.Property;
import org.netbeans.jellytools.properties.PropertySheetOperator;
import org.netbeans.jemmy.ComponentSearcher;
import org.netbeans.jemmy.EventTool;
import org.netbeans.jemmy.JemmyProperties;
import org.netbeans.jemmy.TestOut;
import org.netbeans.jemmy.operators.JCheckBoxOperator;
import org.netbeans.jemmy.operators.JComboBoxOperator;
import org.netbeans.jemmy.operators.JLabelOperator;
import org.netbeans.jemmy.operators.JTableOperator;
import org.netbeans.jemmy.operators.JTreeOperator;
import org.netbeans.junit.NbTestSuite;
/**
* This is the test suite for the Setup Wizard of NetBeans.
*
* @author juhrik@netbeans.org, mmirilovic@netbeans.org
*/
public class SetupWizardTest extends JellyTestCase {
// private static final String EMPTY_STRING = "";
// private static final String "|" = "|";
// private static final String EXCLAM_MARK = "!";
private static final String STR_TRUE = "True";
private static final String STR_FALSE = "False";
// private static final String PROXY_PORT = java.util.ResourceBundle.getBundle("gui/wizards/Bundle").getString("PORT");
// private static final String PROXY_HOST = java.util.ResourceBundle.getBundle("gui/wizards/Bundle").getString("HOST");
// private static final String HASH_STRING = java.util.ResourceBundle.getBundle("gui/wizards/Bundle").getString("Str_Hashes");
// private static final String WIZARD_FAIL = java.util.ResourceBundle.getBundle("gui/wizards/Bundle").getString("Wizard_Fail");
// private static final String ERROR_TITLE = Bundle.getString("org.openide.Bundle", "NTF_ErrorTitle");
protected static PrintStream err;
protected static PrintStream log;
private static final String CAPTION = "=========================== ";
private static SetupWizardOperator setupWizardOperator;
/** The Constructor - it is Called for Each of Test Methods.
*extends NbTestCase
*@param name the test method name - it must start with "test" prefix and the test method must exist
*/
public SetupWizardTest(String name) {
super(name);
}
/**Static method for Test suite. The tests are added to the suite.
*@return the test suite
*/
public static NbTestSuite suite() {
NbTestSuite suite = new NbTestSuite();
suite.addTest(new SetupWizardTest("testInvokeSetupWizard"));
suite.addTest(new SetupWizardTest("testProxyEnabling"));
suite.addTest(new SetupWizardTest("testProxyDisabling"));
suite.addTest(new SetupWizardTest("testProxySettings"));
suite.addTest(new SetupWizardTest("testSwitchToSDI"));
suite.addTest(new SetupWizardTest("testSwitchToMDI"));
// suite.addTest(new SetupWizardTest("testExternalWebBrowser"));
suite.addTest(new SetupWizardTest("testSwingHTMLBrowser"));
// suite.addTest(new SetupWizardTest("testExternalCommandLineWebBrowser"));
suite.addTest(new SetupWizardTest("testSecondPanelCheck"));
suite.addTest(new SetupWizardTest("testDescriptionsCheck"));
// suite.addTest(new SetupWizardTest("testDisableModule")); // TODO
// suite.addTest(new SetupWizardTest("testEnableModule")); // TODO
// suite.addTest(new SetupWizardTest("testDisableModuleBranch")); // TODO
// suite.addTest(new SetupWizardTest("testEnableModuleBranch")); // TODO
suite.addTest(new SetupWizardTest("testThirdPanelCheck"));
suite.addTest(new SetupWizardTest("testSetPeriodOfUCCheck"));
suite.addTest(new SetupWizardTest("testLastPanelSettings"));
return suite;
}
public void setUp() {
// err = System.out;
err = getLog();
log = getRef();
JemmyProperties.getProperties().setOutput(new TestOut(null, new PrintWriter(err, true), new PrintWriter(err, true), null));
new EventTool().waitNoEvent(1000);
System.out.println(CAPTION + getName());
/* if(!getName().equals("testInvokeSetupWizard")){
try{
setupWizardOperator = findSetupWizard();
} catch (Exception exc) {
failTest(exc, "It isn't possible invoke Setup Wizard, action causes EXCEPTION: "+exc.getMessage());
}
}
*/ }
public void tearDown() {
if(setupWizardOperator != null && setupWizardOperator.isShowing())
setupWizardOperator.cancel();
closeAllModal();
}
/**
* Invoke the Setup Wizard, calls SetupWizardOperator.invoke().
*/
public void testInvokeSetupWizard() {
try {
if(SetupWizardOperator.invoke()==null)
fail("Setup Wizard isn't opened after pushing Tools | Setup WIzard.");
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Test enables the proxy in opened Setup Wizard and checks that it is possible to change proxy port and name
*/
public void testProxyEnabling() {
try {
setupWizardOperator = findSetupWizard();
//Use HTTP Proxy Server, set proxy checkbox to true
setupWizardOperator.checkUseHTTPProxyServer(true);
boolean proxyServerNameEnabled = setupWizardOperator.txtProxyServerName().isEditable();
boolean proxyServerPortEnabled = setupWizardOperator.txtPort().isEditable();
if(!proxyServerNameEnabled || !proxyServerPortEnabled)
fail("Proxy Server Name("+(proxyServerPortEnabled?"enabled":"disabled")+") or Port("+(proxyServerPortEnabled?"enabled":"disabled")+") textfield is disabled, but it should be enabled.");
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Disables the proxy in opened Setup Wizard and checks that it is not possible to change proxy port and name
*/
public void testProxyDisabling() {
try {
setupWizardOperator = findSetupWizard();
//Use HTTP Proxy Server, set proxy checkbox to false
setupWizardOperator.checkUseHTTPProxyServer(false);
boolean proxyServerNameEnabled = setupWizardOperator.txtProxyServerName().isEditable();
boolean proxyServerPortEnabled = setupWizardOperator.txtPort().isEditable();
if(!proxyServerNameEnabled || !proxyServerPortEnabled)
fail("Proxy Server Name("+(proxyServerPortEnabled?"enabled":"disabled")+") or Port("+(proxyServerPortEnabled?"enabled":"disabled")+") textfield is enabled, but it should be disabled.");
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Tests to set the Proxy Port and Proxy Name to the correct value.
* Finally it finishes the Setup Wizard.
*/
public void testProxySettings() {
try {
setupWizardOperator = findSetupWizard();
//Use HTTP Proxy Server, set proxy checkbox to true
setupWizardOperator.checkUseHTTPProxyServer(true);
//Set Proxy Host, Port
setupWizardOperator.setProxyServerName("webcache.uk");
setupWizardOperator.setPort("8080");
//Finish the setup wizard
setupWizardOperator.finish();
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Opens Setup Wizard, finds it and switches to the SDI mode.
* Finally it finishes the Setup Wizard.
*/
public void testSwitchToSDI() {
try {
setupWizardOperator = findSetupWizard();
//Multiple Smaller Windows Mode ("SDI")
setupWizardOperator.separateWindowsMode();
new EventTool().waitNoEvent(1000);
boolean sdiRadioButtonIsSelected = setupWizardOperator.rbSeparateWindowsMode().isSelected();
boolean mdiRadioButtonIsSelected = setupWizardOperator.rbCompactWindowsMode().isSelected();
if(!sdiRadioButtonIsSelected || mdiRadioButtonIsSelected)
fail("SDI Mode ("+(sdiRadioButtonIsSelected?"selected":"unselected")+") or MDI Mode ("+(mdiRadioButtonIsSelected?"selected":"unselected")+").");
//Finish the setup wizard
setupWizardOperator.finish();
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Opens Setup Wizard, finds it and switches to the MDI mode.
* Finally it finishes the Setup Wizard.
*/
public void testSwitchToMDI() {
try {
setupWizardOperator = findSetupWizard();
//Full Screen Mode ("MDI")
setupWizardOperator.compactWindowsMode();
new EventTool().waitNoEvent(1000);
boolean sdiRadioButtonIsSelected = setupWizardOperator.rbSeparateWindowsMode().isSelected();
boolean mdiRadioButtonIsSelected = setupWizardOperator.rbCompactWindowsMode().isSelected();
if(sdiRadioButtonIsSelected || !mdiRadioButtonIsSelected)
fail("SDI Mode ("+(sdiRadioButtonIsSelected?"selected":"unselected")+") or MDI Mode ("+(mdiRadioButtonIsSelected?"selected":"unselected")+").");
//Finish the setup wizard
setupWizardOperator.finish();
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Opens Setup Wizard, finds it and selects the External Browser(Windows)
* Finally it finishes the Setup Wizard.
*/
public void testExternalWebBrowser() {
try {
setupWizardOperator = findSetupWizard();
String extBrowser;
if(System.getProperty("os.name").startsWith("Windows")){
//External Browser (Windows)
extBrowser = Bundle.getString("org.netbeans.modules.extbrowser.Bundle", "Services/Browsers/WinWebBrowser.settings");
}else{
//External Browser (Unix)
extBrowser = Bundle.getString("org.netbeans.modules.extbrowser.Bundle", "Services/Browsers/UnixWebBrowser.settings");
}
setupWizardOperator.selectWebBrowser(extBrowser);
new EventTool().waitNoEvent(500);
String comboString = (String)setupWizardOperator.cboWebBrowser().getSelectedItem();
if(!comboString.equals(extBrowser))
fail("Browser: [" + extBrowser + "] should be selected, but selected browser is ["+comboString+"]!");
//Finish the setup wizard
setupWizardOperator.finish();
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Opens Setup Wizard, finds it and selects the Swing HTML Browser
* Finally it finishes the Setup Wizard.
*/
public void testSwingHTMLBrowser() {
try {
setupWizardOperator = findSetupWizard();
//Swing HTML Browser
String swingBrowser = Bundle.getString("org.netbeans.core.ui.Bundle", "Services/Browsers/SwingBrowser.ser");
setupWizardOperator.selectWebBrowser(swingBrowser);
new EventTool().waitNoEvent(500);
String comboString = (String)setupWizardOperator.cboWebBrowser().getSelectedItem();
if(!comboString.equals(swingBrowser))
fail("Browser: [" + swingBrowser + "] should be selected, but selected browser is ["+comboString+"]!");
//Finish the setup wizard
setupWizardOperator.finish();
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Opens Setup Wizard, finds it and selects the External Browser(Command Line)
* Finally it finishes the Setup Wizard.
*/
public void testExternalCommandLineWebBrowser() {
try {
setupWizardOperator = findSetupWizard();
//External Browser (Command Line)
String extCmdLine = Bundle.getString("org.netbeans.modules.extbrowser.Bundle", "Services/Browsers/SimpleExtBrowser.settings");
setupWizardOperator.selectWebBrowser(extCmdLine);
new EventTool().waitNoEvent(500);
String comboString = (String)setupWizardOperator.cboWebBrowser().getSelectedItem();
if(!comboString.equals(extCmdLine))
fail("Browser: [" + extCmdLine + "] should be selected, but selected browser is ["+comboString+"]!");
//Finish the setup wizard
setupWizardOperator.finish();
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Opens Setup Wizard, finds it and presses the Next button.
* Then the test checks whether the step of the wizard is correct(2nd step must be set).
*/
public void testSecondPanelCheck() {
try {
setupWizardOperator = findSetupWizard();
//General NetBeans Settings
checkStepLabel(Bundle.getString("org.netbeans.core.ui.Bundle", "LBL_IDEPanelName"));
//Press Next button
setupWizardOperator.next();
new EventTool().waitNoEvent(3000);
//Module Installation
checkStepLabel(Bundle.getString("org.netbeans.core.ui.Bundle", "LBL_SetupWizardModuleInstallation"));
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Test first collapses all nodes in the tree of the second panel.
* Then the tree is fully expanded, all nodes are selected to False
* Tree is again fully collapsed and all groups of modules are selectsed (set to True)
*/
public void testDescriptionsCheck() {
try {
setupWizardOperator = findSetupWizard();
//Press Next button
setupWizardOperator.next();
JTreeOperator treeOperator = new TreeTableOperator((javax.swing.JTable) new JTableOperator(setupWizardOperator).getSource()).tree();
expandWholeTree(treeOperator, true);
expandWholeTree(treeOperator, false);
setTreeSelected(STR_FALSE);
setTreeSelected(STR_TRUE);
setupWizardOperator.cancel();
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Finds out the module group that contains more than 2 modules and sets the 2nd module of the group disabled
*/
public void testDisableModule() {
try {
setupWizardOperator = findSetupWizard();
//Press Next button
setupWizardOperator.next();
// collapse tree
JTableOperator tableOperator = new JTableOperator(setupWizardOperator);
JTreeOperator treeOperator = new TreeTableOperator((javax.swing.JTable) tableOperator.getSource()).tree();
expandWholeTree(treeOperator, false);
String[] nodesNames = getNodesNames(tableOperator);
for(int i = 1; i < nodesNames.length; i++){
Node n = new Node(treeOperator, nodesNames[i]);
if(n.getChildren().length > 2){
n.expand();
setModuleSelected(tableOperator, n.getChildren()[1], STR_FALSE);
n.collapse();
break;
}
n.collapse();
}
} catch (Exception exc) {
failTest(exc, "Test fails and causes EXCEPTION: "+exc.getMessage());
}
}
/**
* Finds out the module group that contains more than 2 modules and sets the 2nd module of the group enabled.
* It tests that the module is selected as well.
*/
public void testEnableModule() {
try {
setupWizardOperator = findSetupWizard();
//Press Next button
setupWizardOperator.next();
JTableOperator tableOperator = new JTableOperator(setupWizardOperator);
// JTreeOperator treeOperator = new TreeTableOperator((javax.swing.JTable) tableOperator.getSource()).tree();
String[] nodesNames = getNodesNames(tableOperator);
for(int i = 1; i
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.