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

The following examples show how to use org.eclipse.swtbot.swt.finder.SWTBot#shell() . 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: 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 2
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellAddProjectUsingWhichProject(
    String projectName, TypeOfCreateProject usingWhichProject) 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();

  switch (usingWhichProject) {
    case NEW_PROJECT:
      confirmShellAddProjectWithNewProject(projectName);
      break;
    case EXIST_PROJECT:
      confirmShellAddProjectUsingExistProject(projectName);
      break;
    case EXIST_PROJECT_WITH_COPY:
      confirmShellAddProjectUsingExistProjectWithCopy(projectName);
      break;
  }
}
 
Example 3
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@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));
}
 
Example 4
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@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));
}
 
Example 5
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 6
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 7
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 8
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@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();

  try {
    bot.waitUntil(Conditions.shellCloses(shell));
  } catch (TimeoutException e) {
    // If the dialog didn't close in time, close any message boxes that
    // a you can answer with "Yes, I want to add the contact anyway"

    // FIXME Hard-coded message titles (see AddContactWizard)
    List<String> messagesToIgnore =
        Arrays.asList(
            "Contact Unknown",
            "Server Not Found",
            "Unsupported Contact Status Check",
            "Unknown Contact Status",
            "Server Not Responding",
            "Unknown Error");

    for (SWTBotShell currentShell : bot.shells()) {
      String text = currentShell.getText();

      if (messagesToIgnore.contains(text)) {
        currentShell.bot().button(YES).click();
      }
    }
  }

  // wait for tree update in the saros session view
  bot.sleep(500);
}
 
Example 9
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void confirmShellLeavingClosingSession() throws RemoteException {
  SWTBot bot = new SWTBot();
  SWTBotShell shell;

  if (!Views.getInstance().sarosView().isHost()) {
    shell = bot.shell(SHELL_CONFIRM_LEAVING_SESSION);
  } else {
    shell = bot.shell(SHELL_CONFIRM_CLOSING_SESSION);
  }
  shell.activate();
  shell.bot().button(YES).click();
  Views.getInstance().sarosView().waitUntilIsNotInSession();
}
 
Example 11
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void confirmShellNewSharedFile(String decision) {
  SWTBot bot = new SWTBot();
  SWTBotShell shell = bot.shell(SHELL_NEW_FILE_SHARED);
  shell.activate();
  shell.bot().button(decision).click();
  bot.waitUntil(Conditions.shellCloses(shell));
}
 
Example 12
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 13
Source File: SuperBot.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void confirmShellAddProjectUsingExistProject(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();

  // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=344484
  // FIXME fix the bug in the SWTBot Framework, do not use a workaround
  final Button radioButton = shell.bot().radio(RADIO_CREATE_NEW_PROJECT).widget;

  UIThreadRunnable.syncExec(
      new VoidResult() {

        @Override
        public void run() {
          radioButton.setSelection(false);
        }
      });

  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));
}
 
Example 14
Source File: SuperBot.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@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);
}
 
Example 15
Source File: SarosPreferences.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
private void preferInstantSessionStart(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_ADVANCED).select();

    SWTBotCheckBox checkBox =
        shell.bot().checkBox(PREF_NODE_SAROS_ADVANCED_INSTANT_SESSION_START_PREFERRED);

    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 16
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));
}