Java Code Examples for org.eclipse.swtbot.swt.finder.SWTBot#text()
The following examples show how to use
org.eclipse.swtbot.swt.finder.SWTBot#text() .
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: TimeGraphViewTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * 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 2
Source File: TimeGraphViewTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * 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 3
Source File: SDViewTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Test Sequence diagram print dialog */ @Test public void testSDPrintUi() { SWTBotView viewBot = fBot.viewById(UML2DVIEW_ID); assertNotNull(viewBot); viewBot.setFocus(); WaitUtils.waitForJobs(); // Test print dialog SWTBotCanvas canvas = viewBot.bot().canvas(1); canvas.setFocus(); canvas.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance('P')); SWTBotShell printShell = fBot.shell("Print"); assertNotNull(printShell); SWTBot printBot = printShell.bot(); printBot.radio("Use current zoom").click(); SWTBotRadio allPages = printBot.radio("All pages"); SWTBotRadio currentView = printBot.radio("Current view"); // 'All pages' and 'Current view' buttons will be enabled allPages.click(); currentView.click(); // Test 'Number of horizontal pages' button printBot.radio("Number of horizontal pages:").click(); SWTBotText horizontalPagesText = printBot.text(0); SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(1)), horizontalPagesText, "Number of horizontal pages should be 1"); horizontalPagesText.setText("2"); SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(2)), horizontalPagesText, "Number of horizontal pages should be 2"); assertFalse(currentView.isEnabled()); // Test 'Number of vertical pages' button SWTBotText totalPagesText = printBot.textWithLabel("Total number of pages:"); printBot.radio("Number of vertical pages:").click(); SWTBotText verticalPagesText = printBot.text(1); SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(1)), verticalPagesText, "Number of vertical pages should be 1"); SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(1)), totalPagesText, "Total number of pages should be 1"); verticalPagesText.setText("2"); SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(2)), verticalPagesText, "Number of vertical pages should be 2"); assertFalse(currentView.isEnabled()); // Test 'selected pages' button printBot.radio("Selected pages").click(); assertFalse(currentView.isEnabled()); // Test 'From pages' buttons printBot.radio("From page").click(); SWTBotText fromText = printBot.text(3); SWTBotText toText = printBot.text(4); SWTBotUtils.waitUntil(t -> t.getText().isEmpty(), fromText, "From text is not empty"); SWTBotUtils.waitUntil(t -> t.getText().isEmpty(), toText, "To text is not empty"); fromText.setText("2"); toText.setText("3"); SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(2)), fromText, "From text is not 2"); SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(3)), toText, "To text is not 3"); assertFalse(currentView.isEnabled()); // Don't actually print printBot.button("Cancel").click(); printBot.waitUntil(Conditions.shellCloses(printShell)); }
Example 4
Source File: FilterViewerTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * 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 |
/** * 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 |
/** * 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 7
Source File: TsUIConstants.java From translationstudio8 with GNU General Public License v2.0 | 2 votes |
/** * @param bot * @param textKey * @return ; */ public static SWTBotText text(SWTBot bot, String textKey) { return bot.text(getString(textKey)); }
Example 8
Source File: TsUIConstants.java From tmxeditor8 with GNU General Public License v2.0 | 2 votes |
/** * @param bot * @param textKey * @return ; */ public static SWTBotText text(SWTBot bot, String textKey) { return bot.text(getString(textKey)); }