Java 类org.eclipse.swtbot.swt.finder.SWTBot 实例源码

项目:gw4e.project    文件:OutLineView.java   
public ICondition createTreeRowCountCondition (final int count) {
    return new ICondition () {
        @Override
        public boolean test() throws Exception {
            return  geVisibleRowCount () == count;
        }

        @Override
        public void init(SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Expected row coutn not found ";
        }

    };
}
项目:gw4e.project    文件:ToolBarEditor.java   
public void copy(ICondition condition) {
    CopyAction button = new CopyAction();
    button.click();
    editor.click(50, 50);
    if (condition == null) {
        condition = new org.eclipse.swtbot.swt.finder.waits.ICondition() {
            @Override
            public boolean test() throws Exception {
                PasteAction button = new PasteAction();
                return button.isEnabled();
            }

            @Override
            public void init(SWTBot bot) {
            }

            @Override
            public String getFailureMessage() {
                return "Paste button not enabled";
            }

        };
    }
    bot.waitUntil(condition);
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
/**
 * Given a tree that contains an entry with <code>itemName</code> and a direct child with a name
 * matching <code>subchildName</code>, return its tree item.
 *
 * This method is useful when there is the possibility of a tree having two similarly-named
 * top-level nodes.
 *
 * @param mainTree the tree
 * @param itemName the name of a top-level node in the tree
 * @param subchildName the name of a direct child of the top-level node (used to uniquely select
 *        the appropriate tree item for the given top-level node name)
 * @return the tree item corresponding to the top-level node with <code>itemName</code>that has a
 *         direct child with <code>subchildName</code>. If there are multiple tree items that
 *         satisfy this criteria, then the first one (in the UI) will be returned
 *
 * @throws WidgetNotFoundException if no such node can be found
 */
public static SWTBotTreeItem getUniqueTreeItem(final SWTBot bot, final SWTBotTree mainTree,
    String itemName, String subchildName) {
  for (SWTBotTreeItem item : mainTree.getAllItems()) {
    if (itemName.equals(item.getText())) {
      try {
        item.expand();
        waitUntilTreeHasText(bot, item);
        if (item.getNode(subchildName) != null) {
          return item;
        }
      } catch (WidgetNotFoundException ex) {
        // Ignore
      }
    }
  }

  throw new WidgetNotFoundException(
      "The " + itemName + " node with a child of " + subchildName + " must exist in the tree.");
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
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 ex) {
    return false;
  }

  return true;
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
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 treeItemHasText(tree);
      }
    });
  } catch (TimeoutException ex) {
    return false;
  }

  return true;
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
/**
 * 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));
    }
  }
}
项目:dsl-devkit    文件:CoreSwtbotTools.java   
/**
 * Takes a screenshot.
 *
 * @param bot
 *          the {@link SWTBot} factory instance to use, must not be {@code null}
 * @param prefix
 *          base name of file, may be {@code null} only if useCaller is {@code true}
 * @param useCaller
 *          if {@code true}, append the name of the calling method to the prefix
 */
public static void captureScreenshot(final SWTBot bot, final String prefix, final boolean useCaller) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  if (prefix == null && !useCaller) {
    throw new IllegalArgumentException();
  }
  final StringBuilder sBuilder = new StringBuilder("screenshots/");
  if (prefix != null) {
    sBuilder.append(prefix);
  }
  if (useCaller) {
    sBuilder.append(Reflect.getCallingMethod());
  }
  sBuilder.append(".jpeg");
  bot.captureScreenshot(sBuilder.toString());
}
项目:dsl-devkit    文件:CoreSwtbotTools.java   
/**
 * Attempts to expand all nodes along the path specified by the node array parameter.
 * The method is copied from SWTBotTree with an additional check if the node is already expanded.
 *
 * @param bot
 *          tree bot, must not be {@code null}
 * @param nodes
 *          node path to expand, must not be {@code null} or empty
 * @return the last tree item that was expanded, or {@code null} if no item was found
 */
