use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.
the class SynchronizeViewGitChangeSetModelTest method shouldStagePartialChangeInCompareEditor.
@Test
public void shouldStagePartialChangeInCompareEditor() 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.copyLeftToRight", null);
}
});
compareEditor.save();
// then file FILE1 should be in index
Repository repo = lookupRepository(repositoryFile);
Status status;
try (Git git = new Git(repo)) {
status = git.status().call();
}
assertThat(Long.valueOf(status.getChanged().size()), is(Long.valueOf(1L)));
assertThat(status.getChanged().iterator().next(), is(PROJ1 + "/" + FOLDER + "/" + FILE1));
}
use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.
the class SynchronizeViewGitChangeSetModelTest method shouldOpenCompareEditor.
@Test
public void shouldOpenCompareEditor() throws Exception {
// given
changeFilesInProject();
// when
launchSynchronization(HEAD, INITIAL_TAG, true);
// then
CompareEditorTester compare = getCompareEditorForFileInGitChangeSet(FILE1, true);
assertNotNull(compare);
}
use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.
the class SynchronizeViewWorkspaceModelTest method shouldOpenCompareEditor.
@Test
public void shouldOpenCompareEditor() throws Exception {
// given
makeChangesAndCommit(PROJ1);
changeFilesInProject();
// when
launchSynchronization(HEAD, INITIAL_TAG, true);
// then
CompareEditorTester compare = getCompareEditorForFileInWorkspaceModel(FILE1);
assertNotNull(compare);
}
use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.
the class SynchronizeViewWorkspaceModelTest method shouldExchangeCompareEditorSidesBetweenIncomingAndOutgoingChanges.
@Test
public void shouldExchangeCompareEditorSidesBetweenIncomingAndOutgoingChanges() throws Exception {
// given
makeChangesAndCommit(PROJ1);
// compare HEAD against tag
launchSynchronization(HEAD, INITIAL_TAG, false);
CompareEditorTester outgoingCompare = getCompareEditorForFileInWorkspaceModel(FILE1);
// save left value from compare editor
String outgoingLeft = outgoingCompare.getLeftEditor().getText();
// save right value from compare editor
String outgoingRight = outgoingCompare.getRightEditor().getText();
outgoingCompare.close();
// when
// compare tag against HEAD
launchSynchronization(INITIAL_TAG, HEAD, false);
// then
CompareEditorTester incomingComp = getCompareEditorForFileInWorkspaceModel(FILE1);
String incomingLeft = incomingComp.getLeftEditor().getText();
String incomingRight = incomingComp.getRightEditor().getText();
// right side from compare editor should be equal with left
assertThat(outgoingLeft, equalTo(incomingRight));
// left side from compare editor should be equal with right
assertThat(outgoingRight, equalTo(incomingLeft));
}
use of org.eclipse.egit.ui.common.CompareEditorTester in project egit by eclipse.
the class SynchronizeViewGitChangeSetModelTest method shouldShowCompareEditorForNonWorkspaceFileFromSynchronization.
@Test
public void shouldShowCompareEditorForNonWorkspaceFileFromSynchronization() throws Exception {
// given
String content = "file content";
String name = "non-workspace.txt";
File root = new File(getTestDirectory(), REPO1);
File nonWorkspace = new File(root, name);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(nonWorkspace), "UTF-8"));
writer.append(content);
writer.close();
// TODO Synchronize currently shows "No changes" when the only thing that has
// changed is a non-workspace file, so add another change so that this
// does not happen. When the bug is fixed, this should be removed.
setTestFileContent("other content");
// when
launchSynchronization(INITIAL_TAG, HEAD, true);
// then
CompareEditorTester editor = getCompareEditorForNonWorkspaceFileInGitChangeSet(name);
String left = editor.getLeftEditor().getText();
String right = editor.getRightEditor().getText();
assertEquals(content, left);
assertEquals("", right);
}
Aggregations