org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable. 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: BotGefProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Scroll to bottom.
 */
public void scrollToBottom() {
    UIThreadRunnable.syncExec(new VoidResult() {

        @Override
        public void run() {
            final ProcessDiagramEditor processEditor = (ProcessDiagramEditor) gmfEditor.getReference().getEditor(false);
            final FigureCanvas canvas = (FigureCanvas) processEditor.getDiagramGraphicalViewer().getControl();
            Point current;
            Point next = canvas.getViewport().getViewLocation();
            do {
                current = next.getCopy();
                canvas.getViewport().setVerticalLocation(current.y + 10);
                next = canvas.getViewport().getViewLocation();
            } while (!current.equals(next));
        }
    });
}
 
Example #2
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static List<String> getVisibleItems(SWTBotTimeGraph timegraph) {
    return UIThreadRunnable.syncExec(Display.getDefault(), new ListResult<String>() {
        @Override
        public List<String> run() {
            List<String> visibleItems = new ArrayList<>();
            TimeGraphControl control = timegraph.widget;
            ITimeGraphEntry[] expandedElements = control.getExpandedElements();
            for (ITimeGraphEntry entry : expandedElements) {
                Rectangle itemBounds = control.getItemBounds(entry);
                if (itemBounds.height > 0) {
                    visibleItems.add(entry.getName());
                }
            }
            return visibleItems;
        }
    });
}
 
Example #3
Source File: SystemCallLatencyTableAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected AbstractSegmentStoreTableView openTable() {
    /*
     * Open latency view
     */
    SWTBotUtils.openView(PRIMARY_VIEW_ID, SECONDARY_VIEW_ID);
    SWTBotView viewBot = fBot.viewById(PRIMARY_VIEW_ID);
    final IViewReference viewReference = viewBot.getViewReference();
    IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() {
        @Override
        public IViewPart run() {
            return viewReference.getView(true);
        }
    });
    assertTrue("Could not instanciate view", viewPart instanceof SegmentStoreTableView);
    return (SegmentStoreTableView) viewPart;
}
 
Example #4
Source File: CopyToClipboardTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static void assertClipboardContentsEquals(final String expected) {
    fBot.waitUntil(new DefaultCondition() {
        String actual;
        @Override
        public boolean test() throws Exception {
            actual = UIThreadRunnable.syncExec(new StringResult() {
                @Override
                public String run() {
                    Clipboard clipboard = new Clipboard(Display.getDefault());
                    TextTransfer textTransfer = TextTransfer.getInstance();
                    try {
                        return (String) clipboard.getContents(textTransfer);
                    } finally {
                        clipboard.dispose();
                    }
                }
            });
            return expected.equals(actual);
        }
        @Override
        public String getFailureMessage() {
            return NLS.bind("Clipboard contents:\n{0}\nExpected:\n{1}",
                    actual, expected);
        }
    });
}
 
Example #5
Source File: TestRunRecording.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
public void testFinished(final Description description) {
  stop();
  AbstractTestStep.removeTestStepListener(this);
  UIThreadRunnable.syncExec(new VoidResult() {
    @Override
    public void run() {
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().removeMouseListener(TestRunRecording.this);
    }
  });
  if (!testFailed) {
    deleteScreenshots();
  }
}
 
Example #6
Source File: AbstractStandardImportWizardTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Open the import wizard
 */
public void openImportWizard() {
    fWizard = new ImportTraceWizard();

    UIThreadRunnable.asyncExec(new VoidResult() {
        @Override
        public void run() {
            final IWorkbench workbench = PlatformUI.getWorkbench();
            // Fire the Import Trace Wizard
            if (workbench != null) {
                final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                Shell shell = activeWorkbenchWindow.getShell();
                assertNotNull(shell);
                ((ImportTraceWizard) fWizard).init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
                WizardDialog dialog = new WizardDialog(shell, fWizard);
                dialog.open();
            }
        }
    });

    fBot.waitUntil(ConditionHelpers.isWizardReady(fWizard));
}
 
Example #7
Source File: ContextActionUiTestUtil.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Clicks on the {@link MenuItem}.
 *
 * @param menuItem
 *          the {@link MenuItem} to click on
 */
