Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#activate()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#activate() . 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: KernelTimeGraphViewTestBase.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test the legend content
 */
@Test
public void testLegend() {
    List<String> labelValues = getLegendValues();
    SWTBotToolbarButton legendButton = getViewBot().toolbarButton("Show Legend");
    legendButton.click();
    SWTBotShell shell = fBot.shell("Legend");
    shell.activate();
    SWTBot bot = shell.bot();
    for (int i = 0; i < labelValues.size(); i++) {
        SWTBotCLabel label = bot.clabel(i);
        assertNotNull(label);
        assertEquals(labelValues.get(i), label.getText());
    }
    bot.button("OK").click();
}
 
Example 2
Source File: XsemanticsSwtbotTestBase.java    From xsemantics with Eclipse Public License 1.0 6 votes vote down vote up
protected void createProjectAndAssertNoErrorMarker(String projectType) throws CoreException {
	SWTBotMenu fileMenu = bot.menu("File");
	SWTBotMenu newMenu = fileMenu.menu("New");
	SWTBotMenu projectMenu = newMenu.menu("Project...");
	projectMenu.click();

	SWTBotShell shell = bot.shell("New Project");
	shell.activate();
	SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics");
	waitForTreeItems(xsemanticsNode);
	xsemanticsNode.expandNode(projectType).select();
	bot.button("Next >").click();

	bot.textWithLabel("Project name:").setText(TEST_PROJECT);

	bot.button("Finish").click();

	// creation of a project might require some time
	bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT);
	assertTrue("Project doesn't exist", isProjectCreated(TEST_PROJECT));

	waitForBuild();
	assertNoErrorsInProject();
}
 
Example 3
Source File: SarosPreferences.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private void setIBBOnlyTransfer(boolean check) throws RemoteException {

    clickMenuSarosPreferences();

    SWTBot bot = new SWTBot();

    SWTBotShell shell = bot.shell(SHELL_PREFERNCES);

    shell.activate();
    shell.bot().tree().expandNode(NODE_SAROS, NODE_SAROS_NETWORK).select();

    SWTBotCheckBox checkBox =
        shell
            .bot()
            .checkBoxInGroup(
                PREF_NODE_SAROS_NETWORK_ADVANCED_GROUP_FILE_TRANSFER_FORCE_IBB,
                PREF_NODE_SAROS_NETWORK_ADVANCED_GROUP_FILE_TRANSFER);

    if (check) checkBox.select();
    else checkBox.deselect();

    shell.bot().button(APPLY).click();
    shell.bot().button(APPLY_AND_CLOSE).click();

    shell.bot().waitUntil(SarosConditions.isShellClosed(shell));
  }
 
Example 4
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellAddProjectUsingExistProjectWithCopy(String projectName)
    throws RemoteException {

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

  SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS);
  shell.activate();

  shell.bot().radio("Use existing project").click();
  shell.bot().checkBox("Create copy for working distributed. New project name:").click();
  shell.bot().button(FINISH).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
}
 
Example 5
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellCreateNewXMPPAccount(JID jid, String password) throws RemoteException {
  SWTBotShell shell = new SWTBot().shell(SHELL_CREATE_XMPP_JABBER_ACCOUNT);
  shell.activate();

  shell.bot().textWithLabel(LABEL_XMPP_JABBER_SERVER).setText(jid.getDomain());
  shell.bot().textWithLabel(LABEL_USER_NAME).setText(jid.getName());
  shell.bot().textWithLabel(LABEL_PASSWORD).setText(password);
  shell.bot().textWithLabel(LABEL_REPEAT_PASSWORD).setText(password);

  shell.bot().button(FINISH).click();
  try {
    shell.bot().waitUntil(Conditions.shellCloses(shell));
  } catch (TimeoutException e) {
    String errorMessage = ((WizardDialog) shell.widget.getData()).getMessage();
    if (errorMessage.matches(ERROR_MESSAGE_TOO_FAST_REGISTER_ACCOUNTS + ".*"))
      throw new RuntimeException("you are not allowed to register accounts so fast");
    else if (errorMessage.matches(ERROR_MESSAGE_ACCOUNT_ALREADY_EXISTS + ".*\n*.*"))
      throw new RuntimeException("the Account " + jid.getBase() + " already exists");
  }
}
 
