org.eclipse.swtbot.swt.finder.widgets.TimeoutException Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.TimeoutException. 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
/**
 * Blocks the caller until all of the direct children of the tree have text. The assumption is
 * that the tree does not have any "empty" children.
 *
 * TODO: Refactor some of this logic; it follows the same general pattern as
 * {@link #waitUntilTreeItemHasItem(SWTBot, SWTBotTreeItem, String)}.
 *
 * @param tree the tree to search
 * @throws TimeoutException if all of the direct children of the tree do not have text within the
 *         timeout period
 */
public static void waitUntilTreeHasText(SWTBot bot, final SWTBotTreeItem tree)
    throws TimeoutException {
  // Attempt #1
  if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
    // Attempt #2: Something went wrong, try to cautiously reopen it.
    bot.sleep(1000);

    // There isn't a method to collapse, so double-click instead
    tree.doubleClick();
    bot.waitUntil(new TreeCollapsedCondition(tree.widget));

    bot.sleep(1000);

    tree.expand();
    bot.waitUntil(new TreeExpandedCondition(tree.widget));

    if (!waitUntilTreeHasTextImpl(bot, tree.widget)) {
      printTree(tree.widget);
      throw new TimeoutException(
          "Timed out waiting for text of the tree's children, giving up...");
    }
  }
}
 
Example #2
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the table item matching the given row number.
 *
 * @param row the row number.
 * @return the table item with the specified row.
 * @throws WidgetNotFoundException if the node was not found.
 * @since 2.0
 */
public SWTBotTableItem getTableItem(final int row) throws WidgetNotFoundException {
	try {
		new SWTBot().waitUntil(new DefaultCondition() {
			public String getFailureMessage() {
				return "Could not find table item for row " + row; //$NON-NLS-1$
			}

			public boolean test() throws Exception {
				return getItem(row) != null;
			}
		});
	} catch (TimeoutException e) {
		throw new WidgetNotFoundException("Timed out waiting for table item in row " + row, e); //$NON-NLS-1$
	}
	return new SWTBotTableItem(getItem(row));
}
 
Example #3
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the table item matching the given name.
 *
 * @param itemText the text on the node.
 * @return the table item with the specified text.
 * @throws WidgetNotFoundException if the node was not found.
 * @since 1.3
 */
public SWTBotTableItem getTableItem(final String itemText) throws WidgetNotFoundException {
	try {
		new SWTBot().waitUntil(new DefaultCondition() {
			public String getFailureMessage() {
				return "Could not find node with text " + itemText; //$NON-NLS-1$
			}

			public boolean test() throws Exception {
				return getItem(itemText) != null;
			}
		});
	} catch (TimeoutException e) {
		throw new WidgetNotFoundException("Timed out waiting for table item " + itemText, e); //$NON-NLS-1$
	}
	return new SWTBotTableItem(getItem(itemText));
}
 
Example #4
Source File: WidgetUtil.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
public static SWTBotTreeItem getTreeItemWithRegex(
    final SWTBotTree tree, final String... regexNodes) {

  try {
    new SWTBot()
        .waitUntil(
            new DefaultCondition() {
              @Override
              public String getFailureMessage() {
                return "Could not find node matching " + Arrays.asList(regexNodes);
              }

              @Override
              public boolean test() throws Exception {
                return getTreeItem(tree.getAllItems(), regexNodes) != null;
              }
            });
    return getTreeItem(tree.getAllItems(), regexNodes);

  } catch (TimeoutException e) {
    throw new WidgetNotFoundException(
        "Timed out waiting for tree item matching " + Arrays.asList(regexNodes),
        e); //$NON-NLS-1$
  }
}
 
Example #5
Source File: WidgetUtil.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
public static SWTBotToolbarButton getToolbarButtonWithRegex(
    final SWTBotView view, final String regex) {

  try {
    new SWTBot()
        .waitUntil(
            new DefaultCondition() {
              @Override
              public String getFailureMessage() {
                return "Could not find toolbar button matching " + regex;
              }

              @Override
              public boolean test() throws Exception {
                return getToolbarButton(view, regex) != null;
              }
            });
    return getToolbarButton(view, regex);

  } catch (TimeoutException e) {
    throw new WidgetNotFoundException(
        "Timed out waiting for toolbar button matching " + regex, e); // $NON-NLS-1$
  }
}
 
