Search in sources :

Example 41 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testGraphContents.

@Test
public void testGraphContents() {
    final String valA1 = "A1";
    final String valB1 = "B1";
    createAndViewDummyData(new String[] { valA1, valB1 }, new Integer[] { 0, 0, 1, 2, 2, 4, 3, 6, 4, 8, 5, 10, 6, 12, 7, 14, 8, 16, 9, 18 });
    SWTBotEditor graphEditorA = bot.activeEditor();
    final String valA2 = "A2";
    final String valB2 = "B2";
    createAndViewDummyData(new String[] { valA2, valB2 }, new Integer[] { 2, 0, 5, 1, 7, 2, 10, 3 });
    SWTBotEditor graphEditorB = bot.activeEditor();
    // Add graphs.
    setupGraphWithTests("Others", true);
    String graphTitle2 = "Others - Scatter Graph";
    graphEditorA.show();
    setupGraphWithTests("Values", true);
    String graphTitle1 = "Values - Scatter Graph";
    // Test table & graph contents.
    graphEditorA.bot().cTabItem("Data View").activate();
    SWTBotTable dataTable = bot.table();
    List<String> colNames = dataTable.columns();
    assertEquals(3, colNames.size());
    assertEquals(valA1, colNames.get(1));
    assertEquals(valB1, colNames.get(2));
    assertEquals("2", dataTable.cell(2, 1));
    assertEquals("4", dataTable.cell(2, 2));
    graphEditorA.bot().cTabItem(graphTitle1).activate();
    Matcher<AbstractChartBuilder> matcher = widgetOfType(AbstractChartBuilder.class);
    AbstractChartBuilder cb = bot.widget(matcher);
    ISeries[] series = cb.getChart().getSeriesSet().getSeries();
    assertEquals(2, series.length);
    assertEquals(10, series[0].getXSeries().length);
    assertEquals(10, series[1].getXSeries().length);
    assertEquals(2, (int) series[0].getYSeries()[2]);
    assertEquals(4, (int) series[1].getYSeries()[2]);
    graphEditorB.show();
    graphEditorB.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    colNames = dataTable.columns();
    assertEquals(3, colNames.size());
    assertEquals(valA2, colNames.get(1));
    assertEquals(valB2, colNames.get(2));
    assertEquals("7", dataTable.cell(2, 1));
    assertEquals("2", dataTable.cell(2, 2));
    graphEditorB.bot().cTabItem(graphTitle2).activate();
    cb = bot.widget(matcher);
    series = cb.getChart().getSeriesSet().getSeries();
    assertEquals(2, series.length);
    assertEquals(4, series[0].getXSeries().length);
    assertEquals(4, series[1].getXSeries().length);
    assertEquals(7, (int) series[0].getYSeries()[2]);
    assertEquals(2, (int) series[1].getYSeries()[2]);
    // Test filters on the data table & graphs.
    graphEditorA.show();
    graphEditorA.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    new SWTBotMenu(ContextMenuHelper.contextMenu(dataTable, "Add filter...")).click();
    SWTBotShell shell = bot.shell("Create Filter");
    shell.setFocus();
    // Match Filter - Remove a matching
    bot.button("Match Filter").click();
    bot.button("Next >").click();
    bot.text().setText("2");
    deselectDefaultSelection(0);
    bot.radio(1).click();
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    bot.waitUntil(new TableHasUpdated(graphEditorA.bot().table(), 9, true));
    assertEquals("3", dataTable.cell(2, 1));
    assertEquals("6", dataTable.cell(2, 2));
    // Filters should be applied to graphs as well as data tables.
    graphEditorA.bot().cTabItem(graphTitle1).activate();
    cb = bot.widget(matcher);
    series = cb.getChart().getSeriesSet().getSeries();
    bot.waitUntil(new ChartHasUpdated(cb.getChart(), 9));
    assertEquals(3, (int) series[0].getYSeries()[2]);
    assertEquals(6, (int) series[1].getYSeries()[2]);
    // Each graph set should have its own filters.
    graphEditorB.show();
    graphEditorB.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    assertEquals(4, dataTable.rowCount());
    assertEquals("2", dataTable.cell(0, 1));
    // Test removing a filter.
    graphEditorA.show();
    graphEditorA.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    new SWTBotMenu(ContextMenuHelper.contextMenu(dataTable, "Remove filter...", "Match Filter: \"" + valA1 + "\" removing \"2\"")).click();
    bot.waitUntil(new TableHasUpdated(graphEditorA.bot().table(), 10, true));
    assertEquals("2", dataTable.cell(2, 1));
    assertEquals("4", dataTable.cell(2, 2));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ISeries(org.swtchart.ISeries) Test(org.junit.Test)

Example 42 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project linuxtools by eclipse.

the class PreferencesTest method checkDefaultPreference.

private static void checkDefaultPreference(String preferenceCategory, String profilingType) {
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    // Open preferences shell.
    // $NON-NLS-1$
    SWTBotMenu windowsMenu = bot.menu("Window");
    // $NON-NLS-1$
    windowsMenu.menu("Preferences").click();
    // $NON-NLS-1$
    SWTBotShell shell = bot.shell("Preferences");
    shell.activate();
    // Go to specified tree item in "Profiling Categories" preferences page.
    bot.text().setText(preferenceCategory);
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "C/C++", "Profiling", "Categories", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    preferenceCategory));
    // Restore defaults.
    // $NON-NLS-1$
    bot.button("Restore Defaults").click();
    // $NON-NLS-1$
    bot.button("Apply").click();
    // Get information for default tool.
    String defaultToolId = ProviderFramework.getProviderIdToRun(null, profilingType);
    // $NON-NLS-1$
    String defaultToolName = ProviderFramework.getToolInformationFromId(defaultToolId, "name");
    // $NON-NLS-1$
    String defaultToolInfo = ProviderFramework.getToolInformationFromId(defaultToolId, "information");
    // $NON-NLS-1$
    String defaultToolDescription = ProviderFramework.getToolInformationFromId(defaultToolId, "description");
    // $NON-NLS-1$ //$NON-NLS-2$
    String defaultToolLabel = defaultToolName + " [" + defaultToolDescription + "]";
    // Assert default radio is as expected.
    SWTBotRadio defaultRadio = bot.radio(defaultToolLabel);
    assertNotNull(defaultRadio);
    assertEquals(defaultToolInfo, defaultRadio.getToolTipText());
    // $NON-NLS-1$
    bot.button("Apply").click();
    // $NON-NLS-1$
    bot.button("Apply and Close").click();
}
Also used : SWTBotRadio(org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 43 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project dsl-devkit by dsldevkit.

the class DynamicViewMenu method getMenuItemsInternal.

/**
 * Gets the menu items. This is expected to be called from within the UI thread. If not it will throw exceptions
 * based on invalid thread access.
 *
 * @param items
 *          the menu items to search through
 * @param menuPath
 *          the menu path without the menu item to find.
 * @param recursive
 *          if set to <code>true</code>, will find sub-menus as well.
 * @return The list of SWTBotMenu items which match the menu path.
 */
@SuppressWarnings("PMD.CyclomaticComplexity")
private static List<SWTBotMenu> getMenuItemsInternal(final IContributionItem[] items, final List<String> menuPath, final boolean recursive) {
    final List<SWTBotMenu> l = new ArrayList<SWTBotMenu>();
    final boolean findAnything = (menuPath == null) || menuPath.isEmpty();
    for (final IContributionItem item : items) {
        try {
            if ((item instanceof MenuManager) && recursive) {
                // Sub menus
                final MenuManager menuManager = (MenuManager) item;
                if (findAnything || menuManager.getMenuText().equals(menuPath.get(0))) {
                    List<String> subList = null;
                    if (menuPath.size() > 1) {
                        subList = menuPath.subList(1, menuPath.size());
                    }
                    l.addAll(getMenuItemsInternal(menuManager.getItems(), subList, recursive));
                }
            } else if (item instanceof ContributionItem) {
                final ContributionItem dynItem = (ContributionItem) item;
                dynItem.fill(originalMenu, 0);
                final MenuItem[] items2 = originalMenu.getItems();
                for (final MenuItem item2 : items2) {
                    l.add(new SWTBotMenu(item2));
                }
            }
        } catch (final WidgetNotFoundException widgetNotFoundException) {
            // Do nothing
            continue;
        }
    }
    return l;
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) IContributionItem(org.eclipse.jface.action.IContributionItem) ArrayList(java.util.ArrayList) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ContributionItem(org.eclipse.jface.action.ContributionItem) IContributionItem(org.eclipse.jface.action.IContributionItem) MenuItem(org.eclipse.swt.widgets.MenuItem)

Example 44 with SWTBotMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu in project dsl-devkit by dsldevkit.

the class DynamicViewMenu method menu.

/**
 * This method returns a SWTBotMenu item which was created dynamically.<br>
 * menuPath must contain at least one entry which is the menu item you want to access to. However you may indicate
 * the menu path where to find the menu item. <br>
 * If you have the following menu tree: <br>
 * Menu - SubMenu1 - MenuItem1 <br>
 * .........|------- MenuItem2 <br>
 * .........|------- MyMenu <br>
 * then call this method as menu("Menu", "SubMenu1", "MyMenu") <br>
 * If you omit the full menu path, the first "MyMenu" entry found will be returned: <br>
 * menu("MyMenu")
 *
 * @param menuPath
 *          the menu path including the menu item to find.
 * @return the sWT bot menu
 */
public SWTBotMenu menu(final String... menuPath) {
    // $NON-NLS-1$
    assertNotEquals("menuPath must contain at least one item", 0, menuPath.length);
    final List<String> menuList = Arrays.asList(menuPath);
    final List<SWTBotMenu> menus = findMenus(reference, menuList.subList(0, menuList.size() - 1), true);
    for (final SWTBotMenu menuItem : menus) {
        if (menuItem.getText().equals(menuList.get(menuList.size() - 1))) {
            return menuItem;
        }
    }
    // $NON-NLS-1$
    throw new WidgetNotFoundException("Could not find menu " + Arrays.toString(menuPath));
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)

Aggregations

SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)44 Test (org.junit.Test)27 DockerClient (com.spotify.docker.client.DockerClient)14 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)14 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)3 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)3 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)3 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)3 IsEditorOpened (net.heartsome.test.swtbot.waits.IsEditorOpened)2 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)2 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2 SWTBotRadio (org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio)2 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)2 ArrayList (java.util.ArrayList)1 ContributionItem (org.eclipse.jface.action.ContributionItem)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)1 AbstractChartBuilder (org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder)1