Search in sources :

Example 6 with SWTBotShell

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

the class TestCreateSystemtapScript method cleanUp.

@After
public void cleanUp() {
    SWTBotShell[] shells = bot.shells();
    for (final SWTBotShell shell : shells) {
        String shellTitle = shell.getText();
        if (shellTitle.length() > 0 && !shellTitle.startsWith("SystemTap IDE") && !shellTitle.startsWith("Quick Access")) {
            UIThreadRunnable.syncExec(() -> {
                if (shell.widget.getParent() != null) {
                    shell.close();
                }
            });
        }
    }
    bot.closeAllEditors();
    mainShell.activate();
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) After(org.junit.After)

Example 7 with SWTBotShell

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

the class TestCreateSystemtapScript method beforeClass.

@BeforeClass
public static void beforeClass() {
    SWTBotPreferences.TIMEOUT = 20000;
    bot = new SWTWorkbenchBot();
    try {
        bot.viewByTitle("Welcome").close();
        // hide Subclipse Usage stats popup if present/installed
        bot.shell("Subclipse Usage").activate();
        bot.button("Cancel").click();
    } catch (WidgetNotFoundException e) {
        // ignore
        e.printStackTrace();
    }
    prepareTreeSettings();
    // Set SystemTap IDE perspective.
    bot.perspectiveByLabel("SystemTap IDE").activate();
    bot.sleep(5000);
    for (SWTBotShell sh : bot.shells()) {
        if (sh.getText().contains("SystemTap IDE")) {
            mainShell = sh;
            sh.activate();
            bot.sleep(500);
            break;
        }
    }
    // Dismiss "Systemtap not installed" dialog(s) if present.
    try {
        SWTBotShell shell = bot.shell("Cannot Run SystemTap").activate();
        shell.close();
        shell = bot.shell("Cannot Run SystemTap").activate();
        shell.close();
    } catch (WidgetNotFoundException e) {
    // ignore
    }
    // Create a Systemtap project.
    clickMainMenu("File", "New", "Project...");
    SWTBotShell shell = bot.shell("New Project");
    shell.setFocus();
    shell.bot().text().setText("Project");
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "General", "Project"));
    bot.button("Next >").click();
    bot.textWithLabel("Project name:").setText(SYSTEMTAP_PROJECT_NAME);
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    projectExplorer = bot.viewByTitle("Project Explorer");
    projectExplorer.setFocus();
    projectExplorer.bot().tree().select(SYSTEMTAP_PROJECT_NAME).contextMenu("Go Into").click();
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) BeforeClass(org.junit.BeforeClass)

Example 8 with SWTBotShell

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

the class TestCreateSystemtapScript method testGenerateFromPrintf.

@Test
public void testGenerateFromPrintf() {
    SWTBotShell shell = prepareScript("testGenerates.stp", "#!/usr/bin/env stap" + "\nglobal i,j,k,a" + "\nprobe begin{i=0;j=5;k=20;a=65}" + "\n#probe begin{printf(\"%1b%1b%1blo %1b%1brld\\n\", 72,101,108,87,111)}" + "\nprobe timer.ms(100){printf(\"%5i|\\n%10.5d|\\n%-10.5i|\\n%05c\\n\",i,j,k,a);i++;j+=5;k+=20;a++}" + "\n//printf(\"this is a comment\\n\");" + "\n/*printf(\"this is a...\\n\");" + "\nprintf(\"...multiline comment\\n\");*/" + "\nprobe begin{b = sprintf(\"Here\"); printf(\"-->%s<--\\n\", b)}" + "\nprobe timer.ms(100){printf(\"%x - %#x - %#X\\n\",i,i,i);}" + "\nprobe timer.ms(100){printf(\"%o - %#o\\n\",i,i);}" + "\nprobe begin{printf(\"%1b-\\\\n-%p\\n\", 65, 0x8000000002345678)}");
    // Generate regexs.
    bot.button(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsButton).click();
    SWTBotShell dialogShell = bot.shell(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsTitle);
    dialogShell.setFocus();
    bot.button("Yes").click();
    bot.waitUntil(Conditions.shellCloses(dialogShell));
    shell.setFocus();
    SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    // One extra entry for "Add New Regex"
    assertEquals(9, combo.itemCount());
    String[] expectedRegexs = new String[] { " {0,4}(-?\\d+)\\|", " {0,9}(-?\\d+)\\|", "(-?\\d+) {0,9}\\|", " {0,4}(.)", "-->(.+)<--", "([a-f0-9]+) - (0x[a-f0-9]+) - (0X[A-F0-9]+)", "(\\d+) - (0\\d+)", "(.)-\\\\n-(0x[a-f0-9]+)", Messages.SystemTapScriptGraphOptionsTab_regexAddNew };
    for (int i = 0, n = combo.itemCount(); i < n; i++) {
        assertEquals(expectedRegexs[i], combo.items()[i]);
    }
    bot.button("Apply").click();
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 9 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell 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));
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) Matcher(org.hamcrest.Matcher) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 10 with SWTBotShell

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

the class TestCreateSystemtapScript method testCreateScript.

@Test
public void testCreateScript() {
    String scriptName = "testScript.stp";
    createScript(bot, scriptName);
    // Type a script
    SWTBotEclipseEditor editor = bot.editorByTitle(scriptName).toTextEditor();
    editor.typeText(0, editor.getText().length(), "\nprobe begin{log(\"began");
    editor.typeText(0, editor.getText().length() - 1, "); exit(");
    editor.typeText(0, editor.getText().length(), "}");
    editor.save();
    openRunConfigurations(scriptName);
    SWTBotShell shell = bot.shell("Run Configurations");
    shell.setFocus();
    bot.tree().select("SystemTap").contextMenu("New").click();
}
Also used : SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) 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