Example #6
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 #7
Source File: SwtBotTreeActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Blocks the caller until the tree item has the given item text.
 *
 * @param tree the tree item to search
 * @param nodeText the item text to look for
 * @throws org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException if the item could not
 *         be found within the timeout period
 */
private static void waitUntilTreeItemHasItem(SWTBot bot, final SWTBotTreeItem tree,
    final String nodeText) {

  // Attempt #1
  if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
    // Attempt #2: Something went wrong, try to cautiously reopen it.
    bot.sleep(1000);

    // There isn't a method to collapse, so double-click instead
    tree.doubleClick();
    bot.waitUntil(new TreeCollapsedCondition(tree.widget));

    bot.sleep(1000);

    tree.expand();
    bot.waitUntil(new TreeExpandedCondition(tree.widget));

    if (!waitUntilTreeHasItemImpl(bot, tree.widget, nodeText)) {
      printTree(tree.widget);
      throw new TimeoutException(
          String.format("Timed out waiting for %s, giving up...", nodeText));
    }
  }
}
 
Example #8
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 #9
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 #10
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Waits until the node collapses.
 *
 * @param bot
 *          bot to work with, must not be {@code null}
 * @param node
 *          node to wait for, must not be {@code null}
 */
public static void safeBlockingCollapse(final SWTWorkbenchBot bot, final SWTBotTreeItem node) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(node, ARGUMENT_NODE);
  if (node.isExpanded()) {
    node.collapse();
    try {
      bot.waitUntil(new DefaultCondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
          return !node.isExpanded();
        }

        @Override
        public String getFailureMessage() {
          return "Timeout for node to collapse";
        }
      }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND);
    } catch (TimeoutException e) {
      // Try one last time and do not wait anymore
      node.collapse();
    }
  }
}
 
Example #11
Source File: SwtBotAppEngineActions.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/** Import a Maven project from a zip file. */
public static IProject importMavenProject(
    SWTWorkbenchBot bot, String projectName, File extractedLocation) {

  openImportProjectsWizard(bot, "Maven", "Existing Maven Projects");
  bot.button("Next >").click();

  bot.comboBoxWithLabel("Root Directory:").setText(extractedLocation.getAbsolutePath());
  bot.button("Refresh").click();

  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 #12
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the tree item from a parent tree item at the specified location
 *
 * @param bot
 *            the SWTBot
 * @param treeItem
 *            the treeItem to find the tree item under
 * @param nodeNames
 *            the path to the tree item, in the form of node names (from
 *            parent to child).
 * @return the tree item
 */
public static SWTBotTreeItem getTreeItem(SWTBot bot, SWTBotTreeItem treeItem, String... nodeNames) {
    if (nodeNames.length == 0) {
        return treeItem;
    }

    SWTBotTreeItem currentNode = treeItem;
    for (int i = 0; i < nodeNames.length; i++) {
        bot.waitUntil(ConditionHelpers.treeItemHasChildren(treeItem));
        currentNode.expand();

        String nodeName = nodeNames[i];
        try {
            bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(nodeName, currentNode));
        } catch (TimeoutException e) {
            // FIXME: Sometimes in a JFace TreeViewer, it expands to
            // nothing. Need to find out why.
            currentNode.collapse();
            currentNode.expand();
            bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(nodeName, currentNode));
        }

        SWTBotTreeItem newNode = currentNode.getNode(nodeName);
        currentNode = newNode;
    }

    return currentNode;
}
 
Example #13
Source File: StandardImportAndReadSmokeTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create a temporary archive from the specified resource.
 */
