Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Nittka2020-03-11 09:58:41 +0000
committerThomas Wolf2020-04-04 10:15:16 +0000
commit0498bada02b90e1c5505cf21b7000278a5eaae91 (patch)
tree12a21ecc6be36bc01de63cf2e0f4129017cf3c9a /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui
parent4ca1dc20348c630b5c9cacecfda9233861e2834c (diff)
downloadegit-0498bada02b90e1c5505cf21b7000278a5eaae91.tar.gz
egit-0498bada02b90e1c5505cf21b7000278a5eaae91.tar.xz
egit-0498bada02b90e1c5505cf21b7000278a5eaae91.zip
[staging view ] commit button enablement
The commit button should be enabled only if there is something to commit. Bug: 525685 Change-Id: Ib5915668a0e96786c01e431f685fb4bce13aa613 Signed-off-by: Alexander Nittka <alex@nittka.de>
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/StagingViewTester.java22
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java24
2 files changed, 46 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java
index f08691bcef..f224061fad 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/StagingViewTester.java
@@ -108,6 +108,24 @@ public class StagingViewTester {
jobJoiner.join();
}
+ public void unStageFile(String path) {
+ SWTBotTree stagedTree = stagingView.bot().tree(1);
+
+ TestUtil.waitUntilTreeHasNodeContainsText(stagingView.bot(), stagedTree,
+ path, 10000);
+
+ TestUtil.getNode(stagedTree.getAllItems(), path).select();
+
+ JobJoiner jobJoiner = JobJoiner.startListening(
+ org.eclipse.egit.core.JobFamilies.INDEX_DIFF_CACHE_UPDATE, 30,
+ TimeUnit.SECONDS);
+
+ ContextMenuHelper.clickContextMenu(stagedTree,
+ UIText.StagingView_UnstageItemMenuLabel);
+
+ jobJoiner.join();
+ }
+
public void commit() throws Exception {
JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.COMMIT, 30,
TimeUnit.SECONDS);
@@ -166,6 +184,10 @@ public class StagingViewTester {
return button.isChecked();
}
+ public boolean isCommitEnabled() {
+ return stagingView.bot().button(UIText.StagingView_Commit).isEnabled();
+ }
+
private void selectToolbarToggle(SWTBotToolbarToggleButton button,
boolean select) {
if (select) {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
index 186b283553..a006ee944c 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/stagview/StagingViewTest.java
@@ -50,6 +50,8 @@ public class StagingViewTest extends AbstractStagingViewTestCase {
stagingViewTester.commit();
TestUtil.checkHeadCommit(repository, TestUtil.TESTAUTHOR,
TestUtil.TESTCOMMITTER, "The new commit");
+ assertFalse("Commit Button should be disabled",
+ stagingViewTester.isCommitEnabled());
}
@Test
@@ -387,4 +389,26 @@ public class StagingViewTest extends AbstractStagingViewTestCase {
&& commitMessage.contains(expectedCommitter)
&& !commitMessage.contains(TestUtil.TESTCOMMITTER));
}
+
+ @Test
+ public void testButtonEnablement() throws Exception {
+ StagingViewTester stagingViewTester = StagingViewTester
+ .openStagingView();
+ stagingViewTester.assertCommitEnabled(false);
+
+ setContent("I have changed this");
+ stagingViewTester.assertCommitEnabled(false);
+
+ stagingViewTester.stageFile(FILE1_PATH);
+ stagingViewTester.assertCommitEnabled(true);
+
+ stagingViewTester.unStageFile(FILE1_PATH);
+ stagingViewTester.assertCommitEnabled(false);
+
+ stagingViewTester.setAmend(true);
+ stagingViewTester.assertCommitEnabled(true);
+
+ stagingViewTester.setAmend(false);
+ stagingViewTester.assertCommitEnabled(false);
+ }
}

Back to the top