Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotText#setFocus()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotText#setFocus() . 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: BotAddConnectorDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Select the variable to store the connector output.
 *
 * @param pVariableId
 */
public void selectOutputVariable(final String pVariableId) {
    final SWTBotText text = bot.text(0);
    text.setFocus();
    bot.toolbarButtonWithId("expressionViewerDropDown", 0).click();
    final SWTBot proposalBot = bot.shellWithId("expressionViewerProposalShell").bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId("expressionViewerProposalTable");
    proposalTAble.select(pVariableId);; //1st value
    SWTBotTestUtil.pressEnter();
}
 
Example 2
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Integration test for the time event filtering dialog
 */
@Test
public void testTimegraphEventFiltering() {
    SWTWorkbenchBot bot = fBot;
    resetTimeRange();

    SWTBot viewBot = fViewBot.bot();
    SWTBotTimeGraph timegraph = fTimeGraph;
    assertTrue("timegraph visible", timegraph.isVisible());
    timegraph.setFocus();

    Rectangle bounds = fBounds;

    ImageHelper ref = ImageHelper.grabImage(bounds);

    timegraph.setFocus();
    // Move mouse to middle of the timegraph
    timegraph.moveMouseToWidget();
    // Press '/' to open the filter dialog
    timegraph.pressShortcut(KeyStroke.getInstance('/'));

    SWTBotShell dialogShell = viewBot.shell("Time Event Filter").activate();
    SWTBot shellBot = dialogShell.bot();
    SWTBotText text = shellBot.text();
    text.setText("Hat1");
    bot.waitWhile(fTimeGraphIsDirty);

    timegraph.setFocus();
    ImageHelper filtered = ImageHelper.waitForNewImage(bounds, ref);

    /* Compare with the original, they should be different */
    int refHatCount = ref.getHistogram().count(fHat);
    int filteredHatCount = filtered.getHistogram().count(fHat);
    int refHairCount = ref.getHistogram().count(fHair);
    int filteredHairCount = filtered.getHistogram().count(fHair);
    assertTrue("Count of \"HAT\" did not decrease to non-zero", filteredHatCount < refHatCount && filteredHatCount > 0);
    assertTrue("Count of \"HAIR\" did not decrease to zero", filteredHairCount < refHairCount && filteredHairCount == 0);

    dialogShell = viewBot.shell("Time Event Filter").activate();
    shellBot = dialogShell.bot();
    text = shellBot.text();
    text.setFocus();
    SWTBotUtils.pressShortcut(text, Keystrokes.CR);

    bot.waitWhile(fTimeGraphIsDirty);
    List<String> visibleItems = getVisibleItems(timegraph);
    assertEquals("Fewer entries should be visible here: " + visibleItems, 3, visibleItems.size());
}
 
Example 3
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Integration test for the time event filtering dialog
 */
@Test
public void testHideEmptyRows() {
    resetTimeRange();

    SWTBotTimeGraph timegraph = fTimeGraph;
    assertTrue("timegraph visible", timegraph.isVisible());
    timegraph.setFocus();

    /* set time range */
    setWindowRange(49L, 75L);
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 17, timegraph, () -> "All entries should be visible here: " + getVisibleItems(timegraph));

    /* hide empty rows (includes a row with only 1 marker) */
    fViewBot.toolbarButton("Hide Empty Rows").click();
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 10, timegraph, () -> "Fewer entries should be visible here: " + getVisibleItems(timegraph));

    /* change time range to exclude row with markers */
    setWindowRange(51L, 75L);
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 9, timegraph, () -> "Fewer entries should be visible here: " + getVisibleItems(timegraph));

    /* add a time events filter */
    timegraph.setFocus();
    // Move mouse to middle of the timegraph
    timegraph.moveMouseToWidget();
    // Press '/' to open the filter dialog
    timegraph.pressShortcut(KeyStroke.getInstance('/'));

    SWTBot viewBot = fViewBot.bot();
    SWTBotShell dialogShell = viewBot.shell("Time Event Filter").activate();
    SWTBot shellBot = dialogShell.bot();
    SWTBotText text = shellBot.text();
    text.setText("Head3");
    text.setFocus();
    SWTBotUtils.pressShortcut(text, Keystrokes.CR);
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 2, timegraph, () -> "Fewer entries should be visible here: " + getVisibleItems(timegraph));

    /* show also empty rows */
    fViewBot.toolbarButton("Hide Empty Rows").click();
    /* All rows will be filtered by time events filter */
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 2, timegraph, () -> "Same number of entries should be visible here: " + getVisibleItems(timegraph));

    /* remove time events filter */
    dialogShell = viewBot.shell("Time Event Filter").activate();
    shellBot = dialogShell.bot();
    SWTBotButton button = shellBot.buttonWithTooltip("Close (Esc)");
    button.click();
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 17, timegraph, () -> "All entries should be visible here: " + getVisibleItems(timegraph));
}
 
Example 4
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 5
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 6
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);
    }