Search in sources :

Example 21 with SWTWorkbenchBot

use of org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot in project linuxtools by eclipse.

the class DockerConnectionManagerUtils method configureConnectionManager.

/**
 * Configures the {@link DockerConnectionManager} with the given array of
 * {@link IDockerConnection} (can be mocked) and refreshes the associated
 * {@link DockerExplorerView}.
 *
 * @param connectionStorageManager
 *            the {@link IDockerConnectionStorageManager} to use (can be
 *            mocked)
 */
public static void configureConnectionManager(final IDockerConnectionStorageManager connectionStorageManager) {
    DockerConnectionManager.getInstance().setConnectionStorageManager(connectionStorageManager);
    final SWTWorkbenchBot bot = new SWTWorkbenchBot();
    final SWTBotView dockerExplorerBotView = SWTUtils.getSWTBotView(bot, DockerExplorerView.VIEW_ID);
    final SWTBotView dockerContainersBotView = SWTUtils.getSWTBotView(bot, DockerContainersView.VIEW_ID);
    SWTUtils.syncExec(() -> {
        DockerConnectionManager.getInstance().reloadConnections();
        if (dockerExplorerBotView != null) {
            final DockerExplorerView dockerExplorerView = (DockerExplorerView) dockerExplorerBotView.getViewReference().getView(false);
            if (dockerExplorerView != null) {
                dockerExplorerView.getCommonViewer().refresh();
                dockerExplorerView.showConnectionsOrExplanations();
            }
        }
        if (dockerContainersBotView != null) {
            final DockerContainersView dockerContainersView = (DockerContainersView) dockerContainersBotView.getViewReference().getView(false);
            if (dockerContainersView != null) {
                dockerContainersView.getViewer().refresh();
            }
        }
    });
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) DockerExplorerView(org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)

Example 22 with SWTWorkbenchBot

use of org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot in project linuxtools by eclipse.

the class DockerExplorerViewSWTBotTest method setup.

@Before
public void setup() {
    this.bot = new SWTWorkbenchBot();
    SWTUtils.asyncExec(() -> {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerExplorerView.VIEW_ID);
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail("Failed to open Docker Explorer view: " + e.getMessage());
        }
    });
    this.dockerExplorerViewBot = bot.viewById(DockerExplorerView.VIEW_ID);
    this.dockerExplorerView = (DockerExplorerView) (dockerExplorerViewBot.getViewReference().getView(true));
    this.bot.views().stream().filter(v -> v.getReference().getId().equals(DockerContainersView.VIEW_ID) || v.getReference().getId().equals(DockerImagesView.VIEW_ID) || v.getReference().getId().equals("org.eclipse.ui.views.PropertySheet")).forEach(v -> v.close());
}
Also used : Conditions(org.eclipse.swtbot.eclipse.finder.waits.Conditions) CloseWelcomePageRule(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.CloseWelcomePageRule) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) RunWith(org.junit.runner.RunWith) DockerConnectionManagerUtils(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.DockerConnectionManagerUtils) TabDescriptorAssertions(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.TabDescriptorAssertions) DockerClient(com.spotify.docker.client.DockerClient) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) After(org.junit.After) MockContainerFactory(org.eclipse.linuxtools.internal.docker.ui.testutils.MockContainerFactory) Assertions(org.assertj.core.api.Assertions) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) ClassRule(org.junit.ClassRule) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Before(org.junit.Before) DockerException(com.spotify.docker.client.exceptions.DockerException) MockImageFactory(org.eclipse.linuxtools.internal.docker.ui.testutils.MockImageFactory) Viewer(org.eclipse.jface.viewers.Viewer) PlatformUI(org.eclipse.ui.PlatformUI) DockerConnectionManager(org.eclipse.linuxtools.docker.core.DockerConnectionManager) MockDockerConnectionFactory(org.eclipse.linuxtools.internal.docker.ui.testutils.MockDockerConnectionFactory) DockerExplorerViewAssertions(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.DockerExplorerViewAssertions) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) Test(org.junit.Test) Collectors(java.util.stream.Collectors) MockDockerClientFactory(org.eclipse.linuxtools.internal.docker.ui.testutils.MockDockerClientFactory) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) TimeUnit(java.util.concurrent.TimeUnit) SWTBotTreeItemAssertions(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.SWTBotTreeItemAssertions) SWTBotJunit4ClassRunner(org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner) Mockito(org.mockito.Mockito) List(java.util.List) Stream(java.util.stream.Stream) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Rule(org.junit.Rule) MenuAssertion(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.MenuAssertion) ClearConnectionManagerRule(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.ClearConnectionManagerRule) MockContainerInfoFactory(org.eclipse.linuxtools.internal.docker.ui.testutils.MockContainerInfoFactory) TestLoggerRule(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.TestLoggerRule) SWTUtils(org.eclipse.linuxtools.internal.docker.ui.testutils.swt.SWTUtils) Assert(org.junit.Assert) DockerContainerRefreshManager(org.eclipse.linuxtools.internal.docker.core.DockerContainerRefreshManager) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) DockerException(com.spotify.docker.client.exceptions.DockerException) Before(org.junit.Before)

Example 23 with SWTWorkbenchBot

use of org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot in project linuxtools by eclipse.

the class AbstractSWTBotTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    // delay click speed
    // System.setProperty("org.eclipse.swtbot.playback.delay", "200");
    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
    }
    // Make sure project explorer is open and tree available
    ProjectExplorer.openView();
    projectExplorerViewTree = ProjectExplorer.getTree();
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) BeforeClass(org.junit.BeforeClass)

Example 24 with SWTWorkbenchBot

use of org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot 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 25 with SWTWorkbenchBot

use of org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot 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

SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)37 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)15 BeforeClass (org.junit.BeforeClass)15 Test (org.junit.Test)10 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)8 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 AbstractRefactoringSwtBotTest (org.eclipse.xtend.ide.tests.AbstractRefactoringSwtBotTest)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 DockerClient (com.spotify.docker.client.DockerClient)4 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)4 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)4 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 SWTUtils (org.eclipse.linuxtools.internal.docker.ui.testutils.swt.SWTUtils)3 Before (org.junit.Before)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IWorkspaceDescription (org.eclipse.core.resources.IWorkspaceDescription)2