Search in sources :

Example 6 with SWTBotTable

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

the class TestCreateSystemtapScript method testGraphConfig.

@Test
public void testGraphConfig() {
    String scriptName = "testGraph.stp";
    createScript(bot, scriptName);
    final String val0 = "i";
    final String val1 = "j";
    final String val2 = "k";
    openRunConfigurations(scriptName);
    SWTBotShell shell = bot.shell("Run Configurations");
    shell.setFocus();
    bot.tree().select("SystemTap").contextMenu("New").click();
    bot.textWithLabel("Name:").setText(scriptName);
    // Select the "Graphing" tab.
    SWTBotCTabItem tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle);
    tab.activate();
    bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_graphOutputRun).click();
    // Create first regex.
    SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    combo.setText("Value:(\\d+) (\\d+)");
    assertEquals("Value:(\\d+) (\\d+)", combo.getText());
    SWTBotText text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    text.setText("Value:1 2");
    assertEquals("Value:1 2", text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
    text.setText(val0);
    assertEquals(val0, text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
    text.setText(val1);
    assertEquals(val1, text.getText());
    setupGraphWithTests("Values", false);
    // Make a second regex, and a graph for it.
    shell.setFocus();
    combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    assertEquals(2, combo.itemCount());
    combo.setSelection(combo.selectionIndex() + 1);
    assertEquals(3, combo.itemCount());
    assertEquals("", combo.getText());
    combo.setText("Other:(\\d+) (\\d+)");
    assertEquals("Other:(\\d+) (\\d+)", combo.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
    text.setText(val0);
    assertEquals(val0, text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
    text.setText(val2);
    assertEquals(val2, text.getText());
    text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    assertEquals("", text.getText());
    setupGraphWithTests("Others", false);
    // Apply the changes, then close the menu & reopen it to make sure settings were saved.
    shell.setFocus();
    bot.button("Apply").click();
    bot.button("Close").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    openRunConfigurations(scriptName);
    shell = bot.shell("Run Configurations");
    shell.setFocus();
    // Set the filter text to show configs of the current script
    shell.bot().text().setText(scriptName);
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "SystemTap", scriptName));
    tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle);
    tab.activate();
    combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    SWTBotTable table = bot.table();
    assertEquals(3, combo.itemCount());
    assertEquals("Value:(\\d+) (\\d+)", combo.getText());
    assertEquals("Value:1 2", text.getText());
    assertEquals(1, table.rowCount());
    String graphName = GraphFactory.getGraphName("org.eclipse.linuxtools.systemtap.graphing.ui.charts.scatterchartbuilder");
    assertTrue(table.containsItem(graphName.concat(":Values")));
    combo.setSelection(1);
    assertEquals("Other:(\\d+) (\\d+)", combo.getText());
    assertEquals("", text.getText());
    assertEquals(1, table.rowCount());
    assertTrue(table.containsItem(graphName.concat(":Others")));
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) SWTBotCTabItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem) Test(org.junit.Test)

Example 7 with SWTBotTable

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTable 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 8 with SWTBotTable

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

the class CreateChangeLogFromHistorySWTBotTest method canPrepareChangeLogFromSVNHistory.

/**
 * Create changelog from SVN history (commit messages).
 *
 * @throws Exception
 */
@Test
@Ignore
public void canPrepareChangeLogFromSVNHistory() throws Exception {
    // select ChangeLog file
    String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
    SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
    long oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 5000;
    bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
    changeLogItem.select();
    // open history for ChangeLog file
    clickOnShowHistory(projectExplorerViewTree);
    SWTBot historyViewBot = bot.viewByTitle("History").bot();
    // wait for SVN revision table to appear
    oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 3 * 5000;
    historyViewBot.waitUntil(new TableAppearsCondition());
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotTable historyTable = historyViewBot.table();
    // select the first row
    historyTable.select(0);
    // right-click => Generate Changelog...
    clickOnGenerateChangeLog(historyTable);
    SWTBotShell shell = bot.shell("Generate ChangeLog").activate();
    SWTBot generateChangelogBot = shell.bot();
    generateChangelogBot.radio("Clipboard").click();
    generateChangelogBot.button("OK").click();
    // create and open a new file for pasting
    String pasteFile = "newFile";
    IFile newFile = project.getFile(new Path(pasteFile));
    newFile.create(new ByteArrayInputStream("".getBytes()), /* empty content */
    false, null);
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    assertNotNull(project.findMember(new Path(pasteFile)));
    ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString).expandNode(pasteFile).select().doubleClick();
    Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName(pasteFile));
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = oldTimeout;
    SWTBotEditor swtBoteditor = bot.activeEditor();
    assertEquals(pasteFile, swtBoteditor.getTitle());
    SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
    // go to beginning of editor
    eclipseEditor.selectRange(0, 0, 0);
    // paste
    eclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("V"));
    swtBoteditor.save();
    // make sure some changelog like text was pasted
    String text = eclipseEditor.getText();
    assertFalse(text.isEmpty());
}
Also used : Path(org.eclipse.core.runtime.Path) ProjectExplorerTreeItemAppearsCondition(org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition) IFile(org.eclipse.core.resources.IFile) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) TableAppearsCondition(org.eclipse.linuxtools.changelog.ui.tests.utils.TableAppearsCondition) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IEditorReference(org.eclipse.ui.IEditorReference) ByteArrayInputStream(java.io.ByteArrayInputStream) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)8 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)6 Test (org.junit.Test)6 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)3 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)2 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)2 SWTBotButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotButton)2 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IFile (org.eclipse.core.resources.IFile)1 Path (org.eclipse.core.runtime.Path)1 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)1 TableAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.TableAppearsCondition)1 GraphData (org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData)1 AbstractChartBuilder (org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder)1 Point (org.eclipse.swt.graphics.Point)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)1 SWTBotCTabItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem)1 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)1