org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem. 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: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test the invalid file label
 */
@Test
public void testInvalidLabel() {
    // Import invalid analysis file manually (otherwise it is rejected)
    XmlUtils.addXmlFile(Activator.getAbsolutePath(new Path(TEST_FILES_FOLDER
                                                           + INVALID_FILES_FOLDER
                                                           + FILE_IMPORT_INVALID
                                                           + EXTENSION)).toFile());
    XmlAnalysisModuleSource.notifyModuleChange();

    // Check that the "invalid" label displayed
    // and that the checkbox was unchecked as a result
    SWTBot bot = openXMLAnalysesPreferences().bot();
    SWTBotTable tablebot = bot.table(0);
    SWTBotTableItem tableItem = tablebot.getTableItem(FILE_IMPORT_INVALID);
    tableItem.select();
    assertNotNull(bot.label("Invalid file"));
    assertFalse(tableItem.isChecked());

    SWTBotUtils.pressOKishButtonInPreferences(bot);
}
 
Example #2
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the table item matching the given row number.
 *
 * @param row the row number.
 * @return the table item with the specified row.
 * @throws WidgetNotFoundException if the node was not found.
 * @since 2.0
 */
public SWTBotTableItem getTableItem(final int row) throws WidgetNotFoundException {
	try {
		new SWTBot().waitUntil(new DefaultCondition() {
			public String getFailureMessage() {
				return "Could not find table item for row " + row; //$NON-NLS-1$
			}

			public boolean test() throws Exception {
				return getItem(row) != null;
			}
		});
	} catch (TimeoutException e) {
		throw new WidgetNotFoundException("Timed out waiting for table item in row " + row, e); //$NON-NLS-1$
	}
	return new SWTBotTableItem(getItem(row));
}
 
Example #3
Source File: SWTBotTableCombo.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets the table item matching the given name.
 *
 * @param itemText the text on the node.
 * @return the table item with the specified text.
 * @throws WidgetNotFoundException if the node was not found.
 * @since 1.3
 */
public SWTBotTableItem getTableItem(final String itemText) throws WidgetNotFoundException {
	try {
		new SWTBot().waitUntil(new DefaultCondition() {
			public String getFailureMessage() {
				return "Could not find node with text " + itemText; //$NON-NLS-1$
			}

			public boolean test() throws Exception {
				return getItem(itemText) != null;
			}
		});
	} catch (TimeoutException e) {
		throw new WidgetNotFoundException("Timed out waiting for table item " + itemText, e); //$NON-NLS-1$
	}
	return new SWTBotTableItem(getItem(itemText));
}
 
Example #4
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param bot
 * @param variableName
 */
public static void setVariableExpression(final SWTGefBot bot, final String variableName) {
    bot.waitUntil(Conditions.shellIsActive(editExpression));
    bot.tableWithLabel(expressionTypeLabel).select("Variable");
    bot.sleep(1000);
    // select the variable
    final SWTBotTable tableVar = bot.table(1);
    for (int i = 0; i < tableVar.rowCount(); i++) {
        final SWTBotTableItem tableItem = tableVar.getTableItem(i);
        if (tableItem.getText().startsWith(variableName + " --")) {
            tableItem.select();
            break;
        }
    }
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.OK_LABEL)));
    bot.button(IDialogConstants.OK_LABEL).click();
}
 
Example #5
Source File: BotBdmConstraintsEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public BotBdmConstraintsEditor editConstraint(String packageName, String businessObject, String constraintName,
        String... selectFields) {
    selectBusinessObject(packageName, businessObject);
    getConstraintsTable().select(constraintName);
    SWTBotTable constraintsEditionTable = getConstraintsEditionTable();
    List<String> toCheck = Arrays.asList(selectFields);
    for (int i = 0; i < constraintsEditionTable.rowCount(); i++) {
        SWTBotTableItem tableItem = constraintsEditionTable.getTableItem(i);
        if (toCheck.contains(tableItem.getText())) {
            tableItem.check();
        } else {
            tableItem.uncheck();
        }
    }
    return this;
}
 