public static SWTBotTreeItem expandNode(final SWTBotTree bot, final String... nodes) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(nodes, ARGUMENT_NODES);
  assertArgumentIsNotEmpty(nodes, ARGUMENT_NODES);
  new SWTBot().waitUntil(widgetIsEnabled(bot));
  SWTBotTreeItem item = bot.getTreeItem(nodes[0]);
  if (!item.isExpanded()) {
    item.expand();
  }

  final List<String> asList = new ArrayList<String>(Arrays.asList(nodes));
  asList.remove(0);
  if (!asList.isEmpty()) {
    item = expandNode(item, asList.toArray(new String[asList.size()]));
  }

  return item;
}
项目:eavp    文件:AbstractSWTTester.java   
@Override
public void beforeAllTests() {
    super.beforeAllTests();

    final Display display = getDisplay();
    // Creating the shell must be done on the UI thread.
    display.syncExec(new Runnable() {
        @Override
        public void run() {
            // Create and open the shell.
            shell = new Shell(display);
            shell.setLayout(new FillLayout());
            shell.open();
        }
    });

    // Initialize static or otherwise shared resources here.

    // Set up the SWTBot for the shell.
    bot = new SWTBot(shell);

    return;
}
项目:eavp    文件:AbstractSWTTester.java   
@Override
public void beforeAllTests() {
    super.beforeAllTests();

    final Display display = getDisplay();
    // Creating the shell must be done on the UI thread.
    display.syncExec(new Runnable() {
        @Override
        public void run() {
            // Create and open the shell.
            shell = new Shell(display);
            shell.setLayout(new FillLayout());
            shell.open();
        }
    });

    // Initialize static or otherwise shared resources here.

    // Set up the SWTBot for the shell.
    bot = new SWTBot(shell);

    return;
}
项目:gwt-eclipse-plugin    文件:SwtBotLaunchManagerActions.java   
public static void terminateAllLaunchConfigs(SWTBot bot) {
  SwtBotUtils.print("Terminating Launches");

  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  ILaunch[] launches = manager.getLaunches();
  if (launches == null || launches.length == 0) {
    SwtBotUtils.print("No Launches to terminate");
  }

  for (ILaunch launch : launches) {
    if (!launch.isTerminated()) {
      try {
        launch.terminate();
      } catch (DebugException e) {
        SwtBotUtils.printError("Could not terminate launch." + e.getMessage());
      }
    }
  }

  SwtBotWorkbenchActions.waitForIdle(bot);

  SwtBotUtils.print("Terminated Launches");
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
/**
 * Given a tree that contains an entry with <code>itemName</code> and a direct child with a name
 * matching <code>subchildName</code>, return its tree item.
 *
 * This method is useful when there is the possibility of a tree having two similarly-named
 * top-level nodes.
 *
 * @param mainTree the tree
 * @param itemName the name of a top-level node in the tree
 * @param subchildName the name of a direct child of the top-level node (used to uniquely select
 *        the appropriate tree item for the given top-level node name)
 * @return the tree item corresponding to the top-level node with <code>itemName</code>that has a
 *         direct child with <code>subchildName</code>. If there are multiple tree items that
 *         satisfy this criteria, then the first one (in the UI) will be returned
 *
 * @throws IllegalStateException if no such node can be found
 */
public static SWTBotTreeItem getUniqueTreeItem(final SWTBot bot, final SWTBotTree mainTree,
    String itemName, String subchildName) {
  for (SWTBotTreeItem item : mainTree.getAllItems()) {
    if (itemName.equals(item.getText())) {
      try {
        item.expand();
        SwtBotTreeActions.waitUntilTreeHasText(bot, item);
        if (item.getNode(subchildName) != null) {
          return item;
        }
      } catch (WidgetNotFoundException e) {
        // Ignore
      }
    }
  }

  throw new IllegalStateException("The '" + itemName + "' node with a child of '" + subchildName
      + "' must exist in the tree.");
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
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;
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
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;
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
/**
 * 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));
    }
  }
}
项目:gwt-eclipse-plugin    文件:SwtBotTreeActions.java   
/**
 * 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...");
    }
  }
}
项目:syncope    文件:SyncopeViewTest.java   
@Test
public void canLoginAdmin() throws Exception {
    SWTBotShell loginShell = BOT.activeShell();
    loginShell.activate();
    BOT.textWithLabel("Deployment Url").setText(ADDRESS);
    BOT.textWithLabel("Username").setText(ADMIN_UNAME);
    BOT.textWithLabel("Password").setText(ADMIN_PWD);
    BOT.button("Login").click();
    BOT.waitWhile(new ICondition() {

        @Override
        public boolean test() throws Exception {
            String title = BOT.activeShell().getText();
            return title.equals("Loading Templates");
        }

        @Override
        public void init(final SWTBot bot) {
        }

        @Override
        public String getFailureMessage() {
            return "Unable to Login";
        }
    });
}
项目:gw4e.project    文件:GraphModelProperties.java   
public GraphModelProperties(SWTBot bot, String project, String folder,String pkg,  String filename) {
    super();
    this.bot = bot;
    this.project = project;
    this.folder = folder;
    this.pkg = pkg;
    this.filename = filename;
    bot.tree().setFocus();

    bot.tree().select("GW4E");
    bot.waitUntil(Conditions.waitForWidget(WidgetMatcherFactory.withId(GraphModelPropertyPage.GW4E_LABEL_ID, GraphModelPropertyPage.GW4E_LABEL_ID)));
}
项目:google-cloud-eclipse    文件:SwtBotWorkbenchActions.java   
/**
 * Wait until all background tasks are complete.
 */
public static void waitForProjects(final SWTBot bot, IProject... projects) {
  Runnable delayTactic = new Runnable() {
    @Override
    public void run() {
      bot.sleep(300);
    }
  };
  ProjectUtils.waitForProjects(delayTactic, projects);
}
项目:google-cloud-eclipse    文件:SwtBotWorkbenchActions.java   
private static void openPreferencesDialogViaEvents(SWTBot bot) {
  Display display = bot.getDisplay();
  Event event = new Event();

  // Move to the "Apple" menu item (it catches 0, 0)
  event.type = SWT.MouseMove;
  event.x = 0;
  event.y = 0;
  display.post(event);

  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Click
  event.type = SWT.MouseDown;
  event.button = 1;
  display.post(event);
  bot.sleep(SwtBotTestingUtilities.EVENT_DOWN_UP_DELAY_MS);
  event.type = SWT.MouseUp;
  display.post(event);

  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Right to the "Eclipse" menu item
  SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_RIGHT, '\0');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Down two to the "Preferences..." menu item
  SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  SwtBotTestingUtilities.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Press enter
  SwtBotTestingUtilities.sendKeyDownAndUp(bot, 0, '\r');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
}
项目:google-cloud-eclipse    文件:SwtBotTreeUtilities.java   
/**
 * 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.
 * 
 * @param tree the tree to search
 * @throws TimeoutException if any 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 {
  // TODO: Refactor some of this logic; it follows the same general pattern as
  // {@link #waitUntilTreeItemHasItem(SWTBot, SWTBotTreeItem, String)}.

  // 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...");
    }
  }
}
项目:google-cloud-eclipse    文件:SwtBotTestingUtilities.java   
/** Click the button, wait for the window change. */
public static void clickButtonAndWaitForWindowChange(SWTBot bot, final SWTBotButton button) {
  performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      button.click();
    }
  });
}
项目:google-cloud-eclipse    文件:SwtBotTestingUtilities.java   
/** Click the button, wait for the window close. */
public static void clickButtonAndWaitForWindowClose(SWTBot bot, final SWTBotButton button) {
  performAndWaitForWindowClose(bot, new Runnable() {
    @Override
    public void run() {
      button.click();
    }
  });
}
项目:google-cloud-eclipse    文件:SwtBotTestingUtilities.java   
/**
 * Injects a key or character via down and up events. Only one of {@code keyCode} or
 * {@code character} must be provided. Use
 * 
 * @param keyCode the keycode of the key (use {@code 0} if unspecified)
 * @param character the character to press (use {@code '\0'} if unspecified)
 */
