Java Code Examples for org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot#sleep()

The following examples show how to use org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot#sleep() . 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: GuiUtils.java    From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * You MUST navigate to the correct preferences page, or the method fails and
 * possibly throws widget not found exception. Sets The CodeChecker Directory on
 * the preferences pages.
 * 
 * @param method
 *            The associated radio button to the {@link ResolutionMethodTypes}
 *            will be clicked on the preferences/properties page.
 * @param ccDir
 *            Path to the CodeChecker Root directory.
 * @param bot
 *            The bot to be guided.
 * @param root
 *            TODO
 */
public static void setCCBinDir(ResolutionMethodTypes method, Path ccDir, SWTWorkbenchBot bot, boolean root) {
    SWTBotRadio radio = null;
    switch (method) {
        case PATH:
            radio = bot.radio("Search in PATH");
            break;
        case PRE:
            radio = bot.radio("Pre built package");
            break;
        default:
            break;
    }
    radio.click();
    if (method != ResolutionMethodTypes.PATH || ccDir != null) {
        SWTBotText text = bot.textWithLabel(GuiUtils.CC_DIR_WIDGET);
        // if the given path is the package root, extend it to the concrete binary else
        // it could be used directly.
        text.setText(root ? ccDir.resolve(Paths.get(BIN, CODECHECKER)).toString() : ccDir.toString());
        bot.sleep(SHORT_WAIT_TIME);
    }
}
 
Example 2
Source File: SwtBotProjectHelper.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected static void fileNew(final SWTWorkbenchBot it, final String newWhat) {
  int retries = 3;
  ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, retries, true);
  for (final Integer i : _doubleDotLessThan) {
    try {
      it.menu("File").menu("New").menu(newWhat).click();
      return;
    } catch (final Throwable _t) {
      if (_t instanceof WidgetNotFoundException) {
        final WidgetNotFoundException e = (WidgetNotFoundException)_t;
        if (((i).intValue() == (retries - 1))) {
          throw e;
        }
        String _message = e.getMessage();
        String _plus = ("failed: " + _message);
        InputOutput.<String>println(_plus);
        InputOutput.<String>println("retrying...");
        it.sleep(1000);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
}
 
Example 3
Source File: SwtBotMenuActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void openNewMavenProject(SWTWorkbenchBot bot) {
  openNewOtherProjectDialog(bot);

  // filter maven options
  bot.text().setText("maven");
  bot.sleep(500);

  // click on Maven Project
  SWTBotTree tree = bot.tree();
  SWTBotTreeItem[] items = tree.getAllItems();
  SwtBotTreeActions.selectTreeItem(bot, items[0], "Maven Project");

  // move to next step
  bot.button("Next >").click();
}
 
Example 4
Source File: SwtBotProjectDebug.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Goto Debug As > "# MENU_GWT_SUPERDEVMODE"
 */
public static void launchDevModeWithJettyAndWaitForReady(SWTWorkbenchBot bot,
    String projectName) {
  SwtBotUtils.print("Launch DevMode with Jetty");

  // show it has focus
  SWTBotTreeItem project = SwtBotProjectActions.selectProject(bot, projectName);
  project.setFocus();
  project.select();
  project.doubleClick();

  // Since the menus have dynamic numbers in them
  // and with out a built in iteration, this is what I came up with
  for (int i = 1; i < 15; i++) {
    bot.sleep(500);
    if (i < 10) {
      number = i + " ";
    } else {
      number = "";
    }

    final String menuLabel = number + MENU_GWT_SUPERDEVMODE;

    SwtBotUtils.print("Trying to select: Run > Debug As > menuLabel=" + menuLabel);

    try {
      bot.menu("Run").menu("Debug As").menu(menuLabel).click();
      break;
    } catch (Exception e) {
      SwtBotUtils.print("Skipping menu item " + menuLabel);
    }
  }

  // Wait for a successful launch - 60s build server wait time, just in case
  ConsoleViewContains.waitForConsoleOutput(bot, "The code server is ready", 60000);

  SwtBotUtils.print("Launched DevMode with Jetty");
}
 
Example 5
Source File: SwtBotProjectActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static void deleteLaunchConfigs(final SWTWorkbenchBot bot) {
  SwtBotUtils.print("\tDeleting launch configs");

  SwtBotLaunchManagerActions.terminateAllLaunchConfigs(bot);

  SwtBotMenuActions.openDebugConfiguration(bot);

  // TODO change to Messages.get
  SWTBotTreeItem subTree = bot.tree(0).getTreeItem("GWT Development Mode (DevMode)");
  subTree.expand();

  SWTBotTreeItem[] items = subTree.getItems();
  if (items != null && items.length > 0) {
    for (int i=0; i < items.length; i++) {
      SwtBotUtils.print("\t\tDeleting launcher i=" + i);
      items[i].contextMenu("Delete").click();

      SwtBotUtils.performAndWaitForWindowChange(bot, new Runnable() {
        @Override
        public void run() {
          bot.button("Yes").click();
        }
      });

      bot.sleep(500);
    }
  }

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

  SwtBotUtils.print("\tDeleted launch configs");
}
 
Example 6
Source File: XsemanticsSwtbotTestBase.java    From xsemantics with Eclipse Public License 1.0 4 votes vote down vote up
@BeforeClass
	public static void beforeClass() throws Exception {
		PDETargetPlatformUtils.setTargetPlatform();
		
		bot = new SWTWorkbenchBot();
		
		closeWelcomePage();

		// Change the perspective via the Open Perspective dialog
		// Using the menus does not seem to be reliable, so we change
		// the perspective programmatically
//		SWTBotMenu windowMenu = bot.menu("Window");
//		SWTBotMenu openPerspectiveMenu = windowMenu.menu("Open Perspective");
//		SWTBotMenu otherMenu = openPerspectiveMenu.menu("Other...");
//		otherMenu.click();
//		SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
//		openPerspectiveShell.activate();
//
//		// select the dialog
//		bot.table().select("Plug-in Development");
//		bot.button("OK").click();
		openPluginPerspective();

		// in SwtBot 2.2.0 we must use part name since the title
		// of the problems view also contains the items count
		// see also http://www.eclipse.org/forums/index.php/t/640194/
		
		// Error Log view is disturbing since it often shows up
		// and gets the focus, breaking many of our tests, so it's crucial
		// to close it right away.
		// Unfortunately, before Luna, the Error Log view was enabled by
		// default in Plug-in Development perspective, but in Luna it is
		// there anymore.
		if (!isLuna()) {
			bot.viewByPartName("Error Log").close();
		}
		bot.viewByPartName("Problems").show();
		
		SWTBotShell activeShell = null;
		int retry = 0;
		System.out.println("Checking active shell...");
		while (activeShell == null) {
			try {
				activeShell = bot.activeShell();
			} catch (WidgetNotFoundException e) {
				System.out.println(e.getMessage());
				System.out.println("Retrying in 10 seconds...");
				bot.sleep(10000);
				if (++retry > 5) {
					System.out.println("Shell is null after " + retry + " tries");
					break;
				}
			}
		}
	}