private static void click(final MenuItem menuItem) {
  final Event event = new Event();
  event.time = (int) System.currentTimeMillis();
  event.widget = menuItem;
  event.display = menuItem.getDisplay();
  event.type = SWT.Selection;

  UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
    @Override
    public void run() {
      if (SWTUtils.hasStyle(menuItem, SWT.CHECK) || SWTUtils.hasStyle(menuItem, SWT.RADIO)) {
        menuItem.setSelection(!menuItem.getSelection());
      }
      menuItem.notifyListeners(SWT.Selection, event);
    }
  });
}
 
Example #8
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create the table viewer to test
 *
 * @return the table viewer bot
 */
protected AbstractSegmentStoreTableView openTable() {
    AbstractSegmentStoreTableView tableView = getTableView();
    if (tableView != null) {
        return tableView;
    }
    IViewPart vp = null;
    final IWorkbench workbench = PlatformUI.getWorkbench();
    vp = UIThreadRunnable.syncExec((Result<IViewPart>) () -> {
        try {
            return workbench.getActiveWorkbenchWindow().getActivePage().showView(TestSegmentStoreTableView.ID);
        } catch (PartInitException e) {
            return null;
        }
    });
    assertNotNull(vp);
    assertTrue(vp instanceof TestSegmentStoreTableView);
    TestSegmentStoreTableView testSegmentStoreTableView = (TestSegmentStoreTableView) vp;
    testSegmentStoreTableView.setTest(this);
    fTableView = testSegmentStoreTableView;

    return fTableView;
}
 
Example #9
Source File: ImportAndReadKernelSmokeTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static IViewPart getViewPart(final String viewTile) {
    final IViewPart[] vps = new IViewPart[1];
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            IViewReference[] viewRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
            for (IViewReference viewRef : viewRefs) {
                IViewPart vp = viewRef.getView(true);
                if (vp.getTitle().equals(viewTile)) {
                    vps[0] = vp;
                    return;
                }
            }
        }
    });

    return vps[0];
}
 
Example #10
Source File: TestRunRecording.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
public void testStarted(final Description description) {
  if (!screenshotsCleared) {
    deleteDirectoryContents(new File(screenshotFolder));
    screenshotsCleared = true;
  }
  testFailed = false;
  testStepStarted = false;
  if (description.getTestClass() != null) {
    testClassName = description.getTestClass().getName();
  } else {
    testClassName = testClass.getSimpleName();
  }
  testMethodName = description.getMethodName();
  AbstractTestStep.registerTestStepListener(this);
  UIThreadRunnable.syncExec(new VoidResult() {
    @Override
    public void run() {
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().addMouseListener(TestRunRecording.this);
    }
  });
  start();
}
 
Example #11
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Clean up after a test, reset the views and reset the states of the
 * timegraph by pressing reset on all the resets of the legend
 */
@After
public void after() {

    // reset all
    fViewBot.toolbarButton(SHOW_LEGEND).click();
    SWTBotShell legendShell = fBot.shell(LEGEND_NAME);
    SWTBot legendBot = legendShell.bot();

    for (int i = 0; i < StubPresentationProvider.STATES.length; i++) {
        SWTBotButton resetButton = legendBot.button(i);
        if (resetButton.isEnabled()) {
            resetButton.click();
        }
    }
    legendBot.button(OK_BUTTON).click();
    TmfTraceStub trace = fTrace;
    assertNotNull(trace);
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceClosedSignal(this, trace)));
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    fViewBot.close();
    fBot.waitUntil(ConditionHelpers.viewIsClosed(fViewBot));
    fTrace.dispose();
}
 
Example #12
Source File: SystemCallLatencyStatisticsTableAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Opens a latency table
 */
@Before
public void createTree() {
    /*
     * Open latency view
     */
    SWTBotUtils.openView(PRIMARY_VIEW_ID, SECONDARY_VIEW_ID);
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotView viewBot = bot.viewById(PRIMARY_VIEW_ID);
    final IViewReference viewReference = viewBot.getViewReference();
    IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() {
        @Override
        public IViewPart run() {
            return viewReference.getView(true);
        }
    });
    assertTrue("Could not instanciate view", viewPart instanceof SegmentStoreStatisticsView);
    fTreeBot = viewBot.bot().tree();
    assertNotNull(fTreeBot);
}
 