Example 6
Source File: SarosPreferences.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void removeAccount(JID jid) throws RemoteException {

  if (!isAccountExistNoGUI(jid)) return;

  SWTBotShell shell = preCondition();
  shell.bot().listInGroup(GROUP_TITLE_XMPP_JABBER_ACCOUNTS).select(jid.getBase());

  SWTBotButton removeButton =
      shell.bot().buttonInGroup(BUTTON_REMOVE_ACCOUNT, GROUP_TITLE_XMPP_JABBER_ACCOUNTS);

  if (removeButton.isEnabled()) {
    removeButton.click();
    SWTBotShell removeAccountConfirmationShell = shell.bot().shell(REMOVE_ACCOUNT_DIALOG_TITLE);

    removeAccountConfirmationShell.activate();
    removeAccountConfirmationShell.bot().button(YES).click();
    removeAccountConfirmationShell
        .bot()
        .waitUntil(Conditions.shellCloses(removeAccountConfirmationShell));

    shell.bot().button(APPLY).click();
    shell.bot().button(APPLY_AND_CLOSE).click();
    shell.bot().waitUntil(Conditions.shellCloses(shell));
  } else throw new RuntimeException("button to delete an account is not enabled");
}
 
Example 7
Source File: CreateProjectDemo.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void createProject() throws Exception {
	String projectName = "prjBot-001";
	
	bot.menu("File").menu("New").click();
	SWTBotShell shell = bot.shell("New");
	shell.activate();
	// From menu open File > New dialog, verify whether the dialog has been opened.
	
	bot.tree().select("Project");
	SWTBotAssert.assertEnabled(bot.button("Next >"));
	// After selecting Project, the Next button should be enabled.
	
	bot.button("Next >").click();
	bot.textWithLabel("Project name:").setText(projectName);
	SWTBotAssert.assertEnabled(bot.button("Finish"));
	// Enter the Project Name, then Finish button should be enabled.
	
	bot.button("Finish").click();
	SWTBotAssert.assertVisible(bot.tree().select(projectName));
	// Click Finish button and verify whether the project's been successfully created.
}
 
Example 8
Source File: ContextMenusInPEView.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void openWith(String editorType) throws RemoteException {
  treeItem.select();
  ContextMenuHelper.clickContextMenu(tree, CM_OPEN_WITH, CM_OTHER);

  SWTBotShell shell = new SWTBot().shell(SHELL_EDITOR_SELECTION);

  shell.activate();
  shell.bot().table().getTableItem(editorType).select();
  shell.bot().button(OK).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
}
 
Example 9
Source File: NewC.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/**
 * ************************************************************
 *
 * <p>Inner functions
 *
 * <p>************************************************************
 */
private void confirmShellNewJavaClass(String className) {
  final String defaultPkg = "";

  SWTBotShell shell = new SWTBot().shell(SHELL_NEW_JAVA_CLASS);
  shell.activate();
  shell.bot().textWithLabel(LABEL_NAME).setText(className);
  shell.bot().textWithLabel(LABEL_PACKAGE).setText(defaultPkg);
  shell.bot().button(FINISH).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
}
 
Example 10
Source File: RefactorC.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private void moveTo(String shellTitle, String buttonName, String... nodes) {
  treeItem.select();
  ContextMenuHelper.clickContextMenu(tree, MENU_REFACTOR, MENU_MOVE);
  SWTBotShell shell = new SWTBot().shell(shellTitle);
  shell.activate();
  shell.bot().tree().expandNode(nodes).select();
  shell.bot().button(buttonName).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
}
 
Example 11
Source File: ContextMenusInContactListArea.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void rename(String nickname) throws RemoteException {
  getTreeItem().select();
  ContextMenuHelper.clickContextMenu(tree, CM_RENAME);

  SWTBotShell shell = new SWTBot().shell(SHELL_SET_NEW_NICKNAME);
  shell.activate();
  shell.bot().text().setText(nickname);
  shell.bot().button(OK).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
  // wait for tree update in saros session view
  new SWTBot().sleep(500);
}
 
Example 12
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void confirmShellAddProjectWithNewProject(String projectName) throws RemoteException {

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

  SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS);
  shell.activate();

  shell.bot().radio(RADIO_CREATE_NEW_PROJECT).click();
  shell.bot().textWithLabel("Project name", 0).setText(projectName);
  shell.bot().button(FINISH).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
}
 
Example 13
Source File: BotDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Click on Cancel.
 */
public void cancel() {
    if (dialogTitle != null && !dialogTitle.isEmpty()) {
        final SWTBotShell shell = bot.shell(dialogTitle);
        shell.activate();
        shell.setFocus();
    }
    bot.waitUntil(Conditions.waitForWidget(allOf(widgetOfType(Button.class), withMnemonic(IDialogConstants.CANCEL_LABEL),
            withStyle(SWT.PUSH, "SWT.PUSH"))), 20000);
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}
 
