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

The following examples show how to use org.eclipse.swtbot.swt.finder.SWTBot#tree() . 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: ControlFlowViewSortingTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void applyFilter() {
    // Select only certain root nodes and their children but filter out rest
    SWTBotToolbarButton filterButton = fViewBot.toolbarButton(FILTER_ACTION);
    filterButton.click();
    SWTBotShell shell = fBot.shell(FILTER_DIALOG_TITLE).activate();

    SWTBot bot = shell.bot();
    SWTBotTree treeBot = bot.tree();
    bot.button(UNCHECK_ALL).click();

    int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("default", 0, checked);

    // select root nodes and their children
    checkFilterTreeItems(bot, treeBot, SYSTEMD_PROCESS_NAME);
    checkFilterTreeItems(bot, treeBot, KTHREAD_PROCESS_NAME);
    checkFilterTreeItems(bot, treeBot, LTTNG_CONSUMER_PROCESS_NAME);

    bot.button(OK_BUTTON).click();
}
 
Example 2
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Opens a trace in an editor and get the TmfEventsEditor
 *
 * @param bot
 *            the workbench bot
 * @param projectName
 *            the name of the project that contains the trace
 * @param elementPath
 *            the trace element path (relative to Traces folder)
 * @return TmfEventsEditor the opened editor
 */
public static TmfEventsEditor openEditor(SWTWorkbenchBot bot, String projectName, IPath elementPath) {
    final SWTBotView projectExplorerView = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectExplorerView.setFocus();
    SWTBot projectExplorerBot = projectExplorerView.bot();

    final SWTBotTree tree = projectExplorerBot.tree();
    projectExplorerBot.waitUntil(ConditionHelpers.isTreeNodeAvailable(projectName, tree));
    final SWTBotTreeItem treeItem = tree.getTreeItem(projectName);
    treeItem.expand();

    SWTBotTreeItem tracesNode = getTraceProjectItem(projectExplorerBot, treeItem, "Traces");
    tracesNode.expand();

    SWTBotTreeItem currentItem = tracesNode;
    for (String segment : elementPath.segments()) {
        currentItem = getTraceProjectItem(projectExplorerBot, currentItem, segment);
        currentItem.doubleClick();
    }

    SWTBotEditor editor = bot.editorByTitle(elementPath.toString());
    IEditorPart editorPart = editor.getReference().getEditor(false);
    assertTrue(editorPart instanceof TmfEventsEditor);
    return (TmfEventsEditor) editorPart;
}
 
Example 3
Source File: AddProjectNatureTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test viewer filter.
 */
@Test
public void testViewerFilter() {

    /* Check that shadow project is visible */
    toggleFilters(false);
    SWTBotTreeItem shadowProject = SWTBotUtils.selectProject(fBot, SOME_PROJECT_SHADOW_NAME);
    assertEquals(SOME_PROJECT_SHADOW_NAME, shadowProject.getText());
    SWTBotTreeItem tracesItem = SWTBotUtils.getTraceProjectItem(fBot, shadowProject, TRACES_FOLDER_NAME);
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, tracesItem, TRACE_NAME);
    assertEquals(TRACE_NAME, traceItem.getText());
    SWTBotUtils.getTraceProjectItem(fBot, shadowProject, EXPERIMENTS_FOLDER_NAME);

    /* Check that shadow project is not visible */
    toggleFilters(true);

    SWTBotView viewBot = fBot.viewByTitle(PROJECT_EXPLORER_TITLE);
    viewBot.setFocus();
    SWTBot projectExplorerBot = viewBot.bot();

    final SWTBotTree tree = projectExplorerBot.tree();
    SWTBotTreeItem[] items = tree.getAllItems();
    for (SWTBotTreeItem swtBotTreeItem : items) {
        assertNotEquals(SOME_PROJECT_SHADOW_NAME, swtBotTreeItem.getText());
    }
}
 
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: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static SWTBotShell openXMLAnalysesPreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot, MANAGE_XML_ANALYSES_PREF_TITLE);
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("XML Analyses", treeNode));
    treeNode = treeNode.getNode("XML Analyses");
    treeNode.select();
    return preferencesShell;
}
 
