Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#select()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem#select() . 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: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Open view.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param category
 *          the category, must not be {@code null}
 * @param view
 *          the name of the view, must not be {@code null}
 */
public static void openView(final SWTWorkbenchBot bot, final String category, final String view) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(category, "category");
  Assert.isNotNull(view, ARGUMENT_VIEW);
  bot.menu("Window").menu("Show View").menu("Other...").click();
  bot.shell("Show View").activate();
  final SWTBotTree tree = bot.tree();

  for (SWTBotTreeItem item : tree.getAllItems()) {
    if (category.equals(item.getText())) {
      CoreSwtbotTools.waitForItem(bot, item);
      final SWTBotTreeItem[] node = item.getItems();

      for (SWTBotTreeItem swtBotTreeItem : node) {
        if (view.equals(swtBotTreeItem.getText())) {
          swtBotTreeItem.select();
        }
      }
    }
  }
  assertTrue("View or Category found", bot.button().isEnabled());
  bot.button("OK").click();
}
 
Example 2
Source File: ControlViewProfileTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test save session
 */
private void testSaveSession() {
    fProxy.setProfileName(getSessionName());

    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            SESSION_NAME);

    assertEquals(SESSION_NAME, sessionItem.getText());

    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.SAVE_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.SAVE_DIALOG_TITLE).activate();
    shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();
}
 
Example 3
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static void importProfiles() {
    openRemoteProfilePreferences();
    TmfFileDialogFactory.setOverrideFiles(PROFILES_LOCATION);
    fBot.button("Import").click();

    // Change the root path of every profile
    SWTBotTree tree = fBot.tree(1);
    for (SWTBotTreeItem profile : tree.getAllItems()) {
        for (SWTBotTreeItem node : profile.getItems()) {
            for (SWTBotTreeItem traceGroup : node.getItems()) {
                traceGroup.select();
                fBot.textWithLabel("Root path:").setText(TRACE_LOCATION);
            }
        }
    }
    SWTBotUtils.pressOKishButtonInPreferences(fBot);
}
 
Example 4
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static void setTraceTypePreferences(@NonNull String button, @NonNull String... pathToCheck) {
    SWTBot bot = openTraceTypePreferences().bot();
    SWTBotTree treeBot = bot.tree(1);
    if (!button.isEmpty()) {
        bot.button(button).click();
    }

    if (pathToCheck.length > 0) {
        SWTBotTreeItem treeItem = treeBot.expandNode(pathToCheck);
        assertNotNull("Tree item not null", treeItem);
        treeItem.select();
        bot.button(CHECK_SELECTED).click();
    }
    bot.button("Apply").click();
    SWTBotUtils.pressOKishButtonInPreferences(fBot);
}
 
Example 5
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test destroy session
 */
protected void testDestroySession() {
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());

    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.DESTROY_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.DESTROY_CONFIRM_DIALOG_TITLE).activate();
    shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    SWTBotTreeItem sessionGroupItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(), ControlViewSwtBotUtil.SESSION_GROUP_NAME);

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeRemoved(0, sessionGroupItem));
    assertEquals(0, sessionGroupItem.getNodes().size());
}
 
Example 6
Source File: ControlViewAllEventsTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void testEnableKernelEvent() {
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());

    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
    // all tracepoint events and syscalls
    shell.bot().radioInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.ALL_EVENT_GROUP_NAME).click();
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));

    SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
    assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());

    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());
}
 
Example 7
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Expansion of items in a SWTBotTree. Will try collapse and expand if there are no child nodes.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @param item
 *          to wait for, must not be {@code null}
 * @return {@code true} if expanded, {@code false} otherwise
 */
public static boolean waitForItem(final SWTWorkbenchBot bot, final SWTBotTreeItem item) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  Assert.isNotNull(item, ARGUMENT_ITEM);
  item.select();
  safeBlockingExpand(bot, item);
  if (item.getItems().length == 0) {
    safeBlockingCollapse(bot, item);
    safeBlockingExpand(bot, item);
  }
  return item.getItems().length > 0;
}
 
Example 8
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 9
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test disconnect from node
 */
protected void testDisconnectFromNode() {
    SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName());
    nodeItem.select();
    SWTBotMenu menuBot = nodeItem.contextMenu(ControlViewSwtBotUtil.DISCONNECT_MENU_ITEM);
    menuBot.click();
    WaitUtils.waitForJobs();

    // Verify that node is connected
    fBot.waitUntil(ControlViewSwtBotUtil.isStateChanged(fNode, TargetNodeState.DISCONNECTED));
    assertEquals(TargetNodeState.DISCONNECTED, fNode.getTargetNodeState());
    assertEquals(0, nodeItem.getNodes().size());
}
 
