@Test public void testCancelChange() throws Exception { openDialog(); mBot.checkBox("Route orders to server").click(); mBot.button("Add New Property").click(); new NewPropertyInputDialogTestFixture("key2", "value2").inputData(); mBot.button("Cancel").click(); Thread.sleep(WAIT_TIME); AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { assertDeployedStrategy( mStrategy, mEngine, StrategyState.STOPPED, "Strategy1", "Claz", "Lang", "c:\\path", true, null); } }); }
@Test public void testInlineEditing() throws Exception { openDialog(); mBot.button("Add New Property").click(); new NewPropertyInputDialogTestFixture("key2", "value2").inputData(); // use index 1 since first tree is property page navigation tree CustomTree tree = new CustomTree(mBot.tree(1).widget); tree.click(0, 1); mBot.sleep(500); mBot.text("value2").setText("value3"); mBot.button("OK").click(); Thread.sleep(WAIT_TIME); AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { assertDeployedStrategy( mStrategy, mEngine, StrategyState.STOPPED, "Strategy1", "Claz", "Lang", "c:\\path", true, ImmutableMap.of("key2", "value3")); } }); }
@Test public void testChangeProperties() throws Exception { openDialog(); SWTBotCheckBox checkBox = mBot.checkBox("Route orders to server"); assertThat(checkBox.isChecked(), is(true)); checkBox.click(); mBot.button("Add New Property").click(); new NewPropertyInputDialogTestFixture("key", "value").inputData(); mBot.button("Add New Property").click(); new NewPropertyInputDialogTestFixture("key2", "value2").inputData(); mBot.button("OK").click(); Thread.sleep(WAIT_TIME); AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { assertDeployedStrategy( mStrategy, mEngine, StrategyState.STOPPED, "Strategy1", "Claz", "Lang", "c:\\path", false, ImmutableMap.of("key", "value", "key2", "value2")); } }); }
public SWTBotGefEditPart addForEach( SWTBotGefEditPart toPart, String name, String startExpression, String finalExpression) throws Exception { appendActivity(toPart, "ForEach", name); SWTBot propsBot = propsView.bot(); propsView.selectTab(2); SWTBotButton leftButton = propsBot.button(0); SWTBotButton rightButton = propsBot.button(1); leftButton.click(); rightButton.click(); propsBot.styledText(0).setText(startExpression); // Previous change must be saved otherwise we will see an ugly NPE. // This issue seems to be caused by SWTBot since the exception cannot // be seen by clicking the steps manually. save(); propsBot.styledText(1).setText(finalExpression); save(); // TODO: maybe delete the scope element SWTBotGefEditPart added = getEditPart(toPart, name); log.info("Added [part=" + added + ", name=" + name + "]"); return added; }
@Test public void testProgressAndErrorReported() throws Exception { openDialog(); final CountDownLatch latch = new CountDownLatch(1); try { AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { mEngine.setConnection( new MockUIConnection() { @Override public void update(DeployedStrategy strategy, Strategy newConfiguration) throws Exception { latch.await(); throw new Exception("Update Failed"); } }); } }); mBot.button("OK").click(); ProgressDialogFixture fixture = new ProgressDialogFixture(); fixture.assertTask("Updating strategy configuration on 'Engine'..."); latch.countDown(); ErrorDialogFixture errorDialog = new ErrorDialogFixture(); errorDialog.assertError("Update Failed"); errorDialog.dismiss(); } finally { latch.countDown(); } }
@Test public void testPropertiesContextMenu() throws Exception { openDialog(); // use index 1 since first tree is property page navigation tree SWTBotTree tree = mBot.tree(1); ContextMenuHelper.clickContextMenu(tree, "Add"); new NewPropertyInputDialogTestFixture("keyx", "valuex").inputData(); ContextMenuHelper.clickContextMenu(tree, "Add"); new NewPropertyInputDialogTestFixture("keyz", "valuez").inputData(); tree.getTreeItem("keyz").select(); ContextMenuHelper.clickContextMenu(tree, "Delete"); tree.unselect(); // delete should not show up when the selection is empty assertThat(SWTTestUtil.getMenuItems(tree).get("Delete"), nullValue()); mBot.button("OK").click(); Thread.sleep(WAIT_TIME); AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { assertDeployedStrategy( mStrategy, mEngine, StrategyState.STOPPED, "Strategy1", "Claz", "Lang", "c:\\path", true, ImmutableMap.of("keyx", "valuex")); } }); }
@Test public void testDisabledForRunningStrategy() throws Exception { AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { mStrategy = createDeployedStrategy("Strategy1"); mStrategy.setClassName("Claz"); mStrategy.setLanguage("Lang"); mStrategy.setScriptPath("c:\\path"); mStrategy.setRouteOrdersToServer(true); mStrategy.setState(StrategyState.RUNNING); mEngine = createEngine("Engine"); mEngine.setConnection(new MockUIConnection()); mEngine.getDeployedStrategies().add(mStrategy); mDialog = PropertyDialog.createDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), StrategyEngineWorkbenchUI.DEPLOYED_STRATEGY_CONFIGURATION_PROPERTY_PAGE_ID, mStrategy); mDialog.setBlockOnOpen(false); mDialog.open(); } }); mBot.shell("Properties for Strategy1 on Engine"); testDisabled(mBot.textWithLabel("Instance Name:"), "Strategy1"); testDisabled(mBot.textWithLabel("Class:"), "Claz"); testDisabled(mBot.textWithLabel("Language:"), "Lang"); testDisabled(mBot.textWithLabel("Script:"), "c:\\path"); assertThat(mBot.checkBox("Route orders to server").isEnabled(), is(false)); assertThat(mBot.checkBox("Route orders to server").isChecked(), is(true)); // use index 1 since first tree is property page navigation tree assertThat(mBot.tree(1).isEnabled(), is(false)); assertThat(mBot.button("Add New Property").isEnabled(), is(false)); }
// DONE! public SWTBotGefEditPart addValidate(SWTBotGefEditPart toPart, String name, String... variables) { appendActivity(toPart, "Validate", name); SWTBot propsBot = propsView.bot(); propsView.selectTab(1); propsBot.button("Add").click(); SWTBotShell shell = bot.shell("Select Variable").activate(); SWTBot viewBot = shell.bot(); SWTBotTable table = viewBot.table(); table.select(variables); viewBot.button("OK").click(); save(); SWTBotGefEditPart added = getEditPart(toPart, name); // log.info("Added [part=" + added + ", name=" + name + "]"); return added; }
/** @param bot */ private void createJavaProject(SWTBot bot) throws Exception { bot.menu("File") .menu("New") .menu("Java Project") .click(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ bot.shell("New Java Project").activate(); // $NON-NLS-1$ bot.textWithLabel("Project name:").setText("MyProject"); // $NON-NLS-1$ //$NON-NLS-2$ bot.button("Finish").click(); // $NON-NLS-1$ }
/** * Closes Subclipse Report Usage Window * * @param shell * @param report */ private static void closeSubclipseUsageWindow(SWTBotShell shell, boolean report) { SWTBot shellBot = shell.bot(); SWTBotCheckBox chbReportUsage = shellBot.checkBox(IDELabel.SubclipseUsageDialog.REPORT_USAGE_CHECK_BOX); if ((report && (!chbReportUsage.isChecked())) || ((!report) && chbReportUsage.isChecked())) { chbReportUsage.click(); } shellBot.button(IDELabel.Button.OK).click(); log.info("Sublcipse Report Usage window closed"); }
// DONE! public SWTBotGefEditPart addIf(SWTBotGefEditPart toPart, String name, String condition) { appendActivity(toPart, "If", name); SWTBot propsBot = propsView.bot(); propsView.selectTab(1); propsBot.button("Create a New Condition").click(); propsBot.styledText().setText(condition); save(); SWTBotGefEditPart added = getEditPart(toPart, name); log.info("Added [part=" + added + ", name=" + name + "]"); return added; }
@Test public void clicksOnANode() throws Exception { bot.checkBox("Listen").select(); SWTBotTreeItem node = bot.tree().expandNode("Node 3").expandNode("Node 3.1"); bot.button("Clear").click(); node.click(); SWTBotText listener = bot.textInGroup("Listeners"); assertTextContains("MouseDown [3]: MouseEvent{Tree {}", listener); assertTextContains("Selection [13]: SelectionEvent{Tree {}", listener); assertTextContains("item=TreeItem {Node 3.1}", listener); assertTextContains("MouseUp [4]: MouseEvent{Tree {}", listener); }
public void setUp() throws Exception { super.setUp(); bot = new SWTBot(); bot.tabItem("Tree").activate(); bot.checkBox("Listen").deselect(); bot.button("Clear").click(); bot.checkBox("Horizontal Fill").select(); bot.checkBox("Vertical Fill").select(); bot.checkBox("Header Visible").select(); bot.checkBox("Multiple Columns").deselect(); tree = bot.treeInGroup("Tree"); }
// TODO - return just the new <copy></copy> element public SWTBotGefEditPart copyVarToExpresion( SWTBotGefEditPart assignPart, String[] from, String exp) { setFocus(assignPart); propsView.selectTab(1); SWTBot propsBot = propsView.bot(); propsBot.button("New").click(); propsBot.comboBox(1).setSelection("Expression"); propsBot.tree().expandNode(from).select(); propsBot.styledText().setText(exp); save(); return assignPart; }
public SWTBotGefEditPart copyFixedToExpression( SWTBotGefEditPart assignPart, String from, String to) { setFocus(assignPart); propsView.selectTab(1); SWTBot propsBot = propsView.bot(); propsBot.button("New").click(); propsBot.comboBox(0).setSelection("Fixed Value"); propsBot.comboBox(1).setSelection("Expression"); propsBot.text().setText(from); propsBot.styledText().setText(to); save(); return assignPart; }
public SWTBotGefEditPart addAssign(SWTBotGefEditPart toPart, String name) { appendActivity(toPart, "Assign", name); propsView.selectTab(1); SWTBot propsBot = propsView.bot(); try { propsBot.list().select("? to ?"); propsBot.button("Delete").click(); } catch (AssertionFailedException e) { log.info(e.getMessage()); } save(); SWTBotGefEditPart assign = getEditPart(toPart, name); log.info("Added [part=" + assign + ", name=" + name + "]"); return assign; }
public SWTBotGefEditPart copyVarToVar(SWTBotGefEditPart assignPart, String[] from, String[] to) { setFocus(assignPart); propsView.selectTab(1); SWTBot propsBot = propsView.bot(); propsBot.button("New").click(); propsBot.tree(0).expandNode(from).select(); propsBot.tree(1).expandNode(to).select(); save(); // Initializer try { log.info("Initializer view was opend ... clicking YES."); bot.shell("Initializer").bot().button("Yes").click(); } catch (Exception e) { log.warn(e.getMessage()); log.info("Initializer view was not opened."); } return assignPart; }
/** * TODO: See {@link #addElse(SWTBotGefEditPart)} * * @param ifPart * @param condition * @return * @throws Exception */ public SWTBotGefEditPart addElseIf(SWTBotGefEditPart ifPart, String condition) throws Exception { setFocus(ifPart); gEditor.clickContextMenu("Add ElseIf"); // get the new ElseIfPart List<SWTBotGefEditPart> children = ifPart.children(); SWTBotGefEditPart elseIfPart = children.get(children.size() - 1); // test the part if (elseIfPart.part().getModel() instanceof ElseImpl) { elseIfPart = children.get(children.size() - 2); } setFocus(elseIfPart); // setup properties propsView.selectTab(0); SWTBot propsBot = propsView.bot(); propsBot.button("Create a New Condition").click(); propsBot.styledText().setText(condition); save(); log.info("Added [part=" + elseIfPart + ", name=Unnamed]"); return elseIfPart; }
public SWTBotGefEditPart addPickOnAlarm(SWTBotGefEditPart pickPart, String expression) { setFocus(pickPart); gEditor.clickContextMenu("Add OnAlarm"); save(); // get the new ElseIfPart List<SWTBotGefEditPart> children = pickPart.children(); SWTBotGefEditPart onAlaramPart = children.get(children.size() - 1); // test the part if (!(onAlaramPart.part().getModel() instanceof OnAlarm)) { onAlaramPart = children.get(children.size() - 2); } setFocus(onAlaramPart); SWTBot propsBot = propsView.bot(); propsBot.button("Create a New Condition").click(); propsBot.comboBox(1).setSelection("Text"); propsBot.styledText().setText(expression); save(); log.info("Added [part=" + onAlaramPart + ", name=Unnamed]"); // if onAlarm contains scope then return the scope. onAlarm otherwise return (onAlaramPart.children().size() == 1) ? onAlaramPart.children().get(0) : onAlaramPart; }
public void assertFinishEnabled(boolean enabled) { assertThat(mBot.button("Finish").isEnabled(), is(enabled)); }
/** * Closes Report Usage Windows and enable Atlassian Connector Usage Reporting Window. Did not find * other way how to disable Atlassian Connector Usage Reporting Window displaying * * @param reportJbtUsage * @param reportSubclipseUsage */ public static void manageBlockingWidows(boolean reportJbtUsage, boolean reportSubclipseUsage) { // Manage JBT/JBDS and Subclipse Usage Reporting SWTWorkbenchBot bot = new SWTWorkbenchBot(); SWTBotShell shJbtUsage = null; SWTBotShell shSubclipseUsage = null; bot.sleep(Timing.time5S()); new SWTUtilExt(bot).waitForNonIgnoredJobs(); SWTBotShell[] shells = bot.shells(); int index = 0; while ((shJbtUsage == null || shSubclipseUsage == null) && index < shells.length) { if (shells[index].getText().equals(IDELabel.Shell.JBOSS_DEVELOPER_STUDIO_USAGE) || shells[index].getText().equals(IDELabel.Shell.JBOSS_TOOLS_USAGE)) { shJbtUsage = shells[index]; } else if (shells[index].getText().equals(IDELabel.Shell.SUBCLIPSE_USAGE)) { shSubclipseUsage = shells[index]; } index++; } if (shJbtUsage != null && shJbtUsage.isActive()) { closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage); if (shSubclipseUsage != null) { closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage); } } else if (shSubclipseUsage != null && shSubclipseUsage.isActive()) { closeSubclipseUsageWindow(shSubclipseUsage, reportSubclipseUsage); if (shJbtUsage != null) { closeJBossToolsUsageWindow(shJbtUsage, reportJbtUsage); } } // Manage Atlassian Connector Usage Reporting try { SWTBot prefBot = new SWTOpenExt(new SWTBotExt()) .preferenceOpen(ActionItem.Preference.AtlassianConnectorUsageData.LABEL); SWTBotCheckBox chbEnableMonitoring = prefBot.checkBox(); if (!chbEnableMonitoring.isChecked()) { chbEnableMonitoring.click(); } prefBot.button(IDELabel.Button.OK).click(); } catch (WidgetNotFoundException wnfe) { // do nothing there is no Atlassian Connector installed } // Get rid of welcome screen. Simple close did not work when run in maven log.debug("Trying to close Welcome Screen"); for (IViewReference viewReference : WorkbenchPartLookup.getInstance().findAllViewReferences()) { if (viewReference.getPartName().equals("Welcome")) { final IViewReference iViewReference = viewReference; Display.syncExec( new Runnable() { @Override public void run() { iViewReference.getPage().hideView(iViewReference); } }); log.debug("Welcome Screen closed"); break; } // ok, Welcome screen not present log.info("Welcome window not present"); } }
public static void continueInstall(final SWTWorkbenchBot bot, final String shellTitle) throws InstallFailureException { try { bot.radio(0).click(); bot.button("Finish").click(); // wait for Security pop-up, or install finished. final SWTBotShell shell = bot.shell(shellTitle); bot.waitWhile( new ICondition() { @Override public boolean test() throws Exception { return shell.isActive(); } @Override public void init(SWTBot bot) {} @Override public String getFailureMessage() { return null; } }, installationTimeout); if (bot.activeShell().getText().equals("Security Warning")) { bot.button("OK").click(); System.err.println("OK clicked"); bot.waitUntil( new ICondition() { @Override public boolean test() throws Exception { try { boolean stillOpen = bot.shell(shellTitle).isOpen(); System.err.println("still open? " + stillOpen); return !stillOpen; } catch (WidgetNotFoundException ex) { System.err.println("no shell"); // Shell already closed return true; } } @Override public void init(SWTBot bot) {} @Override public String getFailureMessage() { return null; } }, installationTimeout); // 15 more minutes } SWTBot restartShellBot = bot.shell("Software Updates").bot(); // Don't restart in test, test executor will do it. try { // Eclipse 4.2 => "No" restartShellBot.button("No").click(); } catch (WidgetNotFoundException ex) { // Eclipse 3.7.x => "Not now" restartShellBot.button("Not Now").click(); } } catch (Exception ex) { String installDesc = bot.text().getText(); if (installDesc == null || installDesc.isEmpty()) { throw new RuntimeException("Internal error", ex); } throw new InstallFailureException(installDesc); } }
public void cancel() { mBot.button("Cancel").click(); }
public void finish() { mBot.button("Finish").click(); }
/** * test opening a trace, importing * * @throws IOException won't happen */ @Test public void test() throws IOException { File f = File.createTempFile("temp", ".xml").getCanonicalFile(); try (FileWriter fw = new FileWriter(f)) { fw.write(TRACE_CONTENT); } File exportPackage = new File(EXPORT_LOCATION); if (exportPackage.exists()) { exportPackage.delete(); } assertFalse( "File: " + EXPORT_LOCATION + " already present, aborting test", exportPackage.exists()); assertTrue("Trace :" + f.getAbsolutePath() + " does not exist, aborting test", f.exists()); SWTBotUtils.createProject(PROJECT_NAME); SWTBotUtils.openTrace(PROJECT_NAME, f.getAbsolutePath(), XMLSTUB_ID); WaitUtils.waitForJobs(); ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace(); assertNotNull(trace); assertEquals( "Incorrect opened trace!", f.getAbsolutePath(), (new File(trace.getPath())).getAbsolutePath()); SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER); assertNotNull("Cannot find " + PROJECT_EXPLORER, projectExplorerBot); projectExplorerBot.show(); SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeItem.contextMenu(EXPORT_TRACE_PACKAGE).click(); fBot.waitUntil(Conditions.shellIsActive(EXPORT_TRACE_PACKAGE_TITLE)); SWTBot shellBot = fBot.activeShell().bot(); shellBot.button(DESELECT_ALL).click(); SWTBotTreeItem[] items = fBot.tree().getAllItems(); for (SWTBotTreeItem item : items) { assertEquals(item.isChecked(), false); } shellBot.button(SELECT_ALL).click(); for (SWTBotTreeItem item : items) { assertEquals(item.isChecked(), true); } shellBot.radio(SAVE_IN_TAR_FORMAT).click(); shellBot.radio(SAVE_IN_ZIP_FORMAT).click(); shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click(); shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click(); shellBot.comboBox().setText(EXPORT_LOCATION); SWTBotShell shell = fBot.activeShell(); shellBot.button(FINISH).click(); // finished exporting WaitUtils.waitForJobs(); fBot.waitUntil(Conditions.shellCloses(shell)); fBot = new SWTWorkbenchBot(); exportPackage = new File(EXPORT_LOCATION); assertTrue("Exported package", exportPackage.exists()); // Fixme: determine why exportPackageSize is different on different machines // assertEquals("Exported package size check", PACKAGE_SIZE, exportPackage.length()); // import treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME); treeItem.contextMenu(IMPORT_TRACE_PACKAGE).click(); fBot.waitUntil(Conditions.shellIsActive(IMPORT_TRACE_PACKAGE_TITLE)); shellBot = fBot.activeShell().bot(); shellBot.comboBox().setText(EXPORT_LOCATION); shellBot.comboBox().typeText("\n"); shellBot.button(SELECT_ALL).click(); shell = fBot.activeShell(); shellBot.button(FINISH).click(); fBot.button("Yes To All").click(); fBot.waitUntil(Conditions.shellCloses(shell)); fBot = new SWTWorkbenchBot(); SWTBotUtils.openEditor(fBot, PROJECT_NAME, new Path(f.getName())); trace = TmfTraceManager.getInstance().getActiveTrace(); assertNotNull(trace); assertEquals("Test if import matches", f.getName(), trace.getName()); assertFalse("Test if import files don't match", f.getAbsolutePath().equals(trace.getPath())); SWTBotUtils.deleteProject(PROJECT_NAME, fBot); WaitUtils.waitForJobs(); }