public static void sendKeyDownAndUp(SWTBot bot, int keyCode, char character) {
  Event ev = new Event();
  ev.keyCode = keyCode;
  ev.character = character;
  ev.type = SWT.KeyDown;
  bot.getDisplay().post(ev);
  bot.sleep(EVENT_DOWN_UP_DELAY_MS);
  ev.type = SWT.KeyUp;
  bot.getDisplay().post(ev);
}
项目:google-cloud-eclipse    文件:SwtBotTestingUtilities.java   
/**
 * 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();
    }
  });
}
项目:google-cloud-eclipse    文件:SwtBotTestingUtilities.java   
/**
 * Blocks the caller until the given shell is closed.
 */
public static void waitUntilShellIsClosed(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.isOpen();
    }
  });
}
项目:google-cloud-eclipse    文件:SwtBotTestingUtilities.java   
/**
 * Wait until the given text widget contains the provided string
 */
public static void waitUntilStyledTextContains(SWTBot bot, final String text,
    final SWTBotStyledText widget) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public boolean test() throws Exception {
      return widget.getText().contains(text);
    }

    @Override
    public String getFailureMessage() {
      return "Text not found!";
    }
  });
}
项目:google-cloud-eclipse    文件:SwtBotAppEngineActions.java   
/**
 * Spin until the given project actually exists and is facetd.
 *
 * @return the project
 */
private static IProject waitUntilFacetedProjectExists(SWTBot bot, final IProject project) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public String getFailureMessage() {
      return "Project does not exist! " + project;
    }

    @Override
    public boolean test() throws Exception {
      return project.exists() && FacetedProjectFramework.isFacetedProject(project);
    }
  });
  return project;
}
项目:eavp    文件:ComboDialogTester.java   
/**
 * Creates an SWTBot for the dialog's shell, not for the test shell.
 */
@Override
protected SWTBot getBot() {
    // Get the shell for the dialog, then return its associated bot.
    for (SWTBotShell shell : super.getBot().shells()) {
        if (shell.widget == dialog.getShell()) {
            return shell.bot();
        }
    }
    return null;
}
项目:gwt-eclipse-plugin    文件:SwtBotWorkbenchActions.java   
/**
 * Wait until all background tasks are complete.
 */