Example 10
Source File: RemoteBotTree.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IRemoteBotTreeItem selectTreeItemAndWait(String... pathToTreeItem) throws RemoteException {
  SWTBotTreeItem selectedTreeItem = null;
  for (String node : pathToTreeItem) {
    try {
      if (selectedTreeItem == null) {
        waitUntilItemExists(node);
        selectedTreeItem = widget.expandNode(node);
      } else {

        RemoteBotTreeItem treeItem = RemoteBotTreeItem.getInstance();
        treeItem.setWidget(selectedTreeItem);
        treeItem.setSWTBotTree(widget);
        treeItem.waitUntilSubItemExists(node);
        selectedTreeItem = selectedTreeItem.expandNode(node);
      }
    } catch (WidgetNotFoundException e) {
      log.error("tree item \"" + node + "\" not found", e);
    }
  }
  if (selectedTreeItem != null) {
    SWTBotTreeItem item = selectedTreeItem.select();
    RemoteBotTreeItem.getInstance().setWidget(item);
    RemoteBotTreeItem.getInstance().setSWTBotTree(widget);
    return RemoteBotTreeItem.getInstance();
  }

  throw new WidgetNotFoundException(
      "unknown error: " + widget.getText() + ", " + Arrays.asList(pathToTreeItem));
}
 
Example 11
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void createProfile() {
    fBot.button("Add").click();

    // The first tree is the preference "categories" on the left side, we
    // need to skip it
    SWTBotTree tree = fBot.tree(1);

    SWTBotTreeItem treeNode = getTreeItem(fBot, tree, PROFILE_NAME, "name (ssh://userinfo@host:22)");
    treeNode.select();
    SWTBotText uriLabel = fBot.textWithLabel("URI:");
    uriLabel.setText("file://");
    SWTBotText nodeNameLabel = fBot.textWithLabel("Node name:");
    nodeNameLabel.setText(CONNECTION_NODE1_NAME);

    SWTBotTreeItem traceRootNode = treeNode.getNode("/rootpath");
    traceRootNode.select();
    SWTBotText pathLabel = fBot.textWithLabel("Root path:");
    pathLabel.setText(TRACE_LOCATION);
    fBot.checkBox("Recursive").select();

    // Add the ctf file pattern
    treeNode = traceRootNode.getNode(".*");
    treeNode.select();
    SWTBotText filePatternLabel = fBot.textWithLabel("File pattern:");
    filePatternLabel.setText(LTTNG_TRACE_FILE_PATTERN);

    // Add the syslog file pattern
    traceRootNode.contextMenu("New Trace").click();
    treeNode = traceRootNode.getNode(".*");
    treeNode.select();
    filePatternLabel = fBot.textWithLabel("File pattern:");
    filePatternLabel.setText(SYSLOG_FILE_PATTERN);
    SWTBotCombo combo = fBot.comboBoxWithLabel("Trace type:");
    combo.setSelection("Test trace : Test Syslog");

    // Add the wildcard file pattern
    traceRootNode.contextMenu("New Trace").click();

    SWTBotUtils.pressOKishButtonInPreferences(fBot);
}
 
Example 12
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static List<String> getSelectTraceTypeMenuItems() {
    SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    tracesFolder.expand();
    SWTBotTreeItem trace = tracesFolder.getNode("syslog_collapse");
    trace.select();
    List<String> menuItems = trace.contextMenu().menu("Select Trace Type...").menuItems();
    return menuItems;
}
 
Example 13
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void clearProfiles() {
    openRemoteProfilePreferences();
    SWTBotTree tree = fBot.tree(1);
    for (SWTBotTreeItem profile : tree.getAllItems()) {
        profile.select();
        fBot.button("Remove").click();
    }
    SWTBotUtils.pressOKishButtonInPreferences(fBot);
}
 
Example 14
Source File: ProjectExplorerTracesFolderTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static String getTraceProperty(SWTBotTreeItem traceItem, String property) {
    SWTBotUtils.openView(IPageLayout.ID_PROP_SHEET);
    SWTBotView view = fBot.viewById(IPageLayout.ID_PROP_SHEET);
    view.show();
    traceItem.select();
    SWTBot viewBot = view.bot();
    SWTBotUtils.waitUntil(bot -> bot.tree().cell(0, 0).equals(RESOURCE_PROPERTIES), viewBot, "Resource properties did not appear");
    SWTBotTreeItem traceTypeItem = SWTBotUtils.getTreeItem(viewBot, viewBot.tree(), RESOURCE_PROPERTIES, property);
    return traceTypeItem.cell(1);
}
 
Example 15
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 16
Source File: ControlViewKernelFilterTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void testEnableKernelEvent() {
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());

    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();

    shell.bot().radioInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME).click();

    SWTBotTree tracepointsTree = shell.bot().tree();
    SWTBotTreeItem allItem = SWTBotUtils.getTreeItem(fBot, tracepointsTree, ControlViewSwtBotUtil.ALL_TREE_NODE);
    allItem.check();

    SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL);
    filterText.setText(FILTER_EXPRESSION);
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));

    SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME);
    assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText());

    SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
    assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());

    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());

    ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertNotNull(comp);
    assertTrue(comp instanceof TraceEventComponent);
    TraceEventComponent event = (TraceEventComponent) comp;
    assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression());
}
 