Example 6
Source File: ProjectExplorerAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static boolean supplementaryFileExists(SWTBotTreeItem traceNode, String filename) {
    // make sure that analysis are finished
    WaitUtils.waitForJobs();
    try {
        ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
    }
    // Make sure that all jobs are finished after refresh
    WaitUtils.waitForJobs();

    traceNode.contextMenu().menu("Delete Supplementary Files...").click();

    SWTBotShell shell = fBot.shell("Delete Resources");
    SWTBot bot = shell.bot();
    SWTBotTree tree = bot.tree();
    SWTBotTreeItem traceSupplNode = SWTBotUtils.getTreeItem(bot, tree, traceNode.getText());

    SWTBotTreeItem[] supplFileNodes = traceSupplNode.getItems();

    boolean supplFound = false;
    for (SWTBotTreeItem swtBotTreeItem : supplFileNodes) {
        if (swtBotTreeItem.getText().equals(filename)) {
            supplFound = true;
            break;
        }
    }

    bot.button("Cancel").click();
    fBot.waitUntil(Conditions.shellCloses(shell));
    return supplFound;
}
 
Example 7
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 8
Source File: SWTBotImportWizardUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * While in the import wizard, select the specified archive as a source.
 *
 * @param bot
 *            the SWTBot
 * @param archivePath
 *            the archive path to set as a source
 */
public static void selectImportFromArchive(SWTBot bot, String archivePath) {
    SWTBotRadio button = bot.radio("Select &archive file:");
    button.click();

    SWTBotCombo sourceCombo = bot.comboBox(1);

    sourceCombo.setFocus();
    sourceCombo.setText(new File(archivePath).getAbsolutePath());

    /* the resource tree gets updated when the combo loses focus */
    SWTBotTree tree = bot.tree();
    tree.setFocus();
}
 
Example 9
Source File: SWTBotImportWizardUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * While in the import wizard, select the specified directory as a source.
 *
 * @param bot
 *            the SWTBot
 * @param directoryPath
 *            the directory path to set as a source
 */
public static void selectImportFromDirectory(SWTBot bot, String directoryPath) {
    SWTBotRadio button = bot.radio("Select roo&t directory:");
    button.click();

    SWTBotCombo sourceCombo = bot.comboBox();
    File traceFolderParent = new File(directoryPath);
    sourceCombo.setFocus();
    sourceCombo.setText(traceFolderParent.getAbsolutePath());

    /* the resource tree gets updated when the combo loses focus */
    SWTBotTree tree = bot.tree();
    tree.setFocus();
}
 
Example 10
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static SWTBotShell openTraceTypePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Trace Types", treeNode));
    treeNode = treeNode.getNode("Trace Types");
    treeNode.select();
    return preferencesShell;
}
 
Example 11
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test enabled/disabled trace types behavior in the filters view
 */
@Test
public void testFiltersView() {
    int defaultCount = TmfTraceType.getAvailableTraceTypes().length;
    SWTBotUtils.openView(FilterView.ID);
    SWTBotView viewBot = fBot.viewById(FilterView.ID);
    importFilter(viewBot);
    SWTBot bot = viewBot.bot();

    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem item = tree.expandNode("FILTER test", "WITH TRACETYPE Custom XML : testxmlextension");
    item.select();

    SWTBotCCombo comboBox = bot.ccomboBox(0);
    assertEquals("Combo: number of trace types", defaultCount, comboBox.itemCount());

    // Change the preference value for testxmlextension
    setTraceTypePreferences(UNCHECK_ALL, "Custom XML", "testxmlextension");

    // Change node to refresh the tree
    item = tree.expandNode("FILTER test");
    item.select();
    item = tree.expandNode("FILTER test", "WITH TRACETYPE Custom XML : testxmlextension");
    item.select();

    comboBox = bot.ccomboBox(0);
    assertEquals("Combo: number of trace types", 1, comboBox.itemCount());

    setTraceTypePreferences(UNCHECK_ALL, "Custom Text", "testtxtextension");

    // Change node to refresh the tree
    item = tree.expandNode("FILTER test");
    item.select();
    item = tree.expandNode("FILTER test", "WITH TRACETYPE Custom XML : testxmlextension");
    item.select();

    comboBox = bot.ccomboBox(0);
    assertEquals("Combo: number of trace types", 2, comboBox.itemCount());
}
 