private static String createArchive(IResource sourceResource) throws URISyntaxException {
    IPath exportedPath = sourceResource.getFullPath();

    SWTBotTreeItem traceFilesProject = SWTBotUtils.selectProject(fBot, TRACE_PROJECT_NAME);
    traceFilesProject.contextMenu("Export...").click();

    SWTBotShell activeShell = fBot.shell("Export").activate();
    SWTBotTree exportWizardsTree = fBot.tree();
    SWTBotTreeItem treeItem = SWTBotUtils.getTreeItem(fBot, exportWizardsTree, "General", "Archive File");
    treeItem.select();
    fBot.button("Next >").click();
    fBot.button("&Deselect All").click();
    try {
        String resolveLinkedResLabel = "Resolve and export linked resources";
        fBot.waitUntil(Conditions.waitForWidget(withMnemonic(resolveLinkedResLabel)), 100);
        fBot.checkBox(resolveLinkedResLabel).select();
    } catch (TimeoutException e) {
        // Ignore, doesn't exist pre-4.6M5
    }

    if (sourceResource instanceof IFile) {
        String[] folderPath = exportedPath.removeLastSegments(1).segments();
        String fileName = exportedPath.lastSegment();
        SWTBotImportWizardUtils.selectFile(fBot, fileName, folderPath);
    } else {
        selectFolder(exportedPath.segments());
    }

    String workspacePath = URIUtil.toFile(URIUtil.fromString(System.getProperty("osgi.instance.area"))).getAbsolutePath();
    final String archiveDestinationPath = workspacePath + File.separator + TRACE_PROJECT_NAME + File.separator + GENERATED_ARCHIVE_NAME;
    fBot.comboBox().setText(archiveDestinationPath);
    fBot.button("&Finish").click();
    fBot.waitUntil(Conditions.shellCloses(activeShell), IMPORT_TIME_OUT);
    return archiveDestinationPath;
}
 
Example #14
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Waits until the node expands.
 *
 * @param bot
 *          bot to work with, must not be {@code null}
 * @param node
 *          node to wait for, must not be {@code null}
 */
public static void safeBlockingExpand(final SWTWorkbenchBot bot, final SWTBotTreeItem node) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(node, ARGUMENT_NODE);
  if (!node.isExpanded()) {
    node.expand();
    try {
      bot.waitUntil(new DefaultCondition() {

        @Override
        @SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
        public boolean test() {
          return node.isExpanded();
        }

        @Override
        public String getFailureMessage() {
          return "Timeout for node to expand";
        }
      }, TIMEOUT_FOR_NODE_TO_COLLAPSE_EXPAND);

    } catch (TimeoutException e) {
      // Try one last time and do not wait anymore
      node.expand();
    }
  }
}
 
Example #15
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 #16
Source File: SwtWorkbenchBot.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void waitUntilWidgetAppears(final ICondition waitForWidget) {
  try {
    waitUntil(waitForWidget, SHORT_TIME_OUT, SHORT_INTERVAL);
  } catch (TimeoutException e) {
    throw new WidgetNotFoundException("Could not find widget.", e); //$NON-NLS-1$
  }
}
 
Example #17
Source File: SWTGefBotRule.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void closeAllShells(SWTWorkbenchBot bot, Exception e) {
    final SWTBotShell[] shells = bot.shells();
    for (final SWTBotShell shell : shells) {
        if (shell.isOpen() && !isEclipseShell(shell)) {
            System.out.println(String.format("Trying to close shell '%s' after test failure %s", shell.getText(), e));
            try {
                shell.close();
            } catch (TimeoutException e1) {
                System.out.println(String.format("Failed to close shell %s: %s", shell.getText(), e1));
            }
        }
    }
}
 
Example #18
Source File: SwtBotAppEngineActions.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Use the Eclipse general import project wizard to import an existing project from a
 * location.
 */
public static IProject importNativeProject(SWTWorkbenchBot bot, String projectName,
    File extractedLocation) {

  openImportProjectsWizard(bot, "General", "Existing Projects into Workspace");
  bot.button("Next >").click();

  // current comboBox is associated with a radio button
  // with "Select root directory:"
  bot.comboBox().setText(extractedLocation.getAbsolutePath());
  bot.button("Refresh").click();

  // 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 #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: NetworkManipulatorImpl.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void synchronizeOnActivityQueue(JID jid, long timeout) throws RemoteException {

  ISarosSession session = this.session;
  IActivityListener listener = this.listener;

  // this is too lazy, but ok for testing purposes

  if (session == null) throw new IllegalStateException("no session running");

  if (listener == null) throw new IllegalStateException("no session running");

  final CountDownLatch swtThreadSync = new CountDownLatch(1);

  UIThreadRunnable.asyncExec(
      new VoidResult() {
        @Override
        public void run() {
          swtThreadSync.countDown();
        }
      });

  try {
    if (!swtThreadSync.await(
        SarosSWTBotPreferences.SAROS_DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)) {
      log.warn("could not synchronize on the SWT EDT");
    }
  } catch (InterruptedException e1) {
    Thread.currentThread().interrupt();
  }

  int id = RANDOM.nextInt();

  NOPActivity activity = new NOPActivity(session.getLocalUser(), session.getUser(jid), id);

  CountDownLatch latch = new CountDownLatch(1);

  synchronizeRequests.put(id, latch);
  listener.created(activity);

  try {
    if (!latch.await(timeout, TimeUnit.MILLISECONDS))
      throw new TimeoutException("no reply from " + jid);
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  } finally {
    synchronizeRequests.remove(id);
  }
}
 
