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

The following examples show how to use org.eclipse.swtbot.swt.finder.SWTBot#getDisplay() . 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: SwtBotWorkbenchActions.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: SwtBotWorkbenchActions.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
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);
}