Example 12
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void openRemoteProfilePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);

    // The first tree is the preference "categories" on the left side
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Remote Profiles", treeNode));
    treeNode = treeNode.getNode("Remote Profiles");
    treeNode.select();
}
 
Example 13
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Return all timestamps ending with 100... for reasons
 */
@Test
public void testTimestampFilter() {
    SWTBotView viewBot = fBot.viewById(FilterView.ID);
    viewBot.setFocus();
    SWTBot filterBot = viewBot.bot();
    SWTBotTree treeBot = filterBot.tree();

    viewBot.toolbarButton("Add new filter").click();
    treeBot.getTreeItem("FILTER <name>").select();
    SWTBotText textBot = filterBot.text();
    textBot.setFocus();
    String filterName = "timestamp";
    textBot.setText(filterName);
    SWTBotTreeItem filterNodeBot = treeBot.getTreeItem(FILTER_TEST + filterName);
    filterNodeBot.click();
    filterNodeBot.contextMenu("TRACETYPE").click();
    filterNodeBot.expand();
    SWTBotCCombo comboBot = filterBot.ccomboBox();
    comboBot.setSelection(TRACETYPE);
    filterNodeBot.getNode(WITH_TRACETYPE).expand();

    // --------------------------------------------------------------------
    // add AND
    // --------------------------------------------------------------------

    filterNodeBot.getNode(WITH_TRACETYPE).contextMenu(AND).click();

    // --------------------------------------------------------------------
    // add CONTAINS "100"
    // --------------------------------------------------------------------

    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).contextMenu(CONTAINS).click();
    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).expand();
    comboBot = filterBot.ccomboBox(1); // aspect
    comboBot.setSelection(TIMESTAMP);
    textBot = filterBot.text();
    textBot.setFocus();
    textBot.setText("100");
    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).getNode("Timestamp CONTAINS \"100\"").select();
    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).select();

    viewBot.toolbarButton("Save filters").click();

    String ret = applyFilter(fBot, filterName);
    assertEquals("10/100", ret);
}
 