Example #13
Source File: ResourcesViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static int getVisibleItems(SWTBotTimeGraph timegraph) {
    return UIThreadRunnable.syncExec(Display.getDefault(), new IntResult() {
        @Override
        public Integer run() {
            int count = 0;
            TimeGraphControl control = timegraph.widget;
            ITimeGraphEntry[] expandedElements = control.getExpandedElements();
            for (ITimeGraphEntry entry : expandedElements) {
                Rectangle itemBounds = control.getItemBounds(entry);
                if (itemBounds.height > 0) {
                    count++;
                }
            }
            return count;
        }
    });
}
 
Example #14
Source File: LamiChartViewerTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Reset the current perspective
 */
@After
public void resetPerspective() {
    SWTBotView viewBot = fViewBot;
    if (viewBot != null) {
        viewBot.close();
    }
    /*
     * UI Thread executes the reset perspective action, which opens a shell
     * to confirm the action. The current thread will click on the 'Yes'
     * button
     */
    Runnable runnable = () -> SWTBotUtils.anyButtonOf(fBot, "Yes", "Reset Perspective").click();
    UIThreadRunnable.asyncExec(() -> {
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
        ActionFactory.RESET_PERSPECTIVE.create(activeWorkbenchWindow).run();
    });
    runnable.run();
}
 
Example #15
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Get the number of checked items of a table
 *
 * @param table
 *            The table bot
 * @return The number of checked items
 */
public static int getTableCheckedItemCount(SWTBotTable table) {
    return UIThreadRunnable.syncExec(new IntResult() {

        @Override
        public Integer run() {
            int checked = 0;
            for (TableItem item : table.widget.getItems()) {
                if (item.getChecked()) {
                    checked++;
                }
            }
            return checked;
        }
    });
}
 
Example #16
Source File: RCPTestSetupHelper.java    From tlaplus with MIT License 6 votes vote down vote up
public static void beforeClass() {
	UIThreadRunnable.syncExec(new VoidResult() {
		public void run() {
			resetWorkbench();
			resetToolbox();
			
			// close browser-based welcome screen (if open)
			SWTWorkbenchBot bot = new SWTWorkbenchBot();
			try {
				SWTBotView welcomeView = bot.viewByTitle("Welcome");
				welcomeView.close();
			} catch (WidgetNotFoundException e) {
				return;
			}
		}
	});
}
 
Example #17
Source File: FlameGraphTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Open a flamegraph
 */
@Before
public void before() {
    fBot = new SWTWorkbenchBot();
    SWTBotUtils.openView(FLAMEGRAPH_ID);
    SWTBotView view = fBot.viewById(FLAMEGRAPH_ID);
    assertNotNull(view);
    fView = view;
    FlameGraphView flamegraph = UIThreadRunnable.syncExec((Result<FlameGraphView>) () -> {
        IViewPart viewRef = fView.getViewReference().getView(true);
        return (viewRef instanceof FlameGraphView) ? (FlameGraphView) viewRef : null;
    });
    assertNotNull(flamegraph);
    fTimeGraphViewer = flamegraph.getTimeGraphViewer();
    assertNotNull(fTimeGraphViewer);
    SWTBotUtils.maximize(flamegraph);
    fFg = flamegraph;
}
 
Example #18
Source File: AbstractImportAndReadSmokeTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Gets a view part based on view title
 *
 * @param viewTile
 *            a view title
 * @return the view part
 */
protected IViewPart getViewPart(final String viewTile) {
    final IViewPart[] vps = new IViewPart[1];
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            IViewReference[] viewRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
            for (IViewReference viewRef : viewRefs) {
                IViewPart vp = viewRef.getView(true);
                if (vp.getTitle().equals(viewTile)) {
                    vps[0] = vp;
                    return;
                }
            }
        }
    });

    return vps[0];
}
 