Example #6
Source File: SWTBotImportWizardUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * While in the import wizard, select an item in the file selection control.
 * The item can be a folder in the left tree or a file in the right table.
 * The item will be checked.
 *
 * @param bot
 *            the SWTBot
 * @param treePath
 *            the path to the item, ending with a file or folder
 */
public static void selectItem(SWTBot bot, String... treePath) {
    SWTBotTree tree = bot.tree();
    bot.waitUntil(Conditions.widgetIsEnabled(tree));
    if (treePath.length == 0) {
        return;
    }
    if (treePath.length == 1) {
        SWTBotTreeItem rootNode = SWTBotUtils.getTreeItem(bot, tree, treePath);
        rootNode.select();
        rootNode.check();
        return;
    }
    String[] parentPath = Arrays.copyOf(treePath, treePath.length - 1);
    String itemName = treePath[treePath.length - 1];
    SWTBotTreeItem folderNode = SWTBotUtils.getTreeItem(bot, tree, parentPath);
    folderNode.expand();
    if (folderNode.getNodes().contains(itemName)) {
        folderNode = folderNode.getNode(itemName);
        folderNode.select();
        folderNode.check();
    } else {
        folderNode.select();
        SWTBotTable fileTable = bot.table();
        bot.waitUntil(Conditions.widgetIsEnabled(fileTable));
        bot.waitUntil(ConditionHelpers.isTableItemAvailable(itemName, fileTable));
        SWTBotTableItem tableItem = fileTable.getTableItem(itemName);
        tableItem.check();
    }
}
 
Example #7
Source File: CallsiteEventsInTableTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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 #8
Source File: PinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test the follow time updates functionality
 */
@Test
public void testFollow() {
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace ust = traceManager.getActiveTrace();
    assertNotNull(ust);
    ITmfTrace kernelTest = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTest.getPath(), TRACETYPE_ID);
    /* Finish waiting for the trace to index */
    WaitUtils.waitForJobs();
    SWTBotEditor kernelEditor = SWTBotUtils.activateEditor(fBot, kernelTest.getName());
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTest.getName());
    ITmfTrace kernel = traceManager.getActiveTrace();
    assertNotNull(kernel);

    SWTBotTable kernelEventTable = kernelEditor.bot().table();
    SWTBotTableItem kernelEvent = kernelEventTable.getTableItem(5);
    kernelEvent.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();
    SWTBotUtils.activateEditor(fBot, ust.getName());
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, ust));

    // assert that the kernel trace followed the ust trace's range
    IWorkbenchPart part = fOriginalViewBot.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, ust, RANGE));

    SWTBotUtils.activateEditor(fBot, kernel.getName());
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernel, RANGE));

    // unfollow (don't use context menu on table item to avoid updating selection)
    kernelEventTable.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, ust.getInitialTimeRange(), ust));
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernel, RANGE));

    kernelTest.dispose();
}
 
Example #9
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static String applyFilter(SWTWorkbenchBot bot, final String filterName) {
    WaitUtils.waitForJobs();
    final SWTBotTable eventsTable = SWTBotUtils.activeEventsEditor(bot).bot().table();
    SWTBotTableItem tableItem = eventsTable.getTableItem(2);
    tableItem.contextMenu(filterName).click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(eventsTable, "/100", 1, 1));
    return eventsTable.cell(1, 1);
}
 
Example #10
Source File: RemoteBotTable.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IRemoteBotTableItem getTableItemWithRegex(String regex) throws RemoteException {

  for (int i = 0; i < widget.rowCount(); i++) {
    SWTBotTableItem item = widget.getTableItem(i);
    if (item.getText().matches(regex)) {
      return RemoteBotTableItem.getInstance().setWidget(item);
    }
  }
  throw new WidgetNotFoundException(
      "unable to find table item with regex: " + regex + " on table " + widget.getText());
}
 
