Search in sources :

Example 36 with SWTBotView

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.

the class TestUtil method showView.

public static SWTBotView showView(final String viewId) {
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
            try {
                workbenchPage.showView(viewId);
                processUIEvents();
            } catch (PartInitException e) {
                throw new RuntimeException("Showing view with ID " + viewId + " failed.", e);
            }
        }
    });
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    SWTBotView viewbot = bot.viewById(viewId);
    assertNotNull("View with ID " + viewId + " not found via SWTBot.", viewbot);
    return viewbot;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) UIThreadRunnable(org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Example 37 with SWTBotView

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.

the class StagingViewTester method openStagingView.

public static StagingViewTester openStagingView() throws Exception {
    // This is needed so that we can find staging entries by full path.
    Activator.getDefault().getPreferenceStore().setValue(UIPreferences.STAGING_VIEW_FILENAME_MODE, false);
    SWTBotView view = TestUtil.showView(StagingView.VIEW_ID);
    TestUtil.joinJobs(org.eclipse.egit.core.JobFamilies.INDEX_DIFF_CACHE_UPDATE);
    TestUtil.processUIEvents();
    return new StagingViewTester(view);
}
Also used : SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)

Example 38 with SWTBotView

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.

the class GitRepositoriesViewBranchHandlingTest method testCreateCheckoutDeleteLocalBranch.

@Test
public void testCreateCheckoutDeleteLocalBranch() throws Exception {
    final SWTBotView view = getOrOpenView();
    SWTBotTreeItem localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), repositoryFile);
    TestUtil.expandAndWait(localItem);
    assertEquals("Wrong number of children", 1, localItem.getNodes().size());
    assertEquals("master", localItem.getNodes().get(0));
    localItem.getNode(0).select();
    ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil.getPluginLocalizedValue("CreateBranchCommand"));
    SWTBotShell createPage = bot.shell(UIText.CreateBranchWizard_NewBranchTitle);
    createPage.activate();
    // getting text with label doesn't work
    createPage.bot().textWithId("BranchName").setText("newLocal");
    createPage.bot().checkBox(UIText.CreateBranchPage_CheckoutButton).deselect();
    createPage.bot().button(IDialogConstants.FINISH_LABEL).click();
    refreshAndWait();
    localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), repositoryFile);
    TestUtil.expandAndWait(localItem);
    assertEquals("Wrong number of children", 2, localItem.getNodes().size());
    localItem.getNode(0).select();
    assertCheckoutNotAvailable(view);
    localItem.getNode(1).select();
    ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil.getPluginLocalizedValue("CheckoutCommand"));
    TestUtil.joinJobs(JobFamilies.CHECKOUT);
    assertCheckoutNotAvailable(view);
    localItem.getNode(0).select();
    ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil.getPluginLocalizedValue("CheckoutCommand"));
    TestUtil.joinJobs(JobFamilies.CHECKOUT);
    refreshAndWait();
    localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), repositoryFile);
    localItem.getNode(1).select();
    ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil.getPluginLocalizedValue("RepoViewDeleteBranch.label"));
    refreshAndWait();
    localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), repositoryFile);
    TestUtil.expandAndWait(localItem);
    assertEquals("Wrong number of children", 1, localItem.getNodes().size());
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 39 with SWTBotView

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.

the class GitRepositoriesViewRepoHandlingTest method testShowIn.

@Test
public void testShowIn() throws Exception {
    clearView();
    deleteAllProjects();
    shareProjects(repositoryFile);
    refreshAndWait();
    assertProjectExistence(PROJ1, true);
    assertEmpty();
    getOrOpenView().show();
    SWTBotView view = TestUtil.showExplorerView();
    SWTBotTree explorerTree = view.bot().tree();
    SWTBotTreeItem projectItem = getProjectItem(explorerTree, PROJ1).select();
    ContextMenuHelper.clickContextMenuSync(explorerTree, "Show In", viewName);
    refreshAndWait();
    assertHasRepo(repositoryFile);
    SWTBotTree viewerTree = getOrOpenView().bot().tree();
    TableCollection selection = viewerTree.selection();
    assertEquals("Selection should contain one element: " + selection, 1, selection.rowCount());
    String nodeText = selection.get(0).get(0);
    assertTrue("Node text should contain project name", projectItem.getText().startsWith(nodeText));
    view.show();
    SWTBotTreeItem item = TestUtil.expandAndWait(projectItem);
    item = TestUtil.expandAndWait(item.getNode(FOLDER));
    item.getNode(FILE1).select();
    ContextMenuHelper.clickContextMenuSync(explorerTree, "Show In", viewName);
    selection = viewerTree.selection();
    assertTrue("Selection should contain one eelement", selection.rowCount() == 1);
    nodeText = selection.get(0).get(0);
    assertEquals("Node text should contain file name", FILE1, nodeText);
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TableCollection(org.eclipse.swtbot.swt.finder.utils.TableCollection) Test(org.junit.Test)

Example 40 with SWTBotView

use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView in project egit by eclipse.

the class GitRepositoriesViewTestBase method getOrOpenView.

protected SWTBotView getOrOpenView() throws Exception {
    SWTBotView view = TestUtil.showView(RepositoriesView.VIEW_ID);
    TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH);
    return view;
}
Also used : SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)

Aggregations

SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)41 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)14 Test (org.junit.Test)12 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)10 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)7 Repository (org.eclipse.jgit.lib.Repository)3 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)3 Git (org.eclipse.jgit.api.Git)2 Composite (org.eclipse.swt.widgets.Composite)2 Tree (org.eclipse.swt.widgets.Tree)2 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)2 SWTBotStyledText (org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText)2 SWTBotToolbarToggleButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton)2 DockerClient (com.spotify.docker.client.DockerClient)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IDynamicVariable (org.eclipse.core.variables.IDynamicVariable)1 GitScopeOperation (org.eclipse.egit.ui.internal.operations.GitScopeOperation)1