Search in sources :

Example 56 with SWTBotShell

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

the class TestUtil method botForShellStartingWith.

public static SWTBotShell botForShellStartingWith(final String titlePrefix) {
    SWTWorkbenchBot bot = new SWTWorkbenchBot();
    Matcher<Shell> matcher = new TypeSafeMatcher<Shell>() {

        @Override
        protected boolean matchesSafely(Shell item) {
            String title = item.getText();
            return title != null && title.startsWith(titlePrefix);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("Shell with title starting with '" + titlePrefix + "'");
        }
    };
    Shell shell = bot.widget(matcher);
    return new SWTBotShell(shell);
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Shell(org.eclipse.swt.widgets.Shell) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 57 with SWTBotShell

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

the class GitCloneWizardHttpsTest method canCloneARemoteRepo.

@Test
public void canCloneARemoteRepo() throws Exception {
    destRepo = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), "test" + System.nanoTime());
    importWizard.openWizard();
    RepoPropertiesPage propertiesPage = importWizard.openRepoPropertiesPage();
    propertiesPage.setURI(r.getSecureUri());
    propertiesPage.setUser("agitter");
    propertiesPage.setPassword("letmein");
    propertiesPage.setStoreInSecureStore(false);
    SWTBotShell wizardShell = bot.activeShell();
    RepoRemoteBranchesPage remoteBranches = propertiesPage.nextToRemoteBranches();
    bot.waitUntil(shellIsActive(UIText.EGitCredentialsProvider_information));
    // SSL trust dialog
    bot.checkBox(1).select();
    bot.button("OK").click();
    bot.waitUntil(new ActiveShell(wizardShell, "import wizard shell"));
    cloneRepo(destRepo, remoteBranches);
}
Also used : RepoPropertiesPage(org.eclipse.egit.ui.common.RepoPropertiesPage) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) RepoRemoteBranchesPage(org.eclipse.egit.ui.common.RepoRemoteBranchesPage) File(java.io.File) Test(org.junit.Test)

Example 58 with SWTBotShell

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

the class SharingWizardTest method createProject.

private static String createProject(String projectName) throws CoreException {
    bot.menu("File").menu("New").menu("Project...").click();
    SWTBotShell createProjectDialogShell = bot.shell("New Project");
    SWTBotTreeItem item = bot.tree().getTreeItem("General");
    TestUtil.expandAndWait(item).getNode("Project").select();
    bot.button("Next >").click();
    bot.textWithLabel("Project name:").setText(projectName);
    String path = bot.textWithLabel("Location:").getText();
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(createProjectDialogShell), 10000);
    ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
    return path;
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 59 with SWTBotShell

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

the class SharingWizardTest method shareProjectWithExternalRepo.

@Test
public void shareProjectWithExternalRepo() throws Exception {
    String repoName = "ExternalRepositoryForShare";
    createProject(projectName0);
    String location1 = createProject(projectName1);
    String location2 = createProject(projectName2);
    createProject(projectName3);
    ExistingOrNewPage existingOrNewPage = sharingWizard.openWizard(projectName1, projectName2);
    SWTBotShell createRepoDialog = existingOrNewPage.clickCreateRepository();
    String repoDir = RepositoryUtil.getDefaultRepositoryDir();
    File repoFolder = new File(repoDir, repoName);
    createRepoDialog.bot().textWithLabel(UIText.CreateRepositoryPage_DirectoryLabel).setText(repoFolder.getAbsolutePath());
    createRepoDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
    SWTBotCombo combo = bot.comboBoxWithLabel(UIText.ExistingOrNewPage_ExistingRepositoryLabel);
    assertTrue(combo.getText().startsWith(repoName));
    Repository targetRepo = lookupRepository(new File(repoFolder, Constants.DOT_GIT));
    assertTrue(combo.getText().endsWith(targetRepo.getDirectory().getPath()));
    assertEquals(targetRepo.getWorkTree().getPath(), bot.textWithLabel(UIText.ExistingOrNewPage_WorkingDirectoryLabel).getText());
    String[][] contents = new String[2][3];
    contents[0][0] = projectName1;
    contents[0][1] = new Path(location1).toString();
    contents[0][2] = new Path(targetRepo.getWorkTree().getPath()).append(projectName1).toString();
    contents[1][0] = projectName2;
    contents[1][1] = new Path(location2).toString();
    contents[1][2] = new Path(targetRepo.getWorkTree().getPath()).append(projectName2).toString();
    existingOrNewPage.assertTableContents(contents);
    existingOrNewPage.setRelativePath("a/b");
    contents[0][2] = new Path(targetRepo.getWorkTree().getPath()).append("a/b").append(projectName1).toString();
    contents[1][2] = new Path(targetRepo.getWorkTree().getPath()).append("a/b").append(projectName2).toString();
    existingOrNewPage.assertTableContents(contents);
    SWTBotShell shell = bot.activeShell();
    bot.button(IDialogConstants.FINISH_LABEL).click();
    bot.waitUntil(Conditions.shellCloses(shell));
    ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
    String location1Path = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName1).getLocation().toString();
    assertEquals(contents[0][2], location1Path);
    String location2Path = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName2).getLocation().toString();
    assertEquals(contents[1][2], location2Path);
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Repository(org.eclipse.jgit.lib.Repository) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ExistingOrNewPage(org.eclipse.egit.ui.common.ExistingOrNewPage) File(java.io.File) Test(org.junit.Test)

Example 60 with SWTBotShell

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

the class PushToUpstreamTest method pushToUpstream.

private void pushToUpstream() {
    SWTBotTree project = selectProject();
    JobJoiner joiner = JobJoiner.startListening(JobFamilies.PUSH, 20, TimeUnit.SECONDS);
    ContextMenuHelper.clickContextMenu(project, getPushToUpstreamMenuPath());
    TestUtil.openJobResultDialog(joiner.join());
    SWTBotShell resultDialog = TestUtil.botForShellStartingWith("Push Results");
    resultDialog.close();
}
Also used : JobJoiner(org.eclipse.egit.ui.test.JobJoiner) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)158 Test (org.junit.Test)82 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)46 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)40 Repository (org.eclipse.jgit.lib.Repository)18 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)11 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)11 File (java.io.File)10 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)9 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)9 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)7 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)7 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)7 Path (org.eclipse.core.runtime.Path)6 JobJoiner (org.eclipse.egit.ui.test.JobJoiner)6 Shell (org.eclipse.swt.widgets.Shell)6 SWTBotButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotButton)6 IProject (org.eclipse.core.resources.IProject)5 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 ICondition (org.eclipse.swtbot.swt.finder.waits.ICondition)5