use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTable in project linuxtools by eclipse.
the class TestCreateSystemtapScript method testTapsetContents.
@Test
public void testTapsetContents() {
// Create a blank script and add a function to it while it's open.
String scriptName = "probeScript.stp";
createScript(bot, scriptName);
SWTBotView funcView = bot.viewByTitle("Function");
funcView.setFocus();
SWTBotTree funcTree = funcView.bot().tree();
SWTBotTreeItem item = funcTree.getTreeItem(funcNodeName);
item.doubleClick();
SWTBotEclipseEditor editor = bot.activeEditor().toTextEditor();
assertTrue(editor.getText().contains(item.getText()));
// Open a non-stap file and add a probe. This should bring up a dialog
// asking if the function should be added to the only open .stp file.
clickMainMenu("File", "New", "Other...");
SWTBotShell shell = bot.shell("New");
shell.setFocus();
shell.bot().text().setText("Untitled Text File");
bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General", "Untitled Text File"));
bot.button("Finish").click();
bot.waitUntil(Conditions.shellCloses(shell));
SWTBotView probeView = bot.viewByTitle("Probe Alias");
probeView.setFocus();
SWTBotTree probeTree = probeView.bot().tree();
SWTBotTreeItem probeCategory = probeTree.getTreeItem(probeCategoryFull);
probeCategory.expand();
bot.waitUntil(new TreeItemPopulated(probeCategory));
String dialogTitle = "Select Script";
item = probeCategory.getNode(probeGroup);
item.expand();
bot.waitUntil(new TreeItemPopulated(item));
item = item.getNode(0);
item.doubleClick();
{
Matcher<Shell> withText = withText(dialogTitle);
bot.waitUntil(Conditions.waitForShell(withText));
}
shell = bot.shell(dialogTitle);
shell.setFocus();
bot.button("Yes").click();
bot.waitUntil(Conditions.shellCloses(shell));
// The editor containing the script should now be in focus.
bot.waitUntil(new EditorIsActive(scriptName));
assertTrue(wasProbeInserted(editor, item, false));
// Open the probe's definition file (an .stp script).
probeView.show();
item.contextMenu("View Definition").click();
bot.waitUntil(new EditorIsActive(probeDef.getName()));
// Adding a probe while an .stp editor is in focus should always add it
// to that editor, even if multiple .stp editors are open.
item = probeCategory.getNode(probeGroup);
item.doubleClick();
assertTrue(wasProbeInserted(bot.activeEditor().toTextEditor(), item, true));
assertFalse(wasProbeInserted(editor, item, true));
// Switch to the non-stp editor, and add a probe. A dialog should appear
// to let the user choose which of the open files to add to.
editor = bot.editorByTitle("Untitled 1").toTextEditor();
editor.show();
item = probeCategory.getNode(probeSingleWithoutDef);
item.doubleClick();
shell = bot.shell(dialogTitle);
shell.setFocus();
SWTBotTable table = bot.table();
assertTrue(table.containsItem(scriptName));
assertTrue(table.containsItem(probeDef.getName()));
table.select(scriptName);
bot.button("OK").click();
bot.waitUntil(Conditions.shellCloses(shell));
bot.waitUntil(new EditorIsActive(scriptName));
assertTrue(wasProbeInserted(bot.activeEditor().toTextEditor(), item, false));
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTable in project linuxtools by eclipse.
the class TestCreateSystemtapScript method testGraphErrors.
@Test
public void testGraphErrors() {
SWTBotShell shell = prepareScript("missingColumns.stp", null);
SWTBotButton runButton = bot.button("Run");
SWTBotButton addButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton);
SWTBotButton editButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_EditGraphButton);
SWTBotButton dupButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_DuplicateGraphButton);
SWTBotButton remButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButton);
String graphID = "org.eclipse.linuxtools.systemtap.graphing.ui.charts.scatterchartbuilder";
// As soon as the Graphing tab is entered, no regular expression exists & nothing can be run.
SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
assertEquals("", combo.getText());
assertFalse(runButton.isEnabled());
assertFalse(addButton.isEnabled());
combo.setText("(1)(2)");
assertEquals("(1)(2)", combo.getText());
assertTrue(runButton.isEnabled());
assertTrue(addButton.isEnabled());
setupGraphWithTests("Graph", false);
assertTrue(runButton.isEnabled());
// Removing groups from the regex disables graphs that rely on those groups.
combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
combo.setText("(1)");
assertFalse(runButton.isEnabled());
combo.setText("(1)(2)(3)");
assertTrue(runButton.isEnabled());
final SWTBotTable table = bot.table();
table.select(0);
dupButton.click();
assertEquals(2, table.rowCount());
assertTrue(runButton.isEnabled());
combo.setText("(1)");
assertFalse(runButton.isEnabled());
for (int i = 0, n = table.rowCount(); i < n; i++) {
String itemTitle = table.getTableItem(i).getText();
assertTrue("Graph " + i + " should be invalid, but it's not: " + itemTitle, table.getTableItem(i).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph));
}
setupGraphGeneral("Safe", 1, graphID, true, false);
assertFalse(table.getTableItem(2).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph));
combo.setText("(1)(2)(3)");
assertTrue(runButton.isEnabled());
setupGraphGeneral("Unsafe", 3, graphID, true, false);
assertTrue(runButton.isEnabled());
combo.setText("(1)(2)");
assertFalse(runButton.isEnabled());
for (int i = 0, n = table.rowCount(); i < n; i++) {
String itemTitle = table.getTableItem(i).getText();
assertTrue("Graph " + i + " has incorrect validity: " + itemTitle, !itemTitle.contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph) || itemTitle.contains("Unsafe"));
}
table.select(3);
dupButton.click();
remButton.click();
assertTrue(!runButton.isEnabled());
table.select(3);
editButton.click();
SWTBotShell graphShell = bot.shell("Edit Graph").activate();
SWTBotButton finishButton = bot.button("Finish");
assertTrue(!finishButton.isEnabled());
bot.comboBox("<Deleted>").setSelection("NA");
finishButton.click();
bot.waitUntil(Conditions.shellCloses(graphShell));
shell.setFocus();
assertTrue(runButton.isEnabled());
// Perform tests when graphs have an invalid graphID.
UIThreadRunnable.syncExec(() -> {
GraphData gd = (GraphData) table.getTableItem(0).widget.getData();
gd.graphID = "invalidID";
table.getTableItem(0).widget.setData(gd);
});
// Just to refresh the dialog
combo.setText(combo.getText().concat(" "));
assertFalse(runButton.isEnabled());
assertTrue(table.getTableItem(0).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraphID));
table.select(0);
dupButton.click();
remButton.click();
assertFalse(runButton.isEnabled());
assertTrue(table.getTableItem(table.rowCount() - 1).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraphID));
table.select(table.rowCount() - 1);
editButton.click();
graphShell = bot.shell("Edit Graph").activate();
finishButton = bot.button("Finish");
assertFalse(finishButton.isEnabled());
bot.radio(0).click();
finishButton.click();
bot.waitUntil(Conditions.shellCloses(graphShell));
shell.setFocus();
assertTrue(runButton.isEnabled());
// Removing all invalid graphs should restore validity.
combo.setText("(1)");
assertFalse(runButton.isEnabled());
for (int i = table.rowCount() - 1; i >= 0; i--) {
if (table.getTableItem(i).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph)) {
table.select(i);
remButton.click();
}
}
assertTrue(runButton.isEnabled());
while (table.rowCount() > 0) {
table.select(0);
remButton.click();
}
bot.button("Apply").click();
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTable in project linuxtools by eclipse.
the class DockerContainersViewSWTBotTest method selectContainersInTable.
private void selectContainersInTable(final String... items) {
final SWTBotTable table = dockerContainersViewBot.bot().table();
assertThat(table).isNotNull();
table.select(items);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTable in project eclipse-pmd by acanda.
the class AddRuleSetConfigurationWizardBot method ruleNames.
public String[] ruleNames() {
final SWTBotTable table = rules();
final String[] names = new String[table.rowCount()];
for (int i = 0; i < table.rowCount(); i++) {
names[i] = table.cell(i, 0);
}
return names;
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTable in project linuxtools by eclipse.
the class TestCreateSystemtapScript method testDeleteBlankRegex.
@Test
public void testDeleteBlankRegex() {
SWTBotShell shell = prepareScript("blank.stp", null);
// Confirm that adding a new regex when the current one is blank has no effect.
SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
assertEquals(2, combo.itemCount());
combo.setSelection(1);
assertEquals(2, combo.itemCount());
assertEquals(0, combo.selectionIndex());
// Confirm that adding a regex works when the current regex is not empty.
combo.setText("(a) b (c)");
assertEquals("(a) b (c)", combo.getText());
combo.setSelection(1);
assertEquals(3, combo.itemCount());
assertEquals(1, combo.selectionIndex());
// Confirm that a blank regex is not removed when other data is not empty.
combo.setText("(a)");
bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).click();
SWTBotShell graphShell = bot.shell("Create Graph").activate();
graphShell.setFocus();
bot.textWithLabel("Title:").setText("Test");
bot.button("Finish").click();
bot.waitUntil(Conditions.shellCloses(graphShell));
shell.setFocus();
combo.setText("");
assertEquals("", combo.getText());
combo.setSelection(0);
assertEquals(3, combo.itemCount());
// Confirm that auto-deleting a blank regex in the middle of the regex list works properly.
combo.setSelection(2);
assertEquals(4, combo.itemCount());
combo.setText("sample");
combo.setSelection(1);
assertEquals(4, combo.itemCount());
SWTBotTable table = bot.table();
SWTBotButton remButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButton);
assertTrue(!remButton.isEnabled());
table.select(0);
assertTrue(remButton.isEnabled());
remButton.click();
assertTrue(!remButton.isEnabled());
combo.setSelection(2);
assertEquals(3, combo.itemCount());
assertEquals("sample", combo.getText());
assertEquals("(a) b (c)", combo.items()[0]);
assertEquals("sample", combo.items()[1]);
// Confirm that auto-deleting a regex from the beginning of the list works properly.
combo.setSelection(2);
combo.setText("another sample");
combo.setSelection(0);
combo.setText("");
combo.setSelection(1);
assertEquals(3, combo.itemCount());
assertEquals("sample", combo.getText());
assertEquals("sample", combo.items()[0]);
assertEquals("another sample", combo.items()[1]);
}
Aggregations