Example 14
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
     * Return all timestamps ending with 100... for reasons
     */
    @Test
    public void testTimestampEqualsOr() {
        SWTBotView viewBot = fBot.viewById(FilterView.ID);
        viewBot.setFocus();
        SWTBot filterBot = viewBot.bot();
        SWTBotTree treeBot = filterBot.tree();

        viewBot.toolbarButton("Add new filter").click();
        treeBot.getTreeItem("FILTER <name>").select();
        SWTBotText textBot = filterBot.text();
        textBot.setFocus();
        String filterName = "matchAndEquals";
        textBot.setText(filterName);
        SWTBotTreeItem filterNodeBot = treeBot.getTreeItem(FILTER_TEST + filterName);
        filterNodeBot.click();
        filterNodeBot.contextMenu("TRACETYPE").click();
        filterNodeBot.expand();
        SWTBotCCombo comboBot = filterBot.ccomboBox();
        comboBot.setSelection(TRACETYPE);
        filterNodeBot.getNode(WITH_TRACETYPE).expand();

        // --------------------------------------------------------------------
        // add OR
        // --------------------------------------------------------------------

        filterNodeBot.getNode(WITH_TRACETYPE).contextMenu(OR).click();

        // --------------------------------------------------------------------
        // add EQUALS "19...300"
        // --------------------------------------------------------------------

        SWTBotTreeItem orNode = filterNodeBot.getNode(WITH_TRACETYPE).getNode(OR);
        orNode.contextMenu("EQUALS").click();
        orNode.expand();
        orNode.getNode(0).select();
        comboBot = filterBot.ccomboBox(1); // aspect
        comboBot.setSelection(TIMESTAMP);
        textBot = filterBot.text();
        textBot.setFocus();
        textBot.setText("19:00:00.000 000 300");

        // --------------------------------------------------------------------
        // add MATCHES "1"
        // --------------------------------------------------------------------
        orNode.contextMenu("MATCHES").click();
        orNode.expand();
        orNode.getNode(1).select();
        comboBot = filterBot.ccomboBox(1); // aspect
        comboBot.setSelection(CONTENTS);
        textBot = filterBot.text(0); // field
        textBot.setFocus();
        textBot.setText("field");
        textBot = filterBot.text(1); // value
        textBot.setFocus();
        textBot.setText("1");

        viewBot.toolbarButton("Save filters").click();

        String ret = applyFilter(fBot, filterName);
        assertEquals("26/100", ret);
//        filterNodeBot.contextMenu().menu("Delete").click();
    }
 
Example 15
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
     * test compare field >= 2
     */
    @Test
    public void testField01() {
        SWTBotView viewBot = fBot.viewById(FilterView.ID);
        viewBot.setFocus();
        SWTBot filterBot = viewBot.bot();
        SWTBotTree treeBot = filterBot.tree();

        viewBot.toolbarButton("Add new filter").click();
        treeBot.getTreeItem("FILTER <name>").select();
        SWTBotText textBot = filterBot.text();
        textBot.setFocus();
        String filterName = "field";
        textBot.setText(filterName);
        SWTBotTreeItem filterNodeBot = treeBot.getTreeItem(FILTER_TEST + filterName);
        filterNodeBot.click();
        filterNodeBot.contextMenu("TRACETYPE").click();
        filterNodeBot.expand();
        SWTBotCCombo comboBot = filterBot.ccomboBox();
        comboBot.setSelection(TRACETYPE);
        filterNodeBot.getNode(WITH_TRACETYPE).expand();

        // --------------------------------------------------------------------
        // add Compare > 1.5
        // --------------------------------------------------------------------

        filterNodeBot.getNode(WITH_TRACETYPE).contextMenu(COMPARE).click();
        SWTBotTreeItem contentNode = filterNodeBot.getNode(WITH_TRACETYPE).getNode("<select aspect> " + "=" + " <value>");
        contentNode.expand();
        comboBot = filterBot.ccomboBox(1); // aspect
        comboBot.setSelection(CONTENTS);
        textBot = filterBot.text(0); // field
        textBot.setFocus();
        textBot.setText(filterName);

        textBot = filterBot.text(1); // value
        textBot.setFocus();
        textBot.setText("1.5");
        filterBot.radio(">").click();

        // --------------------------------------------------------------------
        // apply
        // --------------------------------------------------------------------
        viewBot.toolbarButton("Save filters").click();

        String ret = applyFilter(fBot, filterName);
//        filterNodeBot.contextMenu().menu("Delete").click();
        assertEquals("50/100", ret);
    }
 
Example 16
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the filter
 */
