Search in sources :

Example 1 with CompareEditorTester

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));
}
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 2 with CompareEditorTester

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);
}
Also used : CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) Test(org.junit.Test)

Example 3 with CompareEditorTester

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);
}
Also used : CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) Test(org.junit.Test)

Example 4 with CompareEditorTester

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));
}
Also used : CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) Test(org.junit.Test)

Example 5 with CompareEditorTester

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);
}
Also used : CompareEditorTester(org.eclipse.egit.ui.common.CompareEditorTester) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) IFile(org.eclipse.core.resources.IFile) File(java.io.File) BufferedWriter(java.io.BufferedWriter) 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