Example #19
Source File: TimeGraphViewUiContextTestBase.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static int getVisibleItems(SWTBotTimeGraph timegraph) {
    return UIThreadRunnable.syncExec(Display.getDefault(), new IntResult() {
        @Override
        public Integer run() {
            int count = 0;
            TimeGraphControl control = timegraph.widget;
            ITimeGraphEntry[] expandedElements = control.getExpandedElements();
            for (ITimeGraphEntry entry : expandedElements) {
                Rectangle itemBounds = control.getItemBounds(entry);
                if (itemBounds.height > 0) {
                    count++;
                }
            }
            return count;
        }
    });
}
 
Example #20
Source File: ImportAndReadPcapTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static IViewPart getViewPart(final String viewTile) {
    final IViewPart[] vps = new IViewPart[1];
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            IViewReference[] viewRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
            for (IViewReference viewRef : viewRefs) {
                IViewPart vp = viewRef.getView(true);
                if (vp.getTitle().equals(viewTile)) {
                    vps[0] = vp;
                    return;
                }
            }
        }
    });

    return vps[0];
}
 
Example #21
Source File: ImportAndReadPcapTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static IViewReference getViewPartRef(final String viewTile) {
    final IViewReference[] vrs = new IViewReference[1];
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            IViewReference[] viewRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
            for (IViewReference viewRef : viewRefs) {
                IViewPart vp = viewRef.getView(true);
                if (vp.getTitle().equals(viewTile)) {
                    vrs[0] = viewRef;
                    return;
                }
            }
        }
    });

    return vrs[0];
}
 
Example #22
Source File: ContextMenuHelper.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private static void click(final MenuItem menuItem) {
  final Event event = new Event();
  event.time = (int) System.currentTimeMillis();
  event.widget = menuItem;
  event.display = menuItem.getDisplay();
  event.type = SWT.Selection;

  UIThreadRunnable.asyncExec(
      menuItem.getDisplay(),
      new VoidResult() {
        @Override
        public void run() {
          menuItem.notifyListeners(SWT.Selection, event);
        }
      });
}
 
Example #23
Source File: PatternLatencyTableViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Get the table associated to the view
 */
private void getTable() {
    SWTBotView viewBot = fBot.viewById(VIEW_ID);
    final IViewReference viewReference = viewBot.getViewReference();
    IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() {
        @Override
        public IViewPart run() {
            return viewReference.getView(true);
        }
    });
    assertNotNull(viewPart);
    if (!(viewPart instanceof PatternLatencyTableView)) {
        fail("Could not instanciate view");
    }
    fLatencyView = (PatternLatencyTableView) viewPart;
    fTable = fLatencyView.getSegmentStoreViewer();
    assertNotNull(fTable);
}
 
Example #24
Source File: PatternDensityViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Set the density viewer
 *
 * @throws SecurityException
 *             If a security manager is present and any the wrong class is
 *             loaded or the class loader is not the same as its ancestor's
 *             loader.
 *
 * @throws NoSuchFieldException
 *             Field not available
 * @throws IllegalAccessException
 *             Field is inaccessible
 * @throws IllegalArgumentException
 *             the object is not the correct class type
 */
public void setDensityViewer() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
    SWTBotView viewBot = fBot.viewById(VIEW_ID);
    final IViewReference viewReference = viewBot.getViewReference();
    IViewPart viewPart = UIThreadRunnable.syncExec(new Result<IViewPart>() {
        @Override
        public IViewPart run() {
            return viewReference.getView(true);
        }
    });
    assertNotNull(viewPart);
    if (!(viewPart instanceof PatternDensityView)) {
        fail("Could not instanciate view");
    }
    fDensityView = (PatternDensityView) viewPart;

    /*
     * Use reflection to access the table viewer
     */
    final Field field = AbstractSegmentStoreDensityView.class.getDeclaredField("fTableViewer");
    field.setAccessible(true);
    fDensityViewer = (AbstractSegmentStoreTableViewer) field.get(fDensityView);
    fDensityChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class));
    assertNotNull(fDensityViewer);
}
 