Example 17
Source File: ControlViewExcludeEventsTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Enable all UST events with one excluded event.
 */
protected void testEnableUstEventExclude() {
    // Getting the 'Sessions' tree
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());
    sessionItem.select();

    // Clicking on the 'Enable Event (default channel)...'
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();

    // Switching to the UST domain
    shell.bot().radioInGroup(ControlViewSwtBotUtil.UST_GROUP_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();

    // Selecting all UST events
    SWTBotTree tracepointsTree = shell.bot().treeInGroup(ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME);
    SWTBotTreeItem treeItem = tracepointsTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE);
    treeItem.check();

    // Click the checkbox for the Exclude event
    shell.bot().checkBoxInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL).click();

    // Enter the event to exclude in the text field
    SWTBotText excludeText = shell.bot().textInGroup(ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL);
    excludeText.setText(EXCLUDE_EXPRESSION);

    // Click the Ok at the bottom of the dialog window
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.UST_DOMAIN_NAME, sessionItem));

    // Assert that the domain is UST global
    SWTBotTreeItem ustGlobalDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME);
    assertEquals(ControlViewSwtBotUtil.UST_DOMAIN_NAME, ustGlobalDomainItem.getText());

    // Assert that the new channel name is channel0 (which is the default name)
    SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
    assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());

    // Assert that the event type in the channel node are correct (all events = *)
    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());

    // Assert that the excluded event is the correct one
    ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertNotNull(comp);
    assertTrue(comp instanceof TraceEventComponent);
    TraceEventComponent event = (TraceEventComponent) comp;
    assertEquals(EXCLUDE_EXPRESSION, event.getExcludedEvents());
}
 
Example 18
Source File: TestTraceOffsetting.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test offsetting by 99 ns
 */
@Test
public void testOffsetting() {
    // Skip this test on Mac OS X 10.11.1 because of bug 481611
    // FIXME: Remove this work around once bug 481611 is fixed
    MacOsVersion macOsVersion = MacOsVersion.getMacOsVersion();
    boolean macBugPresent = macOsVersion != null && macOsVersion.compareTo(new MacOsVersion(10, 11, 1)) >= 0;
    assumeTrue(!macBugPresent);

    SWTBotUtils.createProject(PROJET_NAME);
    SWTBotTreeItem traceFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJET_NAME);
    SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
    SWTBotEditor editor = fBot.editorByTitle(fLocation.getName());
    SWTBotTable eventsTableBot = editor.bot().table();
    String timestamp = eventsTableBot.cell(1, 1);
    assertEquals("19:00:00.000 000 000", timestamp);
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, traceFolderItem, fLocation.getName());
    traceItem.select();
    traceItem.contextMenu("Apply Time Offset...").click();
    WaitUtils.waitForJobs();
    // set offset to 99 ns
    SWTBotShell shell = fBot.shell("Apply time offset");
    shell.setFocus();
    SWTBotTreeItem[] allItems = fBot.tree().getAllItems();
    final SWTBotTreeItem swtBotTreeItem = allItems[0];
    swtBotTreeItem.select();
    swtBotTreeItem.click(1);
    // Press shortcuts on the cell editor
    SWTBotText text = shell.bot().text(1);
    text.pressShortcut(KeyStroke.getInstance('9'));
    text.pressShortcut(KeyStroke.getInstance('9'));
    text.pressShortcut(KeyStroke.getInstance('\n'));
    WaitUtils.waitForJobs();
    fBot.button("OK").click();

    // wait for trace to close
    fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, fLocation.getName()));

    // re-open trace
    SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
    editor = fBot.editorByTitle(fLocation.getName());
    eventsTableBot = editor.bot().table();
    timestamp = eventsTableBot.cell(1, 1);
    assertEquals("19:01:39.000 000 000", timestamp);
    SWTBotUtils.deleteProject(PROJET_NAME, fBot);
}
 
Example 19
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Select the traces folder
 *
 * @param bot
 *            a given workbench bot
 * @param projectName
 *            the name of the project (it needs to exist or else it would
 *            time out)
 * @return a {@link SWTBotTreeItem} of the "Traces" folder
 */
public static SWTBotTreeItem selectTracesFolder(SWTWorkbenchBot bot, String projectName) {
    SWTBotTreeItem projectTreeItem = selectProject(bot, projectName);
    projectTreeItem.select();
    SWTBotTreeItem tracesFolderItem = getTraceProjectItem(bot, projectTreeItem, "Traces");
    tracesFolderItem.select();
    return tracesFolderItem;
}
 
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 folder in the file selection tree.
 *
 * @param bot
 *            the SWTBot
 * @param check
 *            whether or not to check the folder item
 * @param treePath
 *            the path to the folder in the tree
 */
public static void selectFolder(SWTBot bot, boolean check, String... treePath) {
    SWTBotTree tree = bot.tree();
    bot.waitUntil(Conditions.widgetIsEnabled(tree));
    SWTBotTreeItem folderNode = SWTBotUtils.getTreeItem(bot, tree, treePath);
    folderNode.select();
    if (check) {
        folderNode.check();
    }
}