Example #21
Source File: CreatingNewFileTest.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testCreatingNewFileTest() throws Exception {

  CARL.superBot().internal().createProject("foo");

  Util.buildSessionConcurrently("foo", TypeOfCreateProject.NEW_PROJECT, CARL, ALICE, BOB);

  ALICE.superBot().views().packageExplorerView().waitUntilResourceIsShared("foo");
  BOB.superBot().views().packageExplorerView().waitUntilResourceIsShared("foo");

  CARL.superBot().internal().createFile("foo", "readme.txt", "this is a test case");

  ALICE.superBot().views().packageExplorerView().waitUntilResourceIsShared("foo/readme.txt");
  BOB.superBot().views().packageExplorerView().waitUntilResourceIsShared("foo/readme.txt");

  CARL.superBot().views().sarosView().selectUser(ALICE.getJID()).restrictToReadOnlyAccess();

  CARL.superBot().views().sarosView().selectUser(ALICE.getJID()).waitUntilHasReadOnlyAccess();

  // Lin's fault not mine !

  // BOB.superBot().views().sarosView().selectParticipant(ALICE.getJID()).waitUntilHasReadOnlyAccess();

  // ALICE.superBot().views().sarosView().selectParticipant(ALICE.getJID()).waitUntilHasReadOnlyAccess();

  CARL.superBot().views().sarosView().selectUser(ALICE.getJID()).followParticipant();
  BOB.superBot().views().sarosView().selectUser(ALICE.getJID()).followParticipant();

  assertTrue(CARL.superBot().views().sarosView().isFollowing());
  assertTrue(BOB.superBot().views().sarosView().isFollowing());

  ALICE.superBot().internal().createFile("foo", "bar/readme.txt", "not visible");

  ALICE.superBot().views().packageExplorerView().selectFile("foo", "bar", "readme.txt").open();

  ALICE.remoteBot().editor("readme.txt").waitUntilIsActive();
  ALICE
      .remoteBot()
      .editor("readme.txt")
      .typeText(
          "eene meene miste es rappelt in der kiste, eene meene meck und du bist weck ! weck bist du noch lange nicht ...");

  assertFalse("Carls editor must not be opened", CARL.remoteBot().isEditorOpen("readme.txt"));
  assertFalse("Bobs editor must not be opened", BOB.remoteBot().isEditorOpen("readme.txt"));

  assertFalse(
      "Alices created file must not be marked as shared (CARL)",
      CARL.superBot().views().packageExplorerView().isResourceShared("foo/bar/readme.txt"));

  assertFalse(
      "Alices created file must not be marked as shared (BOB)",
      BOB.superBot().views().packageExplorerView().isResourceShared("foo/bar/readme.txt"));

  assertEquals(
      "Alice had changed a file during read only access while typing",
      ALICE.remoteBot().editor("readme.txt").getText(),
      "not visible");

  try {
    ALICE.superBot().views().sarosView().waitUntilIsInconsistencyDetected();
  } catch (TimeoutException e) {
    fail("ALICE should have received an inconsistency warning, " + e.getMessage());
  }
}
 
