Search in sources :

Example 11 with SWTBotShell

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

the class TestCreateSystemtapScript method setupGraphGeneral.

private static void setupGraphGeneral(String title, int numItems, String graphID, boolean useRowNum, boolean isTab) {
    int offset = useRowNum ? 0 : 1;
    SWTBotShell firstShell = bot.activeShell();
    openGraphMenu(isTab);
    SWTBotShell shell = bot.shell("Create Graph");
    shell.setFocus();
    deselectDefaultSelection(0);
    bot.radioWithTooltip(GraphFactory.getGraphName(graphID) + "\n\n" + GraphFactory.getGraphDescription(graphID)).click();
    shell.setFocus();
    SWTBotText text = bot.textWithLabel("Title:");
    text.setText(title);
    bot.comboBoxWithLabel("X Series:").setSelection(offset);
    bot.comboBoxWithLabel("Y Series 0:").setSelection(offset);
    for (int i = 1; i < numItems - offset; i++) {
        bot.comboBoxWithLabel(MessageFormat.format("Y Series {0}:", i)).setSelection(i + 1 + offset);
    }
    if (!useRowNum) {
        bot.comboBoxWithLabel(MessageFormat.format("Y Series {0}:", numItems - 1)).setSelection(0);
    }
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    firstShell.setFocus();
}
Also used : SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Point(org.eclipse.swt.graphics.Point)

Example 12 with SWTBotShell

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

the class TestCreateSystemtapScript method finalCleanUp.

@AfterClass
public static void finalCleanUp() {
    projectExplorer.setFocus();
    SWTBotToolbarButton forwardButton = projectExplorer.toolbarPushButton("Forward");
    projectExplorer.toolbarPushButton("Back to Workspace").click();
    bot.waitUntil(Conditions.widgetIsEnabled(forwardButton));
    projectExplorer.bot().tree().select(SYSTEMTAP_PROJECT_NAME).contextMenu("Delete").click();
    SWTBotShell deleteShell = bot.shell("Delete Resources");
    deleteShell.bot().button("OK").click();
    bot.waitUntil(Conditions.shellCloses(deleteShell));
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) AfterClass(org.junit.AfterClass)

Example 13 with SWTBotShell

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

the class TestCreateSystemtapScript method createScript.

public static void createScript(SWTWorkbenchBot bot, String scriptName) {
    clickMainMenu("File", "New", "Other...");
    SWTBotShell shell = bot.shell("New");
    shell.setFocus();
    shell.bot().text().setText("SystemTap");
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "SystemTap", "SystemTap Script"));
    bot.button("Next >").click();
    SWTBotText text = bot.textWithLabel("Script Name:").setText(scriptName);
    assertEquals(scriptName, text.getText());
    text = bot.textWithLabel("Project:").setText(SYSTEMTAP_PROJECT_NAME);
    assertEquals(SYSTEMTAP_PROJECT_NAME, text.getText());
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    assertEquals(scriptName, bot.activeEditor().getTitle());
}
Also used : SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 14 with SWTBotShell

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

the class TestCreateSystemtapScript method prepareScript.

private static SWTBotShell prepareScript(String scriptName, String scriptContents) {
    createScript(bot, scriptName);
    if (scriptContents != null) {
        SWTBotEclipseEditor editor = bot.editorByTitle(scriptName).toTextEditor();
        editor.setText(scriptContents);
        editor.save();
    }
    openRunConfigurations(scriptName);
    SWTBotShell shell = bot.shell("Run Configurations");
    shell.setFocus();
    bot.tree().select("SystemTap").contextMenu("New").click();
    // Select the "Graphing" tab and enable output graphing.
    bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle).activate();
    bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_graphOutputRun).click();
    return shell;
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 15 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell 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();
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotButton) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) GraphData(org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)41 Test (org.junit.Test)14 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)8 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)6 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)5 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)5 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)5 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)4 Point (org.eclipse.swt.graphics.Point)3 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)3 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)3 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)3 BeforeClass (org.junit.BeforeClass)3 DockerClient (com.spotify.docker.client.DockerClient)2 ProgressHandler (com.spotify.docker.client.ProgressHandler)2 Path (java.nio.file.Path)2 IFile (org.eclipse.core.resources.IFile)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2