org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory Java Examples
The following examples show how to use
org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.
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: ConditionHelpers.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override public boolean test() throws Exception { List<SWTBotEditor> editors = fWorkbenchBot.editors(WidgetMatcherFactory.withPartId(TmfEventsEditor.ID)); for (SWTBotEditor e : editors) { // We are careful not to call e.getWidget() here because it actually forces the editor to show. // This is especially a problem for cases where we wait until there is no active editor. if (e.isActive()) { if (fEditorTitle != null && !fEditorTitle.equals(e.getTitle())) { return false; } fEditor = e; return true; } } return false; }
Example #2
Source File: SWTBotUtils.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Finds an editor and sets focus to the editor * * @param bot * the workbench bot * @param editorName * the editor name * @return the corresponding SWTBotEditor */ public static SWTBotEditor activateEditor(SWTWorkbenchBot bot, String editorName) { Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(editorName); final SWTBotEditor editorBot = bot.editor(matcher); IEditorPart iep = editorBot.getReference().getEditor(true); final TmfEventsEditor tmfEd = (TmfEventsEditor) iep; editorBot.show(); UIThreadRunnable.syncExec(new VoidResult() { @Override public void run() { tmfEd.setFocus(); } }); WaitUtils.waitForJobs(); activeEventsEditor(bot); assertNotNull(tmfEd); return editorBot; }
Example #3
Source File: SwtBotProjectActions.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** Collapse all projects shown in the Project Explorer. */ public static void collapseProjects(SWTWorkbenchBot bot) { for (SWTBotView explorer : bot.views(WidgetMatcherFactory.withPartId(IPageLayout.ID_PROJECT_EXPLORER))) { Widget explorerWidget = explorer.getWidget(); Tree explorerTree = bot.widget(widgetOfType(Tree.class), explorerWidget); for (SWTBotTreeItem item : new SWTBotTree(explorerTree).getAllItems()) { item.collapse(); } } }
Example #4
Source File: ContextActionUiTestUtil.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Returns the {@link SWTBotMenu}s available on the given widget bot. * * @param widgetBot * the bot representing the widget, whose {@link SWTBotMenu}s should be returned * @return the {@link SWTBotMenu}s on the given widget bot */ public static List<SWTBotMenu> getContextMenuItems(final AbstractSWTBot<? extends Control> widgetBot) { return UIThreadRunnable.syncExec(new Result<List<SWTBotMenu>>() { @Override public List<SWTBotMenu> run() { List<SWTBotMenu> menuItems = Lists.newArrayList(); for (MenuItem menuItem : new ContextMenuFinder(widgetBot.widget).findMenus(widgetBot.widget.getShell(), WidgetMatcherFactory.widgetOfType(MenuItem.class), true)) { menuItems.add(new SWTBotMenu(menuItem)); } return menuItems; } }); }
Example #5
Source File: ContextActionUiTestUtil.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Returns the disabled {@link SWTBotMenu}s on the given widget bot. * * @param widgetBot * the bot representing the widget, whose disabled {@link SWTBotMenu}s should be returned * @return the disabled {@link SWTBotMenu}s on the given widget bot */ public static List<SWTBotMenu> getDisabledContextMenuItems(final AbstractSWTBot<? extends Control> widgetBot) { return UIThreadRunnable.syncExec(new Result<List<SWTBotMenu>>() { @Override public List<SWTBotMenu> run() { List<SWTBotMenu> disabledMenuItems = Lists.newArrayList(); for (MenuItem menuItem : new ContextMenuFinder(widgetBot.widget).findMenus(widgetBot.widget.getShell(), WidgetMatcherFactory.widgetOfType(MenuItem.class), true)) { if (!menuItem.isEnabled()) { disabledMenuItems.add(new SWTBotMenu(menuItem)); } } return disabledMenuItems; } }); }
Example #6
Source File: CallsiteEventsInTableTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Main test case */ @Test public void test() { SWTBotUtils.createProject(TRACE_PROJECT_NAME); // Open source file as a unknown trace SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fSourceFile.getAbsolutePath(), null); // Open the actual trace SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), CALLSITE_TRACE_TYPE); SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName()); SWTBotTable tableBot = editorBot.bot().table(); // Maximize editor area SWTBotUtils.maximize(editorBot.getReference(), tableBot); SWTBotTableItem tableItem = tableBot.getTableItem(1); // Open source code location SWTBotMenu menuBot = tableItem.contextMenu("Open Source Code"); menuBot.click(); // Verify that source code was actually opened Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(fSourceFile.getName()); final SWTBotEditor sourceEditorBot = fBot.editor(matcher); assertTrue(sourceEditorBot.isActive()); editorBot.show(); SWTBotUtils.maximize(editorBot.getReference(), tableBot); fBot.closeAllEditors(); SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot); }
Example #7
Source File: ImportAndReadKernelSmokeTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Main test case */ @Test public void test() { CtfTmfTrace trace = CtfTmfTestTraceUtils.getSyntheticTrace(); try { Matcher<IEditorReference> matcher = WidgetMatcherFactory.withPartName(trace.getName()); IEditorPart iep = fBot.editor(matcher).getReference().getEditor(true); final TmfEventsEditor tmfEd = (TmfEventsEditor) iep; fDesired1 = getEvent(trace, 100); fDesired2 = getEvent(trace, 10000); UIThreadRunnable.syncExec(new VoidResult() { @Override public void run() { tmfEd.setFocus(); tmfEd.selectionChanged(new SelectionChangedEvent(tmfEd, new StructuredSelection(fDesired1))); } }); testHV(getViewPart("Histogram")); testCFV((ControlFlowView) getViewPart("Control Flow")); testRV((ResourcesView) getViewPart("Resources")); testStateSystemExplorer(trace.getPath()); } finally { trace.dispose(); } }
Example #8
Source File: ActiveShellMenu.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public boolean test() throws Exception { MenuFinder finder = getMenuFinder(); SwtBotUtils.print("ActiveShellMenu: Getting menus for shell: " + bot.activeShell().getText()); SwtBotUtils.print("ActiveShellMenu: Is active: " + bot.activeShell().isActive() + ""); Matcher<MenuItem> menuMatcher = WidgetMatcherFactory.withMnemonic(name); Shell shell = bot.activeShell().widget; found = finder.findMenus(shell, menuMatcher, recursive); boolean hasFound = found != null && found.size() > 0; SwtBotUtils.print("ActiveShellMenu: Has found menus: '" + hasFound + "' for: " + name); return hasFound; }
Example #9
Source File: SarosView.java From saros with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unused") private void selectConnectAccount(String baseJID) throws RemoteException { SWTBotToolbarDropDownButton b = view.toolbarDropDownButton(TB_CONNECT); @SuppressWarnings("static-access") Matcher<MenuItem> withRegex = WidgetMatcherFactory.withRegex(Pattern.quote(baseJID) + ".*"); b.menuItem(withRegex).click(); try { b.pressShortcut(KeyStroke.getInstance("ESC")); } catch (ParseException e) { log.debug("", e); } }
Example #10
Source File: TestTimer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * In an editor, add a Start Timer, a Humand task and a Transition between them. * * @param gmfEditor * @throws InterruptedException */ private void createStartTimerDiagram(final SWTBotGefEditor gmfEditor) throws InterruptedException { gmfEditor.activateTool("Start timer"); gmfEditor.click(200, 100); final Matcher<Widget> matcher = WidgetMatcherFactory.withLabel("Timer1"); bot.waitUntilWidgetAppears(Conditions.waitForWidget(matcher)); gmfEditor.click(150, 150); // "Timer1" -> "Step1" SWTBotTestUtil.selectTaskFromSelectedElementAndDragIt(gmfEditor, "Timer1", new Point(400, 100)); }
Example #11
Source File: SWTBotTestUtil.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public static void selectTabbedPropertyView(final SWTBot viewerBot, final String tabText) { viewerBot.waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { final List<? extends Widget> widgets = viewerBot.getFinder() .findControls(WidgetMatcherFactory.widgetOfType(TabbedPropertyList.class)); Assert.assertTrue("No widget of type " + TabbedPropertyList.class.getName() + " has been found", widgets.size() > 0); return UIThreadRunnable.syncExec(new Result<Boolean>() { @Override public Boolean run() { try { final TabbedPropertyList tabbedPropertyList = (TabbedPropertyList) widgets.get(0); int i = 0; boolean found = false; ListElement currentTab; final Method selectMethod = TabbedPropertyList.class.getDeclaredMethod("select", new Class[] { int.class }); selectMethod.setAccessible(true); do { currentTab = (org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.ListElement) tabbedPropertyList .getElementAt(i); if (currentTab != null) { final String label = currentTab.getTabItem().getText(); if (label.equals(tabText)) { found = true; selectMethod.invoke(tabbedPropertyList, i); } } i++; } while (currentTab != null && !found); if (!found) { return false; } } catch (final Exception ex) { BonitaStudioLog.error(ex); return false; } return true; } }); } @Override public String getFailureMessage() { return "Can't find a tab item with " + tabText + " label"; } }, 5000); }
Example #12
Source File: TestTimer.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * Set properties on a Fixed Date Timer . * * @throws InterruptedException * @throws ParseException */ @Test public void testEditVariableConstantTimerCondition() throws Exception { final SWTBotGefEditor gmfEditor = addTimerAndTaskToDiagram(); // Set Timer1 editTimerCondition(gmfEditor, DEFAULT_TIMER_NAME); SWTBotShell activeShell = bot.activeShell(); bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click(); // wait for "Edit Expression" shell bot.waitUntil(Conditions.shellIsActive(editExpressionShellLabel)); bot.table().select("Constant"); final Matcher<Widget> matcher = WidgetMatcherFactory.withLabel("Value"); bot.waitUntil(Conditions.waitForWidget(matcher)); bot.textWithLabel("Value").setText("120000"); Assert.assertEquals("Error: Wrong Timer Condition setted", "120000", bot.textWithLabel("Value").getText()); // "Return type" , "java.lang.Long" final SWTBotCombo returnTypeCombo = bot.comboBoxWithLabel(org.bonitasoft.studio.groovy.ui.Messages.returnType); returnTypeCombo.setSelection(Long.class.getName()); Assert.assertEquals("Error: Wrong Timer Condition return type setted", Long.class.getName(), returnTypeCombo.getText()); // in the shell editor for 'Every hour' bot.button(IDialogConstants.OK_LABEL).click(); activeShell.setFocus(); Assert.assertEquals("Error: Content of text field is not corrected.", "120000", bot.text().getText()); bot.button(IDialogConstants.FINISH_LABEL).click(); Assert.assertEquals("Error: Wrong Timer Condition", "00:02:00", bot.textWithLabel(Messages.timerCondition).getText()); editTimerCondition(gmfEditor, DEFAULT_TIMER_NAME); Assert.assertTrue("Error: Wrong Timer Condition", bot.radio(Messages.durationLabel).isSelected()); bot.button(IDialogConstants.CANCEL_LABEL).click(); bot.menu("File").menu("Save").click(); final IStatus status = SWTBotTestUtil.selectAndRunFirstPoolFound(bot); assertTrue(status.getMessage(), status.isOK()); }
Example #13
Source File: WaitForTable.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Creates a new instance of {@link WaitForTable}. * * @param parent * the parent {@link Table}, must not be {@code null} */ public WaitForTable(final Table parent) { super(WidgetMatcherFactory.widgetOfType(TableItem.class)); Assert.isNotNull(parent, "parent"); this.parent = parent; }
Example #14
Source File: WaitForTree.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Creates a new instance of {@link WaitForTree}. * * @param parent * the parent {@link Tree}, must not be {@code null} */ public WaitForTree(final Tree parent) { super(WidgetMatcherFactory.widgetOfType(TreeItem.class)); Assert.isNotNull(parent, "parent"); this.parent = parent; }