@Test
public void testPreferencePage() {
    SWTBot bot = openTraceTypePreferences().bot();
    SWTBotTree treeBot = bot.tree(1);
    //get default count
    bot.button(CHECK_ALL).click();
    int defaultCount = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    int defaultVisibleRows = treeBot.visibleRowCount();
    // test "uncheck all button"
    bot.button(UNCHECK_ALL).click();
    int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    // test check all
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ALL, defaultCount, checked);
    // test check selected
    treeBot.getTreeItem("Custom XML").select();
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SELECTED, 2, checked);
    // test uncheck selected
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, defaultCount - 2, checked);
    // test filter
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    bot.text(1).setText("Custom XML");
    SWTBotUtils.waitUntil(tree -> tree.visibleRowCount() == 2, treeBot, "Visible row count: Default expected 2, but actual value is " + treeBot.visibleRowCount());
    assertEquals("Filtered no checked", 0, checked);
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("Filtered check all", 2, checked);
    bot.text(1).setText("");
    SWTBotUtils.waitUntil(tree -> tree.visibleRowCount() == defaultVisibleRows + 1, treeBot, "Visible row count: Default expected " + defaultCount +", but actual value is " + treeBot.visibleRowCount());
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("Filtered removed all check", defaultCount, checked);
    bot.button("Apply").click();
    SWTBotUtils.pressOKishButtonInPreferences(fBot);
}
 
Example 17
Source File: ControlFlowViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the filter
 */
@Test
public void testFilter() {
    /* change window range to 1 ms */
    TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(1000000L, ITmfTimestamp.NANOSECOND_SCALE));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));

    SWTBotView viewBot = getViewBot();
    SWTBotToolbarButton filterButton = viewBot.toolbarButton("Show View Filters");
    filterButton.click();
    SWTBot bot = fBot.shell("Filter").activate().bot();
    SWTBotTree treeBot = bot.tree();
    // get how many items there are
    int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("default", 226, checked);
    // test "uncheck all button"
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    // test check active
    bot.button(CHECK_ACTIVE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ACTIVE, 69, checked);
    // test check all
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ALL, 226, checked);
    // test uncheck inactive
    bot.button(UNCHECK_INACTIVE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_INACTIVE, 69, checked);
    // test check selected
    treeBot.getTreeItem(LttngTraceGenerator.getName()).select("gnuplot");
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SELECTED, 2, checked);
    // test check subtree
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SUBTREE, 2, checked);
    // test uncheck selected
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 225, checked);
    // test uncheck subtree
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 225, checked);
    // test filter
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    bot.text().setText("half-life 3");
    SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName());
    treeItem.rowCount();
    fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 25));
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("Filtered", 26, checked);
    bot.button(DIALOG_OK).click();
    SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(getViewBot().bot());
    SWTBotTimeGraphEntry traceEntry = timeGraph.getEntry(LttngTraceGenerator.getName());
    for (SWTBotTimeGraphEntry entry : traceEntry.getEntries()) {
        assertEquals("Filtered Control flow view", "Half-life 3", entry.getText());
    }
}
 
Example 18
Source File: ResourcesViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the filter
 */
@Test
public void testFilter() {
    /* change window range to 1 ms */
    TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(1000000L, ITmfTimestamp.NANOSECOND_SCALE));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME), START_TIME);
    SWTBotToolbarButton filterButton = getViewBot().toolbarButton("Show View Filters");
    filterButton.click();
    SWTBot bot = fBot.shell("Filter").activate().bot();
    /*
     * The filtered tree initialization triggers a delayed refresh job that can
     * interfere with the tree selection. Wait for new refresh jobs to avoid this.
     */
    SWTBotTree treeBot = bot.tree();
    // set filter text
    SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName());
    bot.text().setText("24");
    fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 2));
    // clear filter text
    bot.text().setText(LttngTraceGenerator.getName());
    fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 75));
    // get how many items there are
    int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("default", 76, checked);
    // test "uncheck all button"
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    // test check all
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ALL, 76, checked);
    // test uncheck inactive
    treeBot.getTreeItem(LttngTraceGenerator.getName()).select("CPU 1 States");
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SELECTED, 2, checked);
    // test check subtree
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SUBTREE, 2, checked);
    // test uncheck selected
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 75, checked);
    // test uncheck subtree
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 75, checked);
    // test filter
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    bot.text().setText("CPU 2");
    fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 75));
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("Filtered", 76, checked);
    bot.button("OK").click();
}
 
Example 19
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();
    }
}