Example #22
Source File: EditDuringNonHostInvitationTest.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Test
@Ignore("Non-Host Invitation is currently deactivated")
public void testEditDuringInvitationNonHostInvites() throws Exception {

  Util.setUpSessionWithJavaProjectAndClass(
      Constants.PROJECT1, Constants.PKG1, Constants.CLS1, ALICE, BOB);

  BOB.superBot()
      .views()
      .packageExplorerView()
      .waitUntilClassExists(Constants.PROJECT1, Constants.PKG1, Constants.CLS1);

  BOB.superBot().views().sarosView().selectContact(CARL.getJID()).addToSarosSession();

  ALICE
      .superBot()
      .views()
      .packageExplorerView()
      .selectClass(Constants.PROJECT1, Constants.PKG1, Constants.CLS1)
      .open();

  CARL.remoteBot().shell(SHELL_SESSION_INVITATION).confirm(ACCEPT);

  aliceIsWriting =
      createTestThread(
          new EclipseTestThread.Runnable() {

            @Override
            public void run() throws Exception {
              for (int i = 0; i < 20; i++)
                ALICE.remoteBot().editor(Constants.CLS1_SUFFIX).typeText("FooBar");
            }
          });

  aliceIsWriting.start();

  CARL.superBot().confirmShellAddProjectWithNewProject(Constants.PROJECT1);

  aliceIsWriting.join();
  aliceIsWriting.verify();

  CARL.superBot()
      .views()
      .packageExplorerView()
      .waitUntilClassExists(Constants.PROJECT1, Constants.PKG1, Constants.CLS1);

  CARL.superBot()
      .views()
      .packageExplorerView()
      .selectClass(Constants.PROJECT1, Constants.PKG1, Constants.CLS1)
      .open();

  BOB.superBot()
      .views()
      .packageExplorerView()
      .selectClass(Constants.PROJECT1, Constants.PKG1, Constants.CLS1)
      .open();

  String textByBob = BOB.remoteBot().editor(Constants.CLS1_SUFFIX).getText();

  ALICE.remoteBot().editor(Constants.CLS1_SUFFIX).waitUntilIsTextSame(textByBob);

  String textByAlice = ALICE.remoteBot().editor(Constants.CLS1_SUFFIX).getText();

  try {
    CARL.remoteBot().editor(Constants.CLS1_SUFFIX).waitUntilIsTextSame(textByBob);
  } catch (TimeoutException e) {
    //
  }
  String textByCarl = CARL.remoteBot().editor(Constants.CLS1_SUFFIX).getText();

  assertEquals(textByBob, textByAlice);
  assertEquals(textByBob, textByCarl);
}
 
Example #23
Source File: EditDuringInvitationTest.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testEditDuringInvitation() throws Exception {

  Util.setUpSessionWithJavaProjectAndClass(
      Constants.PROJECT1, Constants.PKG1, Constants.CLS1, ALICE, BOB);

  BOB.superBot()
      .views()
      .packageExplorerView()
      .waitUntilClassExists(Constants.PROJECT1, Constants.PKG1, Constants.CLS1);

  ALICE.superBot().views().sarosView().selectContact(CARL.getJID()).addToSarosSession();

  BOB.superBot()
      .views()
      .packageExplorerView()
      .selectClass(Constants.PROJECT1, Constants.PKG1, Constants.CLS1)
      .open();

  CARL.remoteBot().shell(SHELL_SESSION_INVITATION).confirm(ACCEPT);

  EclipseTestThread bobIsWriting =
      createTestThread(
          new EclipseTestThread.Runnable() {

            @Override
            public void run() throws Exception {
              for (int i = 0; i < 20; i++)
                BOB.remoteBot().editor(Constants.CLS1_SUFFIX).typeText("FooBar");
            }
          });

  bobIsWriting.start();

  CARL.superBot().confirmShellAddProjectWithNewProject(Constants.PROJECT1);

  bobIsWriting.join();
  bobIsWriting.verify();

  String textByBob = BOB.remoteBot().editor(Constants.CLS1_SUFFIX).getText();

  CARL.superBot()
      .views()
      .packageExplorerView()
      .waitUntilClassExists(Constants.PROJECT1, Constants.PKG1, Constants.CLS1);

  CARL.superBot()
      .views()
      .packageExplorerView()
      .selectClass(Constants.PROJECT1, Constants.PKG1, Constants.CLS1)
      .open();

  ALICE
      .superBot()
      .views()
      .packageExplorerView()
      .selectClass(Constants.PROJECT1, Constants.PKG1, Constants.CLS1)
      .open();

  ALICE.remoteBot().editor(Constants.CLS1_SUFFIX).waitUntilIsTextSame(textByBob);

  String textByAlice = ALICE.remoteBot().editor(Constants.CLS1_SUFFIX).getText();

  // There are bugs here, CARL get completely different content as BOB.
  try {
    CARL.remoteBot().editor(Constants.CLS1_SUFFIX).waitUntilIsTextSame(textByBob);
  } catch (TimeoutException e) {
    //
  }
  String textByCarl = CARL.remoteBot().editor(Constants.CLS1_SUFFIX).getText();

  assertEquals(textByBob, textByAlice);
  assertEquals(textByBob, textByCarl);
}