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));
}
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();
}
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;
}
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));
}
Aggregations