Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java10
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java34
2 files changed, 41 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
index 53c56ff0bd..a1b6f4e8f3 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java
@@ -756,13 +756,17 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase {
}
protected String getTestFileContent() throws Exception {
+ return getTestFileContent(FILE1);
+ }
+
+ protected String getTestFileContent(String fileName) throws Exception {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
- .getFile(new Path("folder/test.txt"));
+ .getFolder(FOLDER).getFile(fileName);
if (file.exists()) {
byte[] bytes = IO.readFully(file.getLocation().toFile());
return new String(bytes, file.getCharset());
- } else
- return "";
+ }
+ return "";
}
/**
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
index 9a984b58d2..65e0d934df 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
@@ -36,6 +36,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.op.CommitOperation;
import org.eclipse.egit.core.op.TagOperation;
+import org.eclipse.egit.core.test.TestUtils;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
@@ -130,6 +131,39 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
}
@Test
+ public void testCheckoutWithConflictsAndReset() throws Exception {
+ String charset = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(PROJ1).getDefaultCharset();
+ String file1Content = getTestFileContent();
+ checkoutAndVerify(new String[] { LOCAL_BRANCHES, "stable" });
+ ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
+ .getFolder(FOLDER).getFile(FILE1).setContents(
+ new ByteArrayInputStream(
+ "New content".getBytes(charset)),
+ IResource.NONE, null);
+ String file2Content = "Also changed";
+ ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1)
+ .getFolder(FOLDER).getFile(FILE2).setContents(
+ new ByteArrayInputStream(
+ file2Content.getBytes(charset)),
+ IResource.NONE, null);
+ checkout(new String[] { LOCAL_BRANCHES, "master" });
+ SWTBotShell showConflicts = bot
+ .shell(UIText.BranchResultDialog_CheckoutConflictsTitle);
+ SWTBot shellBot = showConflicts.bot();
+ SWTBotTreeItem[] items = shellBot.tree().getAllItems();
+ assertEquals(1, items.length);
+ assertEquals(FILE1, items[0].getItems()[0].getItems()[0].getText());
+ shellBot.button(UIText.BranchResultDialog_buttonDiscardChanges).click();
+ TestUtils.waitForJobs(500, 5000, JobFamilies.DISCARD_CHANGES);
+ TestUtil.joinJobs(JobFamilies.CHECKOUT);
+ assertEquals(file1Content, getTestFileContent());
+ // FILE2 should _not_ have been reset since it didn't conflict with the
+ // checkout and wasn't shown in the conflict dialog
+ assertEquals(file2Content, getTestFileContent(FILE2));
+ }
+
+ @Test
public void testCheckoutWithNonDeleted() throws Exception {
// we need to check if this file system has problems to
// delete a file with an open FileInputStrem

Back to the top