Example 14
Source File: NewC.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
private void confirmWizardNewProject(String projectName) {
  SWTBotShell shell = new SWTBot().shell(SHELL_NEW_PROJECT);
  shell.activate();
  shell.bot().tree().expandNode(NODE_GENERAL, NODE_PROJECT).select();
  shell.bot().button(NEXT).click();
  shell.bot().textWithLabel(LABEL_PROJECT_NAME).setText(projectName);
  shell.bot().button(FINISH).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);
}
 
Example 15
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void confirmShellClosingTheSession() throws RemoteException {
  SWTBotShell shell = new SWTBot().shell(SHELL_CLOSING_THE_SESSION);
  shell.activate();
  shell.bot().button(OK).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
  // wait for tree update in the saros session view
  new SWTBot().sleep(500);
}
 
Example 16
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void confirmShellEditXMPPAccount(String xmppJabberID, String newPassword)
    throws RemoteException {
  SWTBotShell shell = new SWTBot().shell(SHELL_EDIT_XMPP_JABBER_ACCOUNT);
  shell.activate();

  shell.bot().comboBoxWithLabel(LABEL_XMPP_JABBER_ID).setText(xmppJabberID);
  shell.bot().textWithLabel(LABEL_PASSWORD).setText(newPassword);
  shell.bot().button(FINISH).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
}
 
Example 17
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the legend operation. Change sliders and reset, do not change colors
 * as there is not mock of the color picker yet
 *
 * TODO: mock color picker
 */
@Test
public void testLegend() {
    resetTimeRange();
    Rectangle bounds = fBounds;

    ImageHelper ref = ImageHelper.grabImage(bounds);

    // Set the widths to 0.25

    fViewBot.toolbarButton(SHOW_LEGEND).click();
    SWTBotShell legendShell = fBot.shell(LEGEND_NAME);
    legendShell.activate();
    SWTBot legendBot = legendShell.bot();
    assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, HAIR_ID).isEnabled());
    int defaultValue = legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).getValue();
    legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).setValue(25);
    assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, HAIR_ID).isEnabled());
    legendShell.bot().button(OK_BUTTON).click();
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    resetTimeRange();

    // Take another picture
    ImageHelper skinny = ImageHelper.waitForNewImage(bounds, ref);

    /* Compare with the original, they should be different */
    int refCount = ref.getHistogram().count(fHair);
    int skinnyCount = skinny.getHistogram().count(fHair);
    assertTrue(String.format("Count of \"\"HAIR\"\" (%s) did not get change despite change of width before: %d after:%d histogram:%s", fHair, refCount, skinnyCount, Multisets.copyHighestCountFirst(skinny.getHistogram())), skinnyCount < refCount);

    // reset all
    fViewBot.toolbarButton(SHOW_LEGEND).click();
    legendShell = fBot.shell(LEGEND_NAME);
    legendBot = legendShell.bot();
    assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, HAIR_ID).isEnabled());
    legendBot.buttonWithId(LEGEND_ENTRY_KEY, HAIR_ID).click();
    assertEquals(defaultValue, legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).getValue());
    assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, HAIR_ID).isEnabled());
    legendBot.button(OK_BUTTON).click();
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    resetTimeRange();

    // take a third picture
    ImageHelper reset = ImageHelper.waitForNewImage(bounds, skinny);

    // Compare with the original, they should be the same
    int resetCount = reset.getHistogram().count(fHair);
    assertEquals("Count of \"HAIR\" did not get change despite reset of width", refCount, resetCount);
}
 
Example 18
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the legend and export operations. Resize states, take screenshots
 * and compare, they should be different. then reset the sizes and compare,
 * they should be the same.
 *
 * NOTE: This utterly fails in GTK3.
 *
 * @throws IOException
 *             file not found, someone deleted files while the test is
 *             running
 */
