public void confirmShellShareProjectFiles(String project, String[] files, JID[] jids) { SWTBot bot = new SWTBot(); SWTBotShell shell = bot.shell(SHELL_SHARE_PROJECT); shell.activate(); // wait for tree update bot.sleep(500); SWTBotTree tree = shell.bot().tree(); selectProjectFiles(tree, project, files); shell.bot().button(NEXT).click(); // wait for tree update bot.sleep(500); tree = shell.bot().tree(); for (SWTBotTreeItem item : tree.getAllItems()) while (item.isChecked()) item.uncheck(); for (JID jid : jids) WidgetUtil.getTreeItemWithRegex(tree, Pattern.quote(jid.getBase()) + ".*").check(); shell.bot().button(FINISH).click(); bot.waitUntil(Conditions.shellCloses(shell)); }
public static void selectTabbedPropertyView(final SWTBot viewerBot, final String tabeText) { viewerBot.sleep( 1000); // DO NOT REMOVE ME //TODO : find a way to remove bot.sleep, can save almost one // minute UIThreadRunnable.syncExec( new VoidResult() { /* * (non-Javadoc) * @see org.eclipse.swtbot.swt.finder.results.VoidResult#run() */ @Override @SuppressWarnings("restriction") public void run() { try { final List<? extends Widget> widgets = viewerBot .getFinder() .findControls(WidgetMatcherFactory.widgetOfType(TabbedPropertyList.class)); Assert.assertTrue( "No widget of type " + TabbedPropertyList.class.getName() + " has been found", widgets.size() > 0); final TabbedPropertyList tabbedPropertyList = (TabbedPropertyList) widgets.get(0); final StringBuilder availableTabbedPropertySection = new StringBuilder(""); int i = 0; boolean found = false; ListElement currentTab; final Method selectMethod = TabbedPropertyList.class.getDeclaredMethod("select", new Class[] {int.class}); selectMethod.setAccessible(true); do { currentTab = (org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList .ListElement) tabbedPropertyList.getElementAt(i); if (currentTab != null) { final String label = currentTab.getTabItem().getText(); availableTabbedPropertySection.append(label); if (label.equals(tabeText)) { found = true; selectMethod.invoke(tabbedPropertyList, i); } } i++; } while (currentTab != null && !found); if (!found) { throw new WidgetNotFoundException( "Can't find a tab item with " + tabeText + " label. Only found: " + availableTabbedPropertySection.toString()); } } catch (final Exception ex) { BonitaStudioLog.error(ex); throw new WidgetNotFoundException( "Can't find a tab item with " + tabeText + " label"); } } }); }
@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")); } }); }
public static void init(String projectName) throws Exception { SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; Utilities.getDefault().buildProject(projectName); bot = new SWTBot(); SWTBotShell executableShell = null; for (int i = 0, attempts = 100; i < attempts; i++) { for (SWTBotShell shell : bot.shells()) { if (shell.getText().contains("Debug New Executable")) { executableShell = shell; shell.setFocus(); break; } } if (executableShell != null) break; bot.sleep(10); } IPath executablePath = Utilities.getDefault().getProjectPath(projectName).append("a.out"); // $NON-NLS-1$ executableShell.bot().textWithLabel("Binary: ").typeText(executablePath.toOSString()); bot.sleep(2000); executableShell.bot().button("OK").click(); mainShell = null; for (int i = 0, attempts = 100; i < attempts; i++) { for (SWTBotShell shell : bot.shells()) { if (shell.getText().contains("C/C++ Stand-alone Debugger")) { mainShell = shell; shell.setFocus(); break; } } if (mainShell != null) break; bot.sleep(10); } assertNotNull(mainShell); }
@Override public void confirmShellRequestOfSubscriptionReceived() throws RemoteException { SWTBot bot = new SWTBot(); SWTBotShell shell = bot.shell(SHELL_REQUEST_OF_SUBSCRIPTION_RECEIVED); shell.activate(); shell.bot().button(OK).click(); bot.waitUntil(Conditions.shellCloses(shell)); // wait for tree update in the saros session view bot.sleep(500); }
@Override public void confirmShellAddContactsToSession(String... baseJIDOfinvitees) throws RemoteException { SWTBot bot = new SWTBot(); SWTBotShell shell = bot.shell(SHELL_ADD_CONTACT_TO_SESSION); shell.activate(); // wait for tree update bot.sleep(500); SWTBotTree tree = shell.bot().tree(); for (String baseJID : baseJIDOfinvitees) WidgetUtil.getTreeItemWithRegex(tree, Pattern.quote(baseJID) + ".*").check(); shell.bot().button(FINISH).click(); bot.waitUntil(Conditions.shellCloses(shell)); // wait for tree update in the saros session view bot.sleep(500); }
@Override public void confirmShellAddContact(JID jid) throws RemoteException { SWTBot bot = new SWTBot(); SWTBotShell shell = bot.shell(SHELL_ADD_CONTACT_WIZARD); shell.activate(); shell.bot().comboBoxWithLabel(LABEL_XMPP_JABBER_ID).setText(jid.getBase()); shell.bot().button(FINISH).click(); bot.sleep(500); for (SWTBotShell currentShell : bot.shells()) { // FIXME HARDCODED ! if (currentShell.getText().equals("Contact Unknown")) { currentShell.bot().button(YES).click(); break; } } bot.waitUntil(Conditions.shellCloses(shell)); // wait for tree update in the saros session view bot.sleep(500); }
@Override public void confirmShellAddProjectToSession(String project, String[] files) throws RemoteException { SWTBot bot = new SWTBot(); SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS_TO_SESSION); shell.activate(); // wait for tree update bot.sleep(500); SWTBotTree tree = shell.bot().tree(); selectProjectFiles(tree, project, files); shell.bot().button(FINISH).click(); bot.waitUntil(Conditions.shellCloses(shell)); }
@Override public void confirmShellAddProjectsToSession(String... projectNames) throws RemoteException { SWTBot bot = new SWTBot(); SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS_TO_SESSION); shell.activate(); // wait for tree update bot.sleep(500); SWTBotTree tree = shell.bot().tree(); for (String projectName : projectNames) tree.getTreeItem(projectName).check(); shell.bot().button(FINISH).click(); bot.waitUntil(Conditions.shellCloses(shell)); }
@Override public void confirmShellAddProjectUsingExistProject(String projectName) throws RemoteException { SWTBot bot = new SWTBot(); bot.waitUntil( Conditions.shellIsActive(SHELL_ADD_PROJECT), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT); SWTBotShell shell = bot.shell(SHELL_ADD_PROJECT); shell.activate(); shell.bot().radio(RADIO_USING_EXISTING_PROJECT).click(); shell.bot().textWithLabel("Project name", 1).setText(projectName); shell.bot().button(FINISH).click(); // prevent STF from entering an endless loop int timeout = 5; confirmDialogs: while (timeout-- > 0) { bot.sleep(2000); for (SWTBotShell currentShell : bot.shells()) { if (currentShell.getText().equals(SHELL_WARNING_LOCAL_CHANGES_DELETED) || currentShell.getText().equals(SHELL_SAVE_RESOURCE)) { currentShell.activate(); currentShell.bot().button(YES).click(); currentShell.bot().waitUntil(Conditions.shellCloses(currentShell)); break confirmDialogs; } else if (currentShell.getText().equals(SHELL_CONFIRM_SAVE_UNCHANGED_CHANGES)) { currentShell.activate(); currentShell.bot().button(YES).click(); currentShell.bot().waitUntil(Conditions.shellCloses(currentShell)); shell.bot().button(FINISH).click(); continue confirmDialogs; } } } shell.bot().waitUntil(Conditions.shellCloses(shell)); }