Example #11
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public BotBdmModelEditor setType(String packageName, String businessObject, SWTBotTableItem item, String type,
        SWTBotTable attributeTable) {
    SWTBotShell activeShell = bot.activeShell();
    item.click(1);
    SWTBot activeBot = activeShell.bot();
    SWTBotCCombo ccomboBoxInGroup = activeBot.ccomboBoxWithId(FieldTypeEditingSupport.TYPE_COMBO_EDITOR_ID);
    activeBot.waitUntil(new ConditionBuilder()
            .withTest(() -> Stream.of(ccomboBoxInGroup.items()).anyMatch(type::equals))
            .withFailureMessage(() -> String.format("Type '%s' not found in combo", type))
            .create());
    ccomboBoxInGroup.setSelection(type);
    return this;
}
 
Example #12
Source File: BotContractConstraintRow.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private SWTBotTableItem getTableItem(final SWTBotTable swtBotTable, final int row) {
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            final Table table = swtBotTable.widget;
            tableItem = table.getItem(row);
        }
    });
    return new SWTBotTableItem(tableItem);

}
 
Example #13
Source File: AddProjectNatureTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void toggleFilters(boolean checked) {
    SWTBotView viewBot = fBot.viewByTitle(PROJECT_EXPLORER_TITLE);
    viewBot.setFocus();

    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    String title = CUSTOMIZE_VIEW_DIALOG_TITLE_4_7;
    try {
        viewMenu.menu(CUSTOMIZE_VIEW_MENU_ITEM_4_7).click();
    } catch (WidgetNotFoundException e) {
        viewMenu.menu(CUSTOMIZE_VIEW_MENU_ITEM_4_6).click();
        title = CUSTOMIZE_VIEW_DIALOG_TITLE_4_6;
    }
    SWTBotShell shell = fBot.shell(title).activate();
    // Select first cTabItem which has name 'Filters' in 4.10 or older, and 'Pre-set filters' starting with 4.11
    shell.bot().cTabItem(0).activate();

    SWTBotTable table = shell.bot().table();
    SWTBotTableItem item = table.getTableItem(CUSTOMIZE_VIEW_RESOURCES_FILTER);
    item.select();
    if (checked != item.isChecked()) {
        item.toggleCheck();
    }
    item = table.getTableItem(CUSTOMIZE_VIEW_SHADOW_FILTER);
    item.select();
    if (checked != item.isChecked()) {
        item.toggleCheck();
    }

    shell.bot().button(OK_BUTTON).click();
}
 
Example #14
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns items from a table.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param table
 *          to look for items in, must not be {@code null}
 * @return list of table items, never {@code null}
 */
public static List<SWTBotTableItem> tableItems(final SWTWorkbenchBot bot, final SWTBotTable table) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(table, ARGUMENT_TABLE);
  waitForTableItem(bot, table);
  List<SWTBotTableItem> items = null;
  for (int i = 0; i < table.rowCount(); i++) {
    items = new ArrayList<SWTBotTableItem>(Arrays.asList(table.getTableItem(i)));
  }
  return items;
}
 
Example #15
Source File: PinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the behavior with two traces.
 */
