Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-04-22 17:06:57 -0400
committerMichael Keppler2019-04-26 04:00:13 -0400
commit95bf547c006e288a7cd42b99f03ceaa42a9279b9 (patch)
tree20e5d189deab8d780f429d493ec0772dd1042a07 /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test
parent24be8bb6bbd055678ce1e0c93a6a624da09582dd (diff)
downloadegit-95bf547c006e288a7cd42b99f03ceaa42a9279b9.tar.gz
egit-95bf547c006e288a7cd42b99f03ceaa42a9279b9.tar.xz
egit-95bf547c006e288a7cd42b99f03ceaa42a9279b9.zip
Only warn about losing changes if there are changes at all
Only show the confirmation dialog for DiscardChangesOperation if there are actually uncommitted changes on the selected files. Bug: 546194 Change-Id: Id63601bcc9e307a8a3f6bd0456dfdd2923b76b80 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/ReplaceActionsTest.java54
1 files changed, 43 insertions, 11 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/ReplaceActionsTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/ReplaceActionsTest.java
index 4d4793e45..a7daa7cbc 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/ReplaceActionsTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/ReplaceActionsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 SAP AG and others.
+ * Copyright (c) 2012, 2019 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -53,8 +53,28 @@ public class ReplaceActionsTest extends LocalRepositoryTestCase {
@Test
public void testReplaceWithPrevious() throws Exception {
+ String initialContent = getTestFileContent();
touchAndSubmit(null);
+ assertThat(getTestFileContent(), not(initialContent));
+ String menuLabel = util.getPluginLocalizedValue(
+ "ReplaceWithPreviousVersionAction.label");
+ JobJoiner jobJoiner = JobJoiner.startListening(
+ JobFamilies.DISCARD_CHANGES, 30, TimeUnit.SECONDS);
+ clickReplaceWith(menuLabel);
+ jobJoiner.join();
+ assertEquals(initialContent, getTestFileContent());
+ }
+
+ @Test
+ public void testReplaceWithPreviousChanged() throws Exception {
String initialContent = getTestFileContent();
+ touchAndSubmit(null);
+ String newContent = getTestFileContent();
+ assertThat(newContent, not(initialContent));
+ touch("Something else");
+ String changedContent = getTestFileContent();
+ assertThat(changedContent, not(initialContent));
+ assertThat(changedContent, not(newContent));
String menuLabel = util
.getPluginLocalizedValue(
"ReplaceWithPreviousVersionAction.label");
@@ -63,8 +83,28 @@ public class ReplaceActionsTest extends LocalRepositoryTestCase {
.shell(UIText.DiscardChangesAction_confirmActionTitle);
executeReplace(confirm,
UIText.DiscardChangesAction_discardChangesButtonText);
- String replacedContent = getTestFileContent();
- assertThat(replacedContent, not(initialContent));
+ assertEquals(initialContent, getTestFileContent());
+ }
+
+ @Test
+ public void testReplaceWithPreviousChangedClosed() throws Exception {
+ String initialContent = getTestFileContent();
+ touchAndSubmit(null);
+ String newContent = getTestFileContent();
+ assertThat(newContent, not(initialContent));
+ touch("Something else");
+ String changedContent = getTestFileContent();
+ assertThat(changedContent, not(initialContent));
+ assertThat(changedContent, not(newContent));
+ String menuLabel = util.getPluginLocalizedValue(
+ "ReplaceWithPreviousVersionAction.label");
+ clickReplaceWith(menuLabel);
+ SWTBotShell confirm = bot
+ .shell(UIText.DiscardChangesAction_confirmActionTitle);
+ confirm.close();
+ TestUtil.processUIEvents();
+ // Confirmation closed, nothing should have changed
+ assertEquals(changedContent, getTestFileContent());
}
@Test
@@ -104,9 +144,6 @@ public class ReplaceActionsTest extends LocalRepositoryTestCase {
.getPluginLocalizedValue(
"ReplaceWithPreviousVersionAction.label");
clickReplaceWith(menuLabel);
- bot.shell(UIText.DiscardChangesAction_confirmActionTitle).bot()
- .button(UIText.DiscardChangesAction_discardChangesButtonText)
- .click();
SWTBotShell selectDialog = bot
.shell(UIText.CommitSelectDialog_WindowTitle);
assertEquals(2, selectDialog.bot().table().rowCount());
@@ -118,11 +155,6 @@ public class ReplaceActionsTest extends LocalRepositoryTestCase {
assertEquals(contentAfterMerge, contentAfterClose);
clickReplaceWith(menuLabel);
- bot.shell(UIText.DiscardChangesAction_confirmActionTitle).bot()
- .button(UIText.DiscardChangesAction_discardChangesButtonText)
- .click();
- TestUtil.waitForJobs(100, 5000);
-
selectDialog = bot.shell(UIText.CommitSelectDialog_WindowTitle);
// Select first parent, which should be the master commit
SWTBotTable table = selectDialog.bot().table();

Back to the top