@Ignore
@Test
public void testExport() throws IOException {

    resetTimeRange();
    /*
     * Set up temp files
     */
    File ref = File.createTempFile(REFERENCE_LOC, EXTENSION);
    File skinny = File.createTempFile(SKINNY_LOC, EXTENSION);
    File reset = File.createTempFile(RESET_LOC, EXTENSION);
    ref.deleteOnExit();
    skinny.deleteOnExit();
    reset.deleteOnExit();

    /* Take a picture */
    TmfFileDialogFactory.setOverrideFiles(ref.getAbsolutePath());
    fViewBot.viewMenu(EXPORT_MENU).click();
    ImageHelper refImage = ImageHelper.fromFile(ref);
    fBot.waitUntil(new FileWritten(ref, MIN_FILE_SIZE));

    /* Set the widths to skinny */
    fViewBot.toolbarButton(SHOW_LEGEND).click();
    SWTBotShell legendShell = fBot.shell(LEGEND_NAME);
    legendShell.activate();
    SWTBot legendBot = legendShell.bot();
    legendBot.scaleWithId(LEGEND_ENTRY_KEY, HAIR_ID).setValue(50);
    legendShell.bot().button(OK_BUTTON).click();
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    resetTimeRange();

    /* Take another picture */
    TmfFileDialogFactory.setOverrideFiles(skinny.getAbsolutePath());
    fViewBot.viewMenu(EXPORT_MENU).click();
    ImageHelper skinnyImage = ImageHelper.fromFile(skinny);
    fBot.waitUntil(new FileWritten(skinny, MIN_FILE_SIZE));

    /* Compare with the original, they should be different */
    int refCount = refImage.getHistogram().count(fHair);
    int skinnyCount = skinnyImage.getHistogram().count(fHair);
    assertTrue(String.format("Count of \"\"HAIR\"\" (%s) did not get change despite change of width before: %d after:%d histogram:%s", fHair, refCount, skinnyCount, Multisets.copyHighestCountFirst(skinnyImage.getHistogram())),
            skinnyCount < refCount);

    /* reset all */
    fViewBot.toolbarButton(SHOW_LEGEND).click();
    legendShell = fBot.shell(LEGEND_NAME);
    legendBot = legendShell.bot();
    legendBot.buttonWithId(LEGEND_ENTRY_KEY, HAIR_ID).click();
    legendBot.button(OK_BUTTON).click();
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    resetTimeRange();

    /* take a third picture */
    TmfFileDialogFactory.setOverrideFiles(reset.getAbsolutePath());
    fViewBot.viewMenu(EXPORT_MENU).click();
    fBot.waitUntil(new FileWritten(reset, MIN_FILE_SIZE));
    ImageHelper resetImage = ImageHelper.fromFile(reset);

    /* Compare with the original, they should be the same */
    int resetCount = resetImage.getHistogram().count(fHair);
    assertEquals("Count of \"HAIR\" did not get change despite reset of width", refCount, resetCount);
}
 
Example 19
Source File: SwtBotAppEngineActions.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
public static IProject createWebAppProject(SWTWorkbenchBot bot, String projectName,
    String location, String javaPackage, AppEngineRuntime runtime, Runnable extraBotActions) {
  bot.menu("File").menu("New").menu("Project...").click();

  SWTBotShell shell = bot.shell("New Project");
  shell.activate();

  SwtBotTreeUtilities.select(
      bot, bot.tree(), "Google Cloud Platform", "Google App Engine Standard Java Project");
  bot.button("Next >").click();

  if (extraBotActions != null) {
    extraBotActions.run();
  }

  bot.textWithLabel("Project name:").setText(projectName);
  if (location == null) {
    bot.checkBox("Use default location").select();
  } else {
    bot.checkBox("Use default location").deselect();
    bot.textWithLabel("Location:").setText(location);
  }
  if (javaPackage != null) {
    bot.textWithLabel("Java package:").setText(javaPackage);
  }
  if (runtime != null) {
    if (runtime == AppEngineRuntime.STANDARD_JAVA_8) {
      bot.comboBoxWithLabel("Java version:").setSelection("Java 8, Servlet 3.1");
    } else if (runtime == AppEngineRuntime.STANDARD_JAVA_8_SERVLET_25) {
      bot.comboBoxWithLabel("Java version:").setSelection("Java 8, Servlet 2.5");
    } else {
      Assert.fail("Runtime not handled: " + runtime);
    }
  }

  // can take a loooong time to resolve jars (e.g. servlet-api.jar) from Maven Central
  int libraryResolutionTimeout = 300 * 1000/* ms */;
  SwtBotTimeoutManager.setTimeout(libraryResolutionTimeout);
  try {
    SwtBotTestingUtilities.clickButtonAndWaitForWindowClose(bot, bot.button("Finish"));
  } catch (TimeoutException ex) {
    System.err.println("FATAL: timed out while waiting for the wizard to close. Forcibly killing "
        + "all shells: https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1925");
    System.err.println("FATAL: You will see tons of related errors: \"Widget is disposed\", "
        + "\"Failed to execute runnable\", \"IllegalStateException\", etc.");
    SwtBotWorkbenchActions.killAllShells(bot);
    throw ex;
  }
  SwtBotTimeoutManager.resetTimeout();
  IProject project = waitUntilFacetedProjectExists(bot, getWorkspaceRoot().getProject(projectName));
  SwtBotWorkbenchActions.waitForProjects(bot, project);
  return project;
}
 
Example 20
Source File: SuperBot.java    From saros with GNU General Public License v2.0 3 votes vote down vote up
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));
}