Java Code Examples for org.eclipse.swtbot.swt.finder.SWTBot#waitUntil()

The following examples show how to use org.eclipse.swtbot.swt.finder.SWTBot#waitUntil() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwtBotTreeActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean waitUntilTreeHasItemImpl(SWTBot bot, final TreeItem tree,
    final String nodeText) {
  try {
    bot.waitUntil(new DefaultCondition() {
      @Override
      public String getFailureMessage() {
        return "Could not find node with text " + nodeText;
      }

      @Override
      public boolean test() throws Exception {
        return getTreeItem(tree, nodeText) != null;
      }
    });
  } catch (TimeoutException e) {
    return false;
  }

  return true;
}
 
Example 2
Source File: SwtBotTreeActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean waitUntilTreeHasTextImpl(SWTBot bot, final TreeItem tree) {
  try {
    bot.waitUntil(new DefaultCondition() {
      @Override
      public String getFailureMessage() {
        return "Not all of the nodes in the tree have text.";
      }

      @Override
      public boolean test() throws Exception {
        return doesTreeItemHaveText(tree);
      }
    });
  } catch (TimeoutException e) {
    return false;
  }

  return true;
}
 
Example 3
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellSessionInvitationAndShellAddProject(
    String projectName, TypeOfCreateProject usingWhichProject) throws RemoteException {

  SWTBot bot = new SWTBot();
  bot.waitUntil(
      Conditions.shellIsActive(SHELL_SESSION_INVITATION),
      SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);

  SWTBotShell invitationShell = bot.shell(SHELL_SESSION_INVITATION);
  invitationShell.bot().button(ACCEPT).click();

  bot.waitUntil(
      Conditions.shellCloses(invitationShell), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);

  confirmShellAddProjectUsingWhichProject(projectName, usingWhichProject);
  views().sarosView().waitUntilIsInSession();
}
 
Example 4
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void openRemoteProfilePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);

    // The first tree is the preference "categories" on the left side
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Remote Profiles", treeNode));
    treeNode = treeNode.getNode("Remote Profiles");
    treeNode.select();
}
 
Example 5
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * add data wizard configuration (only for defined types as String Integer Boolean etc.)
 *
 * @param bot
 * @param name
 * @param type
 * @param multiplicity
 * @param defaultValue
 */
public static void addNewData(final SWTBot bot, final String name, final String type, final boolean multiplicity,
        final String defaultValue) {
    bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.data.i18n.Messages.newVariable));
    bot.activeShell().setFocus();
    bot.textWithLabel(org.bonitasoft.studio.data.i18n.Messages.name + " *").setText(name);
    bot.comboBoxWithLabel(org.bonitasoft.studio.data.i18n.Messages.datatypeLabel).setSelection(type);
    if (multiplicity) {
        bot.checkBox(org.bonitasoft.studio.data.i18n.Messages.isMultiple).select();
    }
    if (defaultValue != null) {
        bot.textWithLabel(org.bonitasoft.studio.data.i18n.Messages.defaultValueLabel).setText(defaultValue);
    }
    bot.button(IDialogConstants.FINISH_LABEL).click();
}
 
Example 6
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void confirmShellNeedBased(String decsision, boolean remember) throws RemoteException {
  SWTBot bot = new SWTBot();
  SWTBotShell shell = bot.shell(SHELL_NEED_BASED_SYNC);
  shell.activate();
  if (remember) shell.bot().checkBox("Remember my decision.").click();
  shell.bot().button(decsision).click();
  bot.waitUntil(Conditions.shellCloses(shell));
}
 
Example 7
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public BotBdmModelEditor setType(String packageName, String businessObject, SWTBotTableItem item, String type,
        SWTBotTable attributeTable) {
    SWTBotShell activeShell = bot.activeShell();
    item.click(1);
    SWTBot activeBot = activeShell.bot();
    SWTBotCCombo ccomboBoxInGroup = activeBot.ccomboBoxWithId(FieldTypeEditingSupport.TYPE_COMBO_EDITOR_ID);
    activeBot.waitUntil(new ConditionBuilder()
            .withTest(() -> Stream.of(ccomboBoxInGroup.items()).anyMatch(type::equals))
            .withFailureMessage(() -> String.format("Type '%s' not found in combo", type))
            .create());
    ccomboBoxInGroup.setSelection(type);
    return this;
}
 
Example 8
Source File: SWTBotConnectorTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * use it when the wizard "New definition" is active. (menu
 * development>connectors>New definition...)
 * 
 * @param bot
 * @param categoryId
 * @throws Exception
 */
public static void createNewCategory(SWTBot bot, String categoryId) {
    bot.waitUntil(Conditions.widgetIsEnabled((bot.button("New..."))), 10000);
    SWTBotShell activeShell = bot.activeShell();
    bot.button("New...").click();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.activeShell()));
    Assert.assertFalse("ok button should be desabled",
            bot.button(IDialogConstants.OK_LABEL).isEnabled());
    bot.textWithLabel("Id").setText(categoryId);
    bot.textWithLabel("Display name").setText(categoryId);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
}
 
