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()));
}
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));
}
}
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"));
}
Aggregations