@Ignore
@Test
public void testPinTwoTraces() {
    ITmfTrace ust = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(ust);
    ITmfTrace kernelTestTrace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTestTrace.getPath(), TRACETYPE_ID);
    /* Finish waiting for the trace to index */
    WaitUtils.waitForJobs();
    SWTBotEditor kernelEditor = SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTestTrace.getName());

    // assert that the pin to drop down menuItems are present for both traces.
    fBot.waitUntil(new DefaultCondition() {
        WidgetNotFoundException fException;

        @Override
        public boolean test() throws Exception {
            try {
                SWTBotToolbarDropDownButton toolbarDropDownButton = fOriginalViewBot.toolbarDropDownButton(PIN_VIEW_BUTTON_NAME);
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + kernelTestTrace.getName());
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + fUstTestTrace.getName()).click();
                return true;
            } catch (WidgetNotFoundException e) {
                fException = e;
                return false;
            }
        }

        @Override
        public String getFailureMessage() {
            return "Traces not available in toolbar drop down menu: " + fException;
        }
    });

    /*
     * assert that the pinned view is the UST trace despite the active trace being
     * the kernel trace.
     */
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);
    ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull("There should be an active trace", activeTrace);
    assertEquals("context-switches-kernel should be the active trace", kernelTestTrace.getName(), activeTrace.getName());

    // Get the window range of the kernel trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace kernelTrace = traceManager.getActiveTrace();
    assertNotNull(kernelTrace);

    // switch back and forth
    SWTBotUtils.activateEditor(fBot, fUstTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);

    SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);

    IWorkbenchPart part = fOriginalViewBot.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, kernelTrace));

    // assert that the ust trace's window range did not change
    SWTBotUtils.activateEditor(fBot, fUstTestTrace.getName());
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, ust, INITIAL_UST_RANGE));

    // unpin from another active trace
    SWTBotUtils.activateEditor(fBot, kernelTrace.getName());
    fOriginalViewBot.toolbarButton(UNPIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);

    fOriginalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(PINNED_TO_KERNEL_TIME_GRAPH_VIEW_TITLE);

    SWTBotTable kernelEventTable = kernelEditor.bot().table();
    SWTBotTableItem kernelEvent = kernelEventTable.getTableItem(5);
    kernelEvent.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();

    TmfTimeRange expectedUstWindowRange = new TmfTimeRange(TmfTimestamp.fromNanos(UST_START + SECOND), TmfTimestamp.fromNanos(UST_END - SECOND));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, expectedUstWindowRange, ust));
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernelTrace, expectedUstWindowRange));

    // close the pinned trace
    SWTBotEditor kernelTable = fBot.editorByTitle(kernelTestTrace.getName());
    kernelTable.close();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);

    kernelTestTrace.dispose();
}
 
Example #16
Source File: ColorsViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test color by making all events yellow
 */
@Test
public void testYellow() {
    SWTBotView viewBot = fBot.viewById(ColorsView.ID);
    viewBot.setFocus();
    final String insert = "Insert new color setting";
    final String increasePriority = "Increase priority";
    final String decreasePriority = "Decrease priority";
    final String delete = "Delete color setting";
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(insert).click();
    viewBot.toolbarButton(increasePriority).click();
    viewBot.toolbarButton(decreasePriority).click();
    viewBot.toolbarButton(delete).click();
    viewBot.bot().label(0).setFocus();
    viewBot.toolbarButton(delete).click();
    viewBot.bot().label(0).setFocus();
    viewBot.toolbarButton(delete).click();
    final RGB foreground = new RGB(0, 0, 0);
    final RGB background = new RGB(255, 255, 0);
    // Simulate the side effects of picking a color because we cannot
    // control native Color picker dialog in SWTBot.
    final ColorSetting[] cs = new ColorSetting[1];
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            cs[0] = new ColorSetting(foreground, background, foreground, new PassAll());
            ColorSettingsManager.setColorSettings(cs);
        }
    });
    final SWTBotTable eventsEditor = SWTBotUtils.activeEventsEditor(fBot).bot().table();
    // should fix race condition of loading the trace
    WaitUtils.waitForJobs();
    eventsEditor.select(2);
    final SWTBotTableItem tableItem = eventsEditor.getTableItem(2);
    RGB fgc = UIThreadRunnable.syncExec(new Result<RGB>() {
        @Override
        public RGB run() {
            return tableItem.widget.getForeground().getRGB();
        }
    });
    RGB bgc = UIThreadRunnable.syncExec(new Result<RGB>() {
        @Override
        public RGB run() {
            return tableItem.widget.getBackground().getRGB();
        }
    });
    assertEquals("Fg", foreground, fgc);
    assertEquals("Bg", background, bgc);
    // reset color settings
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            ColorSettingsManager.setColorSettings(new ColorSetting[0]);
        }
    });
}
 
Example #17
Source File: RemoteBotTableItem.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
public IRemoteBotTableItem setWidget(SWTBotTableItem tableItem) {
  this.widget = tableItem;
  return this;
}
 
Example #18
Source File: BookmarksViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static Image getBookmarkImage(SWTBotTableItem tableItem) {
    return UIThreadRunnable.syncExec((Result<Image>) () -> tableItem.widget.getImage(0));
}
 