Example 9
Source File: SwtBotUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Blocks the caller until the given shell is no longer active.
 */
public static void waitUntilShellIsNotActive(SWTBot bot, final SWTBotShell shell) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public String getFailureMessage() {
      return "Shell " + shell.getText() + " did not close"; //$NON-NLS-1$
    }

    @Override
    public boolean test() throws Exception {
      return !shell.isActive();
    }
  });
}
 
Example 10
Source File: SWTBotActorFilterUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * use it when the wizard "New definition" is active. (menu
 * development>Actors filters>New definition...)
 *
 * @param bot
 * @param categoryId
 * @throws Exception
 */
public static void createNewCategory(final SWTBot bot, final String categoryId)
        throws Exception {
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button("New...")), 10000);
    SWTBotShell activeShell = bot.activeShell();
    bot.button("New...").click();
    Assert.assertFalse("ok button should be desabled",
            bot.button(IDialogConstants.OK_LABEL).isEnabled());
    bot.textWithLabel("Id").setText(categoryId);
    bot.textWithLabel("Display name").setText(categoryId);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
}
 
Example 11
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static void selectExpressionProposal(final SWTBot bot, final String storageExpressionName,
        final String returnType, final int index) {
    bot.toolbarButtonWithId(SWTBOT_ID_EXPRESSIONVIEWER_DROPDOWN, index).click();
    final SWTBotShell proposalShell = bot.shellWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_SHELL);
    final SWTBot proposalBot = proposalShell.bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_TABLE);
    final int row = proposalTAble.indexOf(storageExpressionName + " -- " + returnType, 0);
    if (row == -1) {
        throw new WidgetNotFoundException(storageExpressionName + " not found in proposals");
    }
    proposalTAble.select(row);
    proposalTAble.pressShortcut(Keystrokes.CR);
    bot.waitUntil(Conditions.shellCloses(proposalShell));
}
 
Example 12
Source File: SwtBotTestingUtilities.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Blocks the caller until the shell matching the text is open.
 */
public static void waitUntilShellIsOpen(SWTBot bot, String text) {
  bot.waitUntil(new DefaultCondition() {
      @Override
      public String getFailureMessage() {
        return "Cannot find a shell with text '" + text + "'";
      }

      @Override
      public boolean test() throws Exception {
        return bot.shell(text).isOpen();
      }
    });
}
 
Example 13
Source File: SWTBotConnectorTestUtil.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public static void selectDefinitionInConnectorShell(final SWTBot bot, final String definition) {
    bot.treeWithId(SWTBotConstants.SWTBOT_ID_EXPLORER_LEFT_TREE).select(0);
    bot.waitUntil(Conditions.tableHasRows(bot.tableWithId(SWTBotConstants.SWTBOT_ID_EXPLORER_RIGHT_TABLE), 1));
    bot.tableWithId(SWTBotConstants.SWTBOT_ID_EXPLORER_RIGHT_TABLE).select(definition);
    bot.button(IDialogConstants.NEXT_LABEL).click();
}
 
Example 14
Source File: AbstractRefactoringSwtBotTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected void waitForLinkedMode() {
  SWTBot _sWTBot = new SWTBot();
  WaitForLinkedModeCondition _waitForLinkedModeCondition = new WaitForLinkedModeCondition(this.controller);
  _sWTBot.waitUntil(_waitForLinkedModeCondition);
}
 
Example 15
Source File: TestCustomXmlWizard.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test to create a custom XML trace and compare the XML generated
 *
 * @throws IOException
 *             the xml file is not accessible, this is bad
 * @throws FileNotFoundException
 *             the xml file wasn't written, this is bad
 */
@Test
public void testNew() throws FileNotFoundException, IOException {
    File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_xml_parsers.xml").toFile();
    SWTBotUtils.createProject(PROJECT_NAME);
    SWTBotTreeItem treeNode = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    treeNode.contextMenu("Manage Custom Parsers...").click();
    SWTBotShell shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    shell.setFocus();
    SWTBot bot = shell.bot();
    bot.radio("XML").click();
    bot.button("New...").click();
    shell = bot.shell(CUSTOM_XML_PARSER_SHELL_TITLE).activate();
    shell.setFocus();
    bot = shell.bot();
    bot.textWithLabel("Category:").setText(CATEGORY_NAME);
    bot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
    bot.textWithLabel("Time Stamp format:").setText("ss");

    bot.styledText().setText(XML_TRACE1);
    bot.buttonWithTooltip("Feeling lucky").click();

    bot.tree().getTreeItem(TRACE).getNode(EVENT).select();
    bot.checkBox("Log Entry").click();
    bot.button("Next >").click();
    bot.button("Finish").click();

    shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    shell.setFocus();
    bot = shell.bot();
    bot.waitUntil(new CustomDefinitionHasContent(xmlFile, CATEGORY_NAME, TRACETYPE_NAME, EXPECTED_TEST_DEFINITION));
    String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
    assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
    bot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
    bot.button("Delete").click();

    shell = fBot.shell("Delete Custom Parser").activate();
    shell.setFocus();
    bot = shell.bot();
    bot.button("Yes").click();


    shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    shell.setFocus();
    bot = shell.bot();
    bot.button("Close").click();
    fBot.waitUntil(new CustomDefinitionHasContent(xmlFile, CATEGORY_NAME, TRACETYPE_NAME, ""));
    xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
    assertEquals("", xmlPart);

    SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
}
 
