Search in sources :

Example 6 with CompareEditorTester

use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.

the class SynchronizeViewGitChangeSetModelTest method shouldExchangeCompareEditorSidesBetweenIncomingAndOutgoingChanges.

@Test
public void shouldExchangeCompareEditorSidesBetweenIncomingAndOutgoingChanges() throws Exception {
    // given
    makeChangesAndCommit(PROJ1);
    // compare HEAD against tag
    launchSynchronization(HEAD, INITIAL_TAG, false);
    CompareEditorTester outgoingCompare = getCompareEditorForFileInGitChangeSet(FILE1, false);
    // save left value from compare editor
    String outgoingLeft = outgoingCompare.getLeftEditor().getText();
    // save right value from compare editor
    String outgoingRight = outgoingCompare.getRightEditor().getText();
    outgoingCompare.close();
    assertNotSame("Text from SWTBot widgets was the same", outgoingLeft, outgoingRight);
    // when
    // compare tag against HEAD
    launchSynchronization(INITIAL_TAG, HEAD, false);
    // then
    CompareEditorTester incomingComp = getCompareEditorForFileInGitChangeSet(FILE1, false);
    // right side from compare editor should be equal with left
    assertThat(outgoingLeft, equalTo(incomingComp.getRightEditor().getText()));
    // left side from compare editor should be equal with right
    assertThat(outgoingRight, equalTo(incomingComp.getLeftEditor().getText()));
}
Also used : CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) Test(org.junit.Test)

Example 7 with CompareEditorTester

use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.

the class SynchronizeViewGitChangeSetModelTest method shouldUnStagePartialChangeInCompareEditor.

@Test
public void shouldUnStagePartialChangeInCompareEditor() throws Exception {
    // given
    changeFilesInProject();
    launchSynchronization(HEAD, HEAD, true);
    CompareEditorTester compareEditor = getCompareEditorForFileInGitChangeSet(FILE1, true);
    // when
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            CommonUtils.runCommand("org.eclipse.compare.copyRightToLeft", null);
        }
    });
    compareEditor.save();
    // then file FILE1 should be unchanged in working tree
    Repository repo = lookupRepository(repositoryFile);
    try (Git git = new Git(repo)) {
        Status status = git.status().call();
        assertThat(Long.valueOf(status.getModified().size()), is(Long.valueOf(1)));
        assertThat(status.getModified().iterator().next(), is(PROJ1 + "/" + FOLDER + "/" + FILE2));
    }
}
Also used : Status(org.eclipse.jgit.api.Status) Repository(org.eclipse.jgit.lib.Repository) Git(org.eclipse.jgit.api.Git) CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) Test(org.junit.Test)

Example 8 with CompareEditorTester

use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.

the class MergeToolTest method useHeadOptionShouldCauseFileToNotHaveConflictMarkers.

@Test
public void useHeadOptionShouldCauseFileToNotHaveConflictMarkers() throws Exception {
    IPath path = new Path(PROJ1).append("folder/test.txt");
    testRepository.branch("stable").commit().add(path.toString(), "stable").create();
    touchAndSubmit("master", "master");
    MergeOperation mergeOp = new MergeOperation(testRepository.getRepository(), "stable");
    mergeOp.execute(null);
    MergeResult mergeResult = mergeOp.getResult();
    assertThat(mergeResult.getMergeStatus(), is(MergeStatus.CONFLICTING));
    assertThat(mergeResult.getConflicts().keySet(), hasItem(path.toString()));
    IndexDiffCache cache = Activator.getDefault().getIndexDiffCache();
    cache.getIndexDiffCacheEntry(testRepository.getRepository());
    TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
    SWTBotTree packageExplorer = TestUtil.getExplorerTree();
    SWTBotTreeItem project1 = getProjectItem(packageExplorer, PROJ1).select();
    SWTBotTreeItem folderNode = TestUtil.expandAndWait(project1).getNode(FOLDER);
    SWTBotTreeItem fileNode = TestUtil.expandAndWait(folderNode).getNode(FILE1);
    fileNode.select();
    ContextMenuHelper.clickContextMenu(packageExplorer, util.getPluginLocalizedValue("TeamMenu.label"), util.getPluginLocalizedValue("MergeToolAction.label"));
    CompareEditorTester compareEditor = CompareEditorTester.forTitleContaining("Merging");
    String text = compareEditor.getLeftEditor().getText();
    assertThat(text, is("master"));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) MergeOperation(org.eclipse.egit.core.op.MergeOperation) IPath(org.eclipse.core.runtime.IPath) CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) MergeResult(org.eclipse.jgit.api.MergeResult) IndexDiffCache(org.eclipse.egit.core.internal.indexdiff.IndexDiffCache) Test(org.junit.Test)

Aggregations

CompareEditorTester (org.eclipse.egit.ui.common.CompareEditorTester)8 Test (org.junit.Test)8 Git (org.eclipse.jgit.api.Git)2 Status (org.eclipse.jgit.api.Status)2 Repository (org.eclipse.jgit.lib.Repository)2 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IndexDiffCache (org.eclipse.egit.core.internal.indexdiff.IndexDiffCache)1 MergeOperation (org.eclipse.egit.core.op.MergeOperation)1 MergeResult (org.eclipse.jgit.api.MergeResult)1 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1