Example #25
Source File: SystemCallLatencyStatisticsTableAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static void testToTsv(SWTBotView view) throws NoSuchMethodException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    assertNotNull(os);
    IViewPart viewPart = view.getReference().getView(true);
    assertTrue(viewPart instanceof AbstractSegmentsStatisticsView);
    Class<@NonNull AbstractSegmentsStatisticsView> clazz = AbstractSegmentsStatisticsView.class;
    Method method = clazz.getDeclaredMethod("exportToTsv", java.io.OutputStream.class);
    method.setAccessible(true);
    final Exception[] except = new Exception[1];
    UIThreadRunnable.syncExec(() -> {
        try {
            method.invoke((AbstractSegmentsStatisticsView) viewPart, os);
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            except[0] = e;
        }
    });
    assertNull(except[0]);
    @SuppressWarnings("null")
    String[] lines = String.valueOf(os).split(System.getProperty("line.separator"));
    assertNotNull(lines);
    assertEquals("header", "Level\tMinimum\tMaximum\tAverage\tStandard Deviation\tCount\tTotal", lines[0]);
    assertEquals("line 1", "bug446190\t\t\t\t\t\t", lines[1]);
    assertEquals("line 2", "Total\t1 µs\t5.904 s\t15.628 ms\t175.875 ms\t1801\t28.146 s", lines[2]);
}
 
Example #26
Source File: ImageHelper.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Gets a screen grab of the rectangle r; the way to access a given pixel is
 * <code>pixel = rect.width * y + x;</code>
 *
 * @param rect
 *            the area to grab in display relative coordinates (top left is the
 *            origin)
 * @return an ImageHelper, cannot be null
 */
public static ImageHelper grabImage(final Rectangle rect) {
    return UIThreadRunnable.syncExec(new Result<ImageHelper>() {
        @Override
        public ImageHelper run() {
            try {
                // note: awt is explicitly called until we can use SWT to
                // replace it.
                java.awt.Robot rb = new java.awt.Robot();
                java.awt.image.BufferedImage bi = rb.createScreenCapture(new java.awt.Rectangle(rect.x, rect.y, rect.width, rect.height));
                return new ImageHelper(bi.getRGB(0, 0, rect.width, rect.height, null, 0, rect.width), rect);
            } catch (AWTException e) {
            }
            return new ImageHelper(new int[0], new Rectangle(0, 0, 0, 0));
        }
    });
}
 
Example #27
Source File: SwtBotWorkbenchActions.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/** Open the view with the given ID. */
public static SWTBotView openViewById(SWTWorkbenchBot bot, String viewId) {
  UIThreadRunnable.syncExec(
      bot.getDisplay(),
      () -> {
        IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        assertNotNull(activeWindow);
        try {
          activeWindow.getActivePage().showView(viewId);
        } catch (PartInitException ex) {
          // viewById() will fail in calling thread
          logger.log(Level.SEVERE, "Unable to open view " + viewId, ex);
        }
      });
  return bot.viewById(viewId);
}
 
Example #28
Source File: ShellIsActiveWithThreadSTacksOnFailure.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean test() throws Exception {
    try {
        final SWTBotShell shell = bot.shell(text);
        return UIThreadRunnable.syncExec(new BoolResult() {

            public Boolean run() {
                return shell.widget.isVisible() || shell.widget.isFocusControl();
            }
        });
    } catch (final WidgetNotFoundException e) {
    }
    return false;
}
 
Example #29
Source File: XYChartViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Clean up after a test, reset the views.
 */
@After
public void after() {
    TmfTraceStub trace = fTrace;
    assertNotNull(trace);
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceClosedSignal(this, trace)));
    fViewBot.close();
    fBot.waitUntil(ConditionHelpers.viewIsClosed(fViewBot));
    fTrace.dispose();
}
 
Example #30
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Press the shortcut specified by the given keys. The method returns when
 * the key events have been received by the focus control.
 *
 * @param keyboard
 *            the keyboard
 * @param keys
 *            the keys to press
 */
public static void pressShortcut(Keyboard keyboard, KeyStroke... keys) {
    Control focusControl = UIThreadRunnable.syncExec(new Result<Control>() {
        @Override
        public Control run() {
            return Display.getCurrent().getFocusControl();
        }
    });
    pressShortcut(focusControl, () -> keyboard.pressShortcut(keys), keys);
}