Example #19
Source File: BookmarksViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static void bookmarkTest(String editorName) throws IOException {
    SWTBotView fViewBot = fBot.viewByPartName("Bookmarks");
    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    assertEquals("Failed to show the Bookmarks View", "Bookmarks", fViewBot.getTitle());
    /**
     * Add a bookmark: a) Double click to select an event in the event
     * editor b) Go to the Edit > Add Bookmark... menu c) Enter the bookmark
     * description in dialog box
     */
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, editorName);
    SWTBotTable tableBot = editorBot.bot().table();
    SWTBotTableItem tableItem = tableBot.getTableItem(7);
    String expectedTimeStamp = tableItem.getText(1);
    assertNull("The image should not be bookmarked yet", getBookmarkImage(tableItem));

    tableItem.select();
    tableItem.doubleClick();
    fBot.menu("Edit").menu("Add Bookmark...").click();
    WaitUtils.waitForJobs();
    SWTBotShell addBookmarkShell = fBot.shell("Add Bookmark");
    addBookmarkShell.bot().text().setText(BOOKMARK_NAME);
    addBookmarkShell.bot().button("OK").click();
    assertNotNull("Failed to add bookmark in event editor", getBookmarkImage(tableItem));

    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    SWTBotTree bookmarkTree = fViewBot.bot().tree();
    WaitUtils.waitForJobs();
    /**
     * throws WidgetNotFoundException - if the node was not found, nothing
     * to assert
     */
    SWTBotTreeItem bookmark = bookmarkTree.getTreeItem(BOOKMARK_NAME);
    assertEquals(BOOKMARK_NAME, bookmark.cell(0));

    /**
     * Scroll within event table so that bookmark is not visible anymore and
     * then double-click on bookmark in Bookmarks View
     */
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(null, TmfTimestamp.fromMicros(22))));
    bookmark.doubleClick();
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    TableCollection selection = tableBot.selection();
    TableRow row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Open another trace #2 and then double-click on bookmark in Bookmarks
     * view
     */
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/E-Test-10K")).getPath(), TRACE_TYPE);
    WaitUtils.waitForJobs();
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Close the trace #1 and then double-click on bookmark in Bookmarks
     * view
     */
    editorBot.close();
    WaitUtils.waitUntil(eb -> !eb.isActive(), editorBot, "Waiting for the editor to close");
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(eb -> eb.bot().table().selection().rowCount() > 0, editorBot, "Selection is still empty");
    tableBot = editorBot.bot().table();
    WaitUtils.waitUntil(tb -> !Objects.equal(tb.selection().get(0).get(1), "<srch>"), tableBot, "Header is still selected");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Select bookmarks icon in bookmark view right-click on icon and select
     * "Remove Bookmark"
     */
    bookmark.select();
    bookmark.contextMenu("Delete").click();
    SWTBotShell deleteBookmarkShell = fBot.shell("Delete Selected Entries");
    SWTBotUtils.anyButtonOf(deleteBookmarkShell.bot(), "Delete", "Yes").click();
    fBot.waitUntil(Conditions.treeHasRows(bookmarkTree, 0));
    tableItem = editorBot.bot().table().getTableItem(7);
    assertNull("Bookmark not deleted from event table", getBookmarkImage(tableItem));
}
 
Example #20
Source File: SWTBotImportWizardUtils.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * While in the import wizard, select a file in the file selection tree.
 *
 * @param bot
 *            the SWTBot
 * @param fileName
 *            the name of the file to select
 * @param folderTreePath
 *            the path to the parent folder in the tree
 */
public static void selectFile(SWTBot bot, String fileName, String... folderTreePath) {
    selectFolder(bot, false, folderTreePath);

    SWTBotTable fileTable = bot.table();
    bot.waitUntil(Conditions.widgetIsEnabled(fileTable));
    bot.waitUntil(ConditionHelpers.isTableItemAvailable(fileName, fileTable));
    SWTBotTableItem tableItem = fileTable.getTableItem(fileName);
    tableItem.check();
}