Example 16
Source File: StandardImportGzipTraceTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Import a gzip trace
 */
@Test
public void testGzipImport() {
    final String traceType = "Test trace : TMF Tests";
    final String tracesNode = "Traces [1]";
    final SWTWorkbenchBot bot = getSWTBot();

    /*
     * Actual importing
     */
    openImportWizard();
    SWTBotImportWizardUtils.selectImportFromArchive(bot, fGzipTrace.getAbsolutePath());
    SWTBotImportWizardUtils.selectFolder(bot, true, ROOT_FOLDER);
    SWTBotCheckBox checkBox = bot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace);
    assertFalse(checkBox.isEnabled());
    SWTBotCombo comboBox = bot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType);
    comboBox.setSelection(traceType);
    importFinish();
    /*
     * Remove .gz extension
     */
    assertNotNull(fGzipTrace);
    String name = fGzipTrace.getName();
    assertNotNull(name);
    assertTrue(name.length() > 3);
    String traceName = name.substring(0, name.length() - 3);
    assertNotNull(traceName);
    assertFalse(traceName.isEmpty());

    /*
     * Open trace
     */
    SWTBotView projectExplorer = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectExplorer.setFocus();
    final SWTBotTree tree = projectExplorer.bot().tree();
    /*
     * This appears to be problematic due to the length of the file name and
     * the resolution in our CI.
     */
    SWTBotTreeItem treeItem = SWTBotUtils.getTreeItem(projectExplorer.bot(), tree, PROJECT_NAME, tracesNode, traceName);
    treeItem.doubleClick();
    WaitUtils.waitForJobs();
    /*
     * Check results
     */
    SWTBot editorBot = SWTBotUtils.activeEventsEditor(bot).bot();
    SWTBotTable editorTable = editorBot.table();
    final String expectedContent1 = "Type-1";
    final String expectedContent2 = "";
    editorBot.waitUntil(ConditionHelpers.isTableCellFilled(editorTable, expectedContent1, 2, 2));
    editorBot.waitUntil(ConditionHelpers.isTableCellFilled(editorTable, expectedContent2, 1, 0));
    String c22 = editorTable.cell(2, 2);
    String c10 = editorTable.cell(1, 0);
    assertEquals(expectedContent1, c22);
    assertEquals(expectedContent2, c10);
}
 
Example 17
Source File: SWTBotImportWizardUtils.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * While in the import wizard, select a file in the file selection tree.
 *
 * @param bot
 *            the SWTBot
 * @param fileName
 *            the name of the file to select
 * @param folderTreePath
 *            the path to the parent folder in the tree
 */
public static void selectFile(SWTBot bot, String fileName, String... folderTreePath) {
    selectFolder(bot, false, folderTreePath);

    SWTBotTable fileTable = bot.table();
    bot.waitUntil(Conditions.widgetIsEnabled(fileTable));
    bot.waitUntil(ConditionHelpers.isTableItemAvailable(fileName, fileTable));
    SWTBotTableItem tableItem = fileTable.getTableItem(fileName);
    tableItem.check();
}
 
Example 18
Source File: SWTBotActorFilterUtil.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
/**
 * use it to access to the synchronize organization wizard
 * "Manage Organization" (menu Organization>Manage...)
 *
 * @param bot
 */
public static void activateSynchronizeOrganizationWizard(final SWTBot bot) {
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Organization")), 10000);
    bot.menu("Organization").menu("Deploy...").click();
    bot.waitUntil(Conditions.shellIsActive(Messages.deployOrganizationTitle), 10000);
}
 
Example 19
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the child tree item of the specified item with the given name.
 * The project element label may have a count suffix in the format ' [n]'.
 *
 * @param bot
 *            a given workbench bot
 * @param parentItem
 *            the parent tree item
 * @param name
 *            the desired child element name (without suffix)
 * @return the a {@link SWTBotTreeItem} with the specified name
 */
public static SWTBotTreeItem getTraceProjectItem(SWTBot bot, final SWTBotTreeItem parentItem, final String name) {
    ProjectElementHasChild condition = new ProjectElementHasChild(parentItem, name);
    bot.waitUntil(condition);
    return condition.getItem();
}
 
Example 20
Source File: SWTBotConnectorTestUtil.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
/**
 * use it to access to the wizard "New definition..." (menu
 * DEvelopement>Connectors>New definition...)
 * 
 * @param bot
 */
public static void activateConnectorDefinitionShell(SWTBot bot) {
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Development")), 10000);
    bot.menu("Development").menu("Connectors").menu("New definition...").click();
    bot.waitUntil(Conditions.shellIsActive("New connector definition"), 10000);
}