Search in sources :

Example 1 with JobJoiner

use of org.eclipse.egit.ui.test.JobJoiner in project egit by eclipse.

the class GitRepositoriesViewFetchAndPushTest method testFetchFromOrigin.

private void testFetchFromOrigin(boolean useRemote) throws Exception {
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile);
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile2);
    Repository repository = lookupRepository(clonedRepositoryFile2);
    // add the configuration for push from cloned2
    repository.getConfig().setString("remote", "origin", "push", "refs/heads/*:refs/heads/*");
    repository.getConfig().save();
    SWTBotTree tree = getOrOpenView().bot().tree();
    String destinationString = clonedRepositoryFile.getParentFile().getName() + " - " + "origin";
    String dialogTitle = NLS.bind(UIText.FetchResultDialog_title, destinationString);
    selectNode(tree, useRemote, true);
    runFetch(tree);
    bot.waitUntil(Conditions.shellIsActive(dialogTitle));
    SWTBotShell confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
    confirm.close();
    deleteAllProjects();
    shareProjects(clonedRepositoryFile2);
    String objid = repository.exactRef("refs/heads/master").getTarget().getObjectId().name();
    objid = objid.substring(0, 7);
    touchAndSubmit(null);
    // push from other repository
    JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.PUSH, 60, TimeUnit.SECONDS);
    PushOperationUI op = new PushOperationUI(repository, "origin", false);
    op.start();
    TestUtil.openJobResultDialog(jobJoiner.join());
    String pushdialogTitle = NLS.bind(UIText.PushResultDialog_title, op.getDestinationString());
    bot.shell(pushdialogTitle).close();
    deleteAllProjects();
    refreshAndWait();
    selectNode(tree, useRemote, true);
    runFetch(tree);
    bot.waitUntil(Conditions.shellIsActive(dialogTitle));
    confirm = bot.shell(dialogTitle);
    SWTBotTreeItem[] treeItems = confirm.bot().tree().getAllItems();
    boolean found = false;
    for (SWTBotTreeItem item : treeItems) {
        found = item.getText().contains(objid);
        if (found)
            break;
    }
    assertTrue(found);
    confirm.close();
    selectNode(tree, useRemote, true);
    runFetch(tree);
    confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
}
Also used : Repository(org.eclipse.jgit.lib.Repository) JobJoiner(org.eclipse.egit.ui.test.JobJoiner) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 2 with JobJoiner

use of org.eclipse.egit.ui.test.JobJoiner in project egit by eclipse.

the class CompareActionsTest method testCompareWithCommit.

@Test
public void testCompareWithCommit() throws Exception {
    String compareWithCommitMenuText = util.getPluginLocalizedValue("CompareWithCommitAction.label");
    String dialogTitle = UIText.CommitSelectionDialog_WindowTitle;
    SWTBotShell dialog = openCompareWithDialog(compareWithCommitMenuText, dialogTitle);
    // use the default (the last commit) -> no changes
    assertEquals(3, dialog.bot().table().rowCount());
    dialog.bot().table().select(0);
    JobJoiner jobJoiner = JobJoiner.startListening(ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION, 60, TimeUnit.SECONDS);
    dialog.bot().button(IDialogConstants.OK_LABEL).click();
    jobJoiner.join();
    closeFirstEmptySynchronizeDialog();
    assertSynchronizeNoChange();
    // use the second (previous) -> should have a change
    dialog = openCompareWithDialog(compareWithCommitMenuText, dialogTitle);
    dialog.bot().table().select(1);
    jobJoiner = JobJoiner.startListening(ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION, 60, TimeUnit.SECONDS);
    dialog.bot().button(IDialogConstants.OK_LABEL).click();
    jobJoiner.join();
    assertSynchronizeFile1Changed();
}
Also used : JobJoiner(org.eclipse.egit.ui.test.JobJoiner) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 3 with JobJoiner

use of org.eclipse.egit.ui.test.JobJoiner in project egit by eclipse.

the class FetchAndMergeActionTest method checkoutBranch.

private void checkoutBranch(String branchToCheckout) {
    SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
    getProjectItem(projectExplorerTree, PROJ1).select();
    String[] menuPath = new String[] { util.getPluginLocalizedValue("TeamMenu.label"), util.getPluginLocalizedValue("SwitchToMenu.label"), branchToCheckout };
    JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.CHECKOUT, 60, TimeUnit.SECONDS);
    ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
    jobJoiner.join();
}
Also used : JobJoiner(org.eclipse.egit.ui.test.JobJoiner) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)

Example 4 with JobJoiner

use of org.eclipse.egit.ui.test.JobJoiner in project egit by eclipse.

the class SynchronizeViewPushTest method shouldUpdateTrackingBranchOnPush.

@Test
public void shouldUpdateTrackingBranchOnPush() throws Exception {
    makeChangesAndCommit(PROJ1);
    Repository repository = lookupRepository(repositoryFile);
    ObjectId headId = repository.resolve(Constants.HEAD);
    String trackingBranch = Constants.R_REMOTES + "origin/master";
    launchSynchronization(Constants.HEAD, trackingBranch, false);
    SWTBotView viewBot = bot.viewById(ISynchronizeView.VIEW_ID);
    SWTBotToolbarButton pushButton = viewBot.toolbarButton(UIText.GitActionContributor_Push);
    JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.PUSH, 30, TimeUnit.SECONDS);
    pushButton.click();
    TestUtil.openJobResultDialog(jobJoiner.join());
    String destinationString = repositoryFile.getParentFile().getName() + " - " + "origin";
    SWTBotShell resultDialog = bot.shell(NLS.bind(UIText.PushResultDialog_title, destinationString));
    resultDialog.close();
    Repository remoteRepository = lookupRepository(childRepositoryFile);
    ObjectId masterOnRemote = remoteRepository.resolve("master");
    assertThat("Expected push to update branch on remote repository", masterOnRemote, is(headId));
    ObjectId trackingId = repository.resolve(trackingBranch);
    assertThat("Expected tracking branch to be updated", trackingId, is(headId));
}
Also used : Repository(org.eclipse.jgit.lib.Repository) ObjectId(org.eclipse.jgit.lib.ObjectId) JobJoiner(org.eclipse.egit.ui.test.JobJoiner) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test)

Example 5 with JobJoiner

use of org.eclipse.egit.ui.test.JobJoiner in project egit by eclipse.

the class ReplaceActionsTest method executeReplace.

private void executeReplace(SWTBotShell dialog, String buttonLabel) {
    JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.DISCARD_CHANGES, 30, TimeUnit.SECONDS);
    dialog.bot().button(buttonLabel).click();
    jobJoiner.join();
}
Also used : JobJoiner(org.eclipse.egit.ui.test.JobJoiner)

Aggregations

JobJoiner (org.eclipse.egit.ui.test.JobJoiner)18 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)6 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)6 Repository (org.eclipse.jgit.lib.Repository)4 Test (org.junit.Test)3 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)2 IProject (org.eclipse.core.resources.IProject)1 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)1 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)1 PushOperationUI (org.eclipse.egit.ui.internal.push.PushOperationUI)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)1 SWTBotToolbarButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)1