Search in sources :

Example 31 with SWTBotShell

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

the class TestCreateSystemtapScript method setupGraphWithTests.

private static void setupGraphWithTests(String title, boolean isTab) {
    SWTBotShell firstShell = bot.activeShell();
    openGraphMenu(isTab);
    SWTBotShell shell = bot.shell("Create Graph");
    shell.setFocus();
    SWTBotText text = bot.textWithLabel("Title:");
    text.setText(title);
    assertEquals(title, text.getText());
    SWTBotCombo comboX = bot.comboBoxWithLabel("X Series:");
    // X Series includes "Row Num" as a selection
    assertEquals(3, comboX.itemCount());
    SWTBotCombo comboY0 = bot.comboBoxWithLabel("Y Series 0:");
    // Y Series 0 only includes series entries
    assertEquals(2, comboY0.itemCount());
    comboY0.setSelection(0);
    SWTBotCombo comboY1 = bot.comboBoxWithLabel("Y Series 1:");
    // Y Series (i>0) has extra "NA" option as first entry
    assertEquals(3, comboY1.itemCount());
    comboY1.setSelection(1);
    // Don't allow duplicate selections
    assertFalse(bot.button("Finish").isEnabled());
    comboY1.setSelection(2);
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    firstShell.setFocus();
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 32 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell 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)

Example 33 with SWTBotShell

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

the class PreferencesTest method testProfileProjectActions.

private void testProfileProjectActions(SWTWorkbenchBot bot) throws Exception {
    testPreferencesPage();
    // Focus on project explorer view.
    // $NON-NLS-1$
    SWTBotView projectExplorer = bot.viewByTitle("Project Explorer");
    projectExplorer.bot().tree().select(PROJ_NAME);
    final Shell shellWidget = bot.activeShell().widget;
    // Open profiling configurations dialog
    UIThreadRunnable.asyncExec(() -> {
        DebugUITools.openLaunchConfigurationDialogOnGroup(shellWidget, (StructuredSelection) PlatformUI.getWorkbench().getWorkbenchWindows()[0].getSelectionService().getSelection(), // $NON-NLS-1$
        "org.eclipse.debug.ui.launchGroup.profilee");
    });
    // $NON-NLS-1$
    SWTBotShell shell = bot.shell("Profiling Tools Configurations");
    shell.activate();
    // Create new profiling configuration
    SWTBotTree profilingConfigs = bot.tree();
    // $NON-NLS-1$
    SWTBotTree perfNode = profilingConfigs.select("Profile Timing");
    // $NON-NLS-1$
    perfNode.contextMenu("New").click();
    // $NON-NLS-1$
    bot.button("Profile").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    // Assert that the expected tool is running.
    // $NON-NLS-1$
    SWTBotShell profileShell = bot.shell("Successful profile launch").activate();
    assertNotNull(profileShell);
    // $NON-NLS-1$
    bot.button("Apply and Close").click();
    bot.waitUntil(shellCloses(profileShell));
}
Also used : SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Shell(org.eclipse.swt.widgets.Shell) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 34 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell 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();
}
Also used : SWTBotRadio(org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 35 with SWTBotShell

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

the class PreferencesTest method setUpWorkbench.

@BeforeClass
public static void setUpWorkbench() throws Exception {
    // Set up is based from from GcovTest{c,CPP}.
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    try {
        // $NON-NLS-1$
        bot.viewByTitle("Welcome").close();
        // hide Subclipse Usage stats popup if present/installed
        // $NON-NLS-1$
        bot.shell("Subclipse Usage").activate();
        // $NON-NLS-1$
        bot.button("Cancel").click();
    } catch (WidgetNotFoundException e) {
    // ignore
    }
    // Set C/C++ perspective.
    // $NON-NLS-1$
    bot.perspectiveByLabel("C/C++").activate();
    bot.sleep(500);
    for (SWTBotShell sh : bot.shells()) {
        if (sh.getText().startsWith("C/C++")) {
            // $NON-NLS-1$
            sh.activate();
            bot.sleep(500);
            break;
        }
    }
    // Turn off automatic building by default to avoid timing issues
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = workspace.getDescription();
    boolean isAutoBuilding = desc.isAutoBuilding();
    if (isAutoBuilding) {
        desc.setAutoBuilding(false);
        workspace.setDescription(desc);
    }
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) IWorkspaceDescription(org.eclipse.core.resources.IWorkspaceDescription) IWorkspace(org.eclipse.core.resources.IWorkspace) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) BeforeClass(org.junit.BeforeClass)

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