public static void waitForIdle(SWTBot bot) {
  SwtBotUtils.print("\t\tWaiting for idle");
  while (!Job.getJobManager().isIdle()) {
    bot.sleep(500);
  }
  SwtBotUtils.print("\t\tNow idle");
}
项目:gwt-eclipse-plugin    文件:SwtBotWorkbenchActions.java   
private static void openPreferencesDialogViaEvents(SWTBot bot) {
  Display display = bot.getDisplay();
  Event ev = new Event();

  // Move to the "Apple" menu item (it catches 0, 0)
  ev.type = SWT.MouseMove;
  ev.x = 0;
  ev.y = 0;
  display.post(ev);

  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Click
  ev.type = SWT.MouseDown;
  ev.button = 1;
  display.post(ev);
  bot.sleep(SwtBotUtils.EVENT_DOWN_UP_DELAY_MS);
  ev.type = SWT.MouseUp;
  display.post(ev);

  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Right to the "Eclipse" menu item
  SwtBotUtils.sendKeyDownAndUp(bot, SWT.ARROW_RIGHT, '\0');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Down two to the "Preferences..." menu item
  SwtBotUtils.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  SwtBotUtils.sendKeyDownAndUp(bot, SWT.ARROW_DOWN, '\0');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);

  // Press enter
  SwtBotUtils.sendKeyDownAndUp(bot, 0, '\r');
  bot.sleep(OPEN_PREFERENCES_DIALOG_DELAY_MS);
}
项目:gwt-eclipse-plugin    文件:SwtBotUtils.java   
public static void clickButtonAndWaitForWindowChange(SWTBot bot, final SWTBotButton button) {
  performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      button.click();
    }
  });
}
项目:gwt-eclipse-plugin    文件:SwtBotUtils.java   
/**
 * Injects a key or character via down and up events.
 *
 * @param keyCode the keycode of the key (only this or character have to be provided.)
 * @param character the character to press (only this or keyCode have to be provided.)
 */
public static void sendKeyDownAndUp(SWTBot bot, int keyCode, char character) {
  Event ev = new Event();
  ev.keyCode = keyCode;
  ev.character = character;
  ev.type = SWT.KeyDown;
  bot.getDisplay().post(ev);
  bot.sleep(EVENT_DOWN_UP_DELAY_MS);
  ev.type = SWT.KeyUp;
  bot.getDisplay().post(ev);
}
项目:gwt-eclipse-plugin    文件:SwtBotUtils.java   
/**
 * 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();
    }
  });
}
项目:gwt-eclipse-plugin    文件:SwtBotMenuActions.java   
/**
 * Opens the Debug Configurations... perspective.
 */
public static void openDebugConfiguration(final SWTBot bot) {
  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      // Be sure the main window has focus
      setFocusMainShell(bot);

      bot.menu("Run").menu("Debug Configurations...").click();
    }
  });

  bot.activeShell().setFocus();
}
项目:gwt-eclipse-plugin    文件:SwtBotMenuActions.java   
/**
 * Opens a resource using the Open Resource dialog.
 */
public static void openResource(final SWTBot bot, String fileName) {
  SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
    @Override
    public void run() {
      bot.menu("Navigate").menu("Open Resource").click();
    }
  });

  bot.text().typeText(fileName);
  SwtBotUtils.clickButtonAndWaitForWindowChange(bot, bot.button("Open"));
}
项目:fullsync    文件:ProfileDialogTest.java   
@Test
public void testCreateProfile() {
    bot.menu("File").menu("New Profile").click();
    SWTBot profile = bot.shell("Profile").bot();
    assertTrue("Profile Dialog opens with General Tab selected", profile.tabItem("General").isActive());
    profile.text(0).setText("SWTBot Profile 1");
    profile.text(1).setText("Description");
    profile.button("Ok").click();
}
项目:fullsync    文件:GUITestBase.java   
@Before
public void setUpBefore() throws Exception {
    tempConfigDir = new TemporaryFolder();
    tempConfigDir.create();
    System.setProperty("net.sourceforge.fullsync.configDir", tempConfigDir.getRoot().toString());
    System.setProperty("net.sourceforge.fullsync.skipExit", "true");
    System.setProperty("net.sourceforge.fullsync.skipHelp", "true");
    System.setProperty("net.sourceforge.fullsync.skipWelcomeScreen", "true");

    applicationThread = new Thread(() -> Main.main(new String[] { "-v" }));
    applicationThread.setName("FullSync GUI");
    applicationThread.start();
    assertTrue("GUI startup failed, Display not found", null != waitForDisplayToAppear(GUI_STARTUP_TIMEOUT));
    bot = new SWTBot();
}
项目:gw4e.project    文件:ToolbarTest.java   
@Override
public void init(SWTBot bot) {
}