/* * 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-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package complete.common; import org.netbeans.jellytools.*; import org.netbeans.jellytools.nodes.Node; import org.netbeans.jellytools.actions.*; import org.netbeans.jellytools.modules.vcscore.VCSCommandsOutputOperator; import org.netbeans.jellytools.modules.vcsgeneric.VCSCommandOperator; import org.netbeans.jellytools.modules.vcsgeneric.wizard.*; import org.netbeans.jellytools.properties.*; import org.netbeans.jemmy.operators.*; /** XTest / JUnit test class performing check of Command editor. * @author Jiri Kovalsky * @version 1.0 */ public class Commands extends org.netbeans.junit.NbTestCase { public static String MOUNT_MENU = "Versioning|Mount Version Control|Generic VCS"; /** Constructor required by JUnit. * @param testName Method name to be used as testcase. */ public Commands(String testName) { super(testName); } /** Method used for explicit test suite definition. * @return Commands test suite. */ public static junit.framework.Test suite() { junit.framework.TestSuite suite = new org.netbeans.junit.NbTestSuite(); suite.addTest(new Commands("testCommandEditor")); suite.addTest(new Commands("testPopupSubmenu")); suite.addTest(new Commands("testPopupDevider")); suite.addTest(new Commands("testPopupAction")); suite.addTest(new Commands("testCustomizeMenu")); suite.addTest(new Commands("testSetupCommand")); suite.addTest(new Commands("testInvokeCommand")); suite.addTest(new Commands("testConfirmationMessages")); return suite; } /** Use for internal test execution inside IDE. * @param args Command line arguments. */ public static void main(java.lang.String[] args) { junit.textui.TestRunner.run(suite()); } /** Method called before each testcase. Sets default timeouts, redirects system * output and maps main components. */ protected void setUp() throws Exception { String workingDir = getWorkDirPath(); new java.io.File(workingDir).mkdirs(); java.io.File outputFile = new java.io.File(workingDir + "/output.txt"); outputFile.createNewFile(); java.io.File errorFile = new java.io.File(workingDir + "/error.txt"); errorFile.createNewFile(); java.io.PrintWriter outputWriter = new java.io.PrintWriter(new java.io.FileWriter(outputFile)); java.io.PrintWriter errorWriter = new java.io.PrintWriter(new java.io.FileWriter(errorFile)); org.netbeans.jemmy.JemmyProperties.setCurrentOutput(new org.netbeans.jemmy.TestOut(System.in, outputWriter, errorWriter)); } /** Method will create a file and capture the screen together with saving the exception. */ private void captureScreen(Exception exc) throws Exception { java.io.File dumpFile = new java.io.File("dump.png"); try { dumpFile = new java.io.File(getWorkDirPath() + "/dump.png"); java.io.File excFile = new java.io.File(getWorkDirPath() + "/exception.txt"); dumpFile.getParentFile().mkdirs(); dumpFile.createNewFile(); java.io.PrintWriter writer = new java.io.PrintWriter(new java.io.FileWriter(excFile)); exc.printStackTrace(writer); writer.flush(); writer.close(); } catch(java.io.IOException e) {} org.netbeans.jemmy.util.PNGEncoder.captureScreen(dumpFile.getAbsolutePath()); } /** Checks that command editor can be invoked and contains all of its components. * @throws Exception any unexpected exception thrown during test. */ public void testCommandEditor() throws Exception { try { System.out.print(".. Testing command editor .."); new ActionNoBlock(MOUNT_MENU, null).perform(); VCSWizardProfile wizardProfile = new VCSWizardProfile(); wizardProfile.checkOnlyCompatibleProfiles(false); wizardProfile.setProfile(VCSWizardProfile.EMPTY_UNIX); wizardProfile.next(); VCSWizardAdvanced wizardAdvanced = new VCSWizardAdvanced(); wizardAdvanced.editCommands(); CommandEditor commandEditor = new CommandEditor(); commandEditor.verify(); Node node = new Node(commandEditor.treeCommands(), "Empty"); node.select(); String[] commands = new String[] {"Refresh", "Refresh Recursively", "(separator)", "Check in", "Check out", "Lock", "Unlock", "Add", "Remove"}; int count = commands.length; for (int i=0; i