diff options
author | Guy Perron | 2014-06-11 19:08:30 +0000 |
---|---|---|
committer | Sam Davis | 2014-07-30 21:28:18 +0000 |
commit | c0e11f3f3fceedd5e917203560f9ddd486757609 (patch) | |
tree | 5291a35e78a4c12d2d88ce465c170a0344559822 /org.eclipse.mylyn.reviews.tests | |
parent | bfa12d80327edac1ecf7e5a29b194cadea96740e (diff) | |
download | org.eclipse.mylyn.reviews-c0e11f3f3fceedd5e917203560f9ddd486757609.tar.gz org.eclipse.mylyn.reviews-c0e11f3f3fceedd5e917203560f9ddd486757609.tar.xz org.eclipse.mylyn.reviews-c0e11f3f3fceedd5e917203560f9ddd486757609.zip |
423242: Add ability to edit comment from compare navigator popup
Change-Id: Icf07632123a7f0dc87680a402719b4fca8642832
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=423242
Signed-off-by: Guy Perron <guy.perron@ericsson.com>
Diffstat (limited to 'org.eclipse.mylyn.reviews.tests')
5 files changed, 261 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.reviews.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.reviews.tests/META-INF/MANIFEST.MF index 1d8d8f93b..641435916 100644 --- a/org.eclipse.mylyn.reviews.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.reviews.tests/META-INF/MANIFEST.MF @@ -25,7 +25,9 @@ Require-Bundle: org.hamcrest;bundle-version="1.1.0", org.eclipse.emf.ecore;bundle-version="2.5.0", org.eclipse.emf.edit;bundle-version="2.5.0", org.apache.commons.io, - org.eclipse.jface.text + org.eclipse.jface.text, + org.mockito;bundle-version="1.8.4" Export-Package: org.eclipse.mylyn.reviews.spi.edit.remote;x-internal:=true, org.eclipse.mylyn.reviews.tests;x-internal:=true, org.eclipse.mylyn.reviews.tests.ui;x-internal:=true +Import-Package: org.eclipse.compare.internal diff --git a/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/AllReviewsTests.java b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/AllReviewsTests.java index 65560ec10..e015dafdf 100644 --- a/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/AllReviewsTests.java +++ b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/AllReviewsTests.java @@ -16,6 +16,7 @@ import junit.framework.TestSuite; import org.eclipse.mylyn.reviews.spi.edit.remote.AbstractRemoteEditFactoryProviderTest; import org.eclipse.mylyn.reviews.tests.ui.ReviewAnnotationModelTest; +import org.eclipse.mylyn.reviews.tests.ui.ReviewCompareAnnotationSupportTest; import org.eclipse.mylyn.reviews.tests.ui.ReviewUiTest; import org.eclipse.mylyn.reviews.tests.ui.UiDataLocatorTest; @@ -30,6 +31,7 @@ public class AllReviewsTests { suite.addTestSuite(UiDataLocatorTest.class); suite.addTestSuite(AbstractRemoteEditFactoryProviderTest.class); suite.addTestSuite(ReviewAnnotationModelTest.class); + suite.addTestSuite(ReviewCompareAnnotationSupportTest.class); return suite; } diff --git a/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewAnnotationModelTest.java b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewAnnotationModelTest.java index 7099a36e1..950cf87fa 100644 --- a/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewAnnotationModelTest.java +++ b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewAnnotationModelTest.java @@ -7,6 +7,7 @@ * * Contributors: * Tasktop Technologies - initial API and implementation + * Guy Perron 423242: Add ability to edit comment from compare navigator popup *******************************************************************************/ package org.eclipse.mylyn.reviews.tests.ui; @@ -38,6 +39,7 @@ import org.eclipse.team.core.history.IFileRevision; /** * @author Leo Dos Santos + * @author Guy Perron */ public class ReviewAnnotationModelTest extends TestCase { @@ -67,6 +69,11 @@ public class ReviewAnnotationModelTest extends TestCase { return null; } + @Override + public IStatus discardComment(IReviewItem fileItem, IComment comment, IProgressMonitor monitor) { + return null; + } + } @Override @@ -117,6 +124,13 @@ public class ReviewAnnotationModelTest extends TestCase { iter = model.getAnnotationIterator(); assertEquals(2, getCount(iter)); + + notification = new NotificationImpl(Notification.REMOVE, newComment, null); + model.getItem().eNotify(notification); + + iter = model.getAnnotationIterator(); + assertEquals(1, getCount(iter)); + } private int getCount(Iterator<CommentAnnotation> iter) { diff --git a/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewCompareAnnotationSupportTest.java b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewCompareAnnotationSupportTest.java new file mode 100644 index 000000000..5bc7cae93 --- /dev/null +++ b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewCompareAnnotationSupportTest.java @@ -0,0 +1,233 @@ +/******************************************************************************* + * Copyright (c) 2014 Ericsson. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Guy Perron - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.reviews.tests.ui; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import junit.framework.TestCase; + +import org.eclipse.compare.internal.MergeSourceViewer; +import org.eclipse.jface.text.Position; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.mylyn.internal.reviews.ui.compare.Direction; +import org.eclipse.mylyn.internal.reviews.ui.compare.ReviewCompareAnnotationSupport; +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mock; + +/** + * @author Guy Perron + */ +public class ReviewCompareAnnotationSupportTest extends TestCase { + + @Mock + private ReviewCompareAnnotationSupport rcaSupportspy; + + @Override + public void setUp() throws Exception { + super.setUp(); + ListViewer mockListViewer = mock(ListViewer.class); + ReviewCompareAnnotationSupport rcaSupport = new ReviewCompareAnnotationSupport(mockListViewer); + + rcaSupportspy = spy(rcaSupport); + doNothing().when(rcaSupportspy).moveToAnnotation((MergeSourceViewer) Matchers.any(), + (MergeSourceViewer) Matchers.any(), (Position) Matchers.any()); + + } + + //Test FORWARDS direction + + @Test + public void testNextAnnotFwdLeftBeforeRightOffsetAfterBoth() throws Exception { + int ret; + + // Position left < right, currentLeftOffset > Left and Right position, moving forward + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(5, 0); + Position nextRightPosition = new Position(8, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.FORWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.LEFT_SIDE, ret); + } + + @Test + public void testNextAnnotFwdLeftAfterRightOffsetAfterBoth() throws Exception { + int ret; + + // Position left > right, currentLeftOffset >Left and Right position, moving forward + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(5, 0); + Position nextRightPosition = new Position(3, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.FORWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.RIGHT_SIDE, ret); + } + + @Test + public void testNextAnnotFwdLeftBeforeRightOffsetBeforeBoth() throws Exception { + int ret; + + // Position left < right, currentLeftOffset < Left and Right position, moving forward + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(15, 0); + Position nextRightPosition = new Position(16, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.FORWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.LEFT_SIDE, ret); + } + + @Test + public void testNextAnnotFwdLeftAfterRightOffsetBeforeBoth() throws Exception { + int ret; + + // Position left > right, currentLeftOffset < Left and Right position, moving forward + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(20, 0); + Position nextRightPosition = new Position(15, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.FORWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.RIGHT_SIDE, ret); + } + + @Test + public void testNextAnnotFwdLeftBeforeRightOffsetAfterLeftBeforeRightAfter() throws Exception { + int ret; + + // Position left < right, currentLeftOffset > Left and currentLeftOffset < Right, moving forward + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(5, 0); + Position nextRightPosition = new Position(15, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.FORWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.RIGHT_SIDE, ret); + } + + @Test + public void testNextAnnotFwdLeftAfterRightOffsetBeforeLeftAfterRight() throws Exception { + int ret; + + // left > right, currentLeftOffset < left && currentLeftOffset > Right , moving forward + int currentLeftOffset = 1; + Position nextLeftPosition = new Position(10, 0); + Position nextRightPosition = new Position(0, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.FORWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.LEFT_SIDE, ret); + } + + @Test + public void testNextAnnotFwdLeftAfterRightOffsetEqualLeftAfterRight() throws Exception { + int ret; + + // Position left > right, currentLeftOffset = next left && currentLeftOffset > next Right, moving forward + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(10, 0); + Position nextRightPosition = new Position(0, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.FORWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.RIGHT_SIDE, ret); + } + + //Test BACKWARDS direction + @Test + public void testNextAnnotBwdLeftAfterRightOffsetBeforeBoth() throws Exception { + int ret; + + // left after right, currentLeftOffset is before both position, moving backwards + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(20, 0); + Position nextRightPosition = new Position(15, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.BACKWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.LEFT_SIDE, ret); + } + + @Test + public void testNextAnnotBwdLeftBeforeRightOffsetBeforeBoth() throws Exception { + int ret; + + // left before right, currentLeftOffset is before both position, moving backwards + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(20, 0); + Position nextRightPosition = new Position(25, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.BACKWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.RIGHT_SIDE, ret); + } + + @Test + public void testNextAnnotBwdLeftAfterRightOffsetAfterBoth() throws Exception { + int ret; + + // left after right, currentLeftOffset is after both position, moving backwards + int currentLeftOffset = 15; + Position nextLeftPosition = new Position(10, 0); + Position nextRightPosition = new Position(0, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.BACKWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.LEFT_SIDE, ret); + } + + @Test + public void testNextAnnotBwdLeftBeforeRightOffsetAfterBoth() throws Exception { + int ret; + + // left after right, currentLeftOffset is after both position, moving backwards + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(5, 0); + Position nextRightPosition = new Position(8, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.BACKWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.RIGHT_SIDE, ret); + } + + @Test + public void testNextAnnotBwdLeftAfterRightOffsetLeftAfterRightBefore() throws Exception { + int ret; + + // left after right, currentLeftOffset is before Left and After Right position, moving backwards + int currentLeftOffset = 1; + Position nextLeftPosition = new Position(10, 0); + Position nextRightPosition = new Position(0, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.BACKWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.RIGHT_SIDE, ret); + } + + @Test + public void testNextAnnotBwdLeftBeforeRightOffsetLeftBeforeRightAfter() throws Exception { + int ret; + + // left before right, currentLeftOffset is after Left and Before Right, moving backwards + int currentLeftOffset = 10; + Position nextLeftPosition = new Position(5, 0); + Position nextRightPosition = new Position(15, 0); + ret = rcaSupportspy.calculateNextAnnotation(Direction.BACKWARDS, nextLeftPosition, nextRightPosition, + currentLeftOffset); + + assertEquals(rcaSupportspy.LEFT_SIDE, ret); + } + +} diff --git a/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewUiTest.java b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewUiTest.java index d0de291e4..9c60e6b8e 100644 --- a/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewUiTest.java +++ b/org.eclipse.mylyn.reviews.tests/src/org/eclipse/mylyn/reviews/tests/ui/ReviewUiTest.java @@ -7,6 +7,8 @@ * * Contributors: * Tasktop Technologies - initial API and implementation + * Guy Perron 423242: Add ability to edit comment from compare navigator popup + *******************************************************************************/ package org.eclipse.mylyn.reviews.tests.ui; @@ -25,6 +27,7 @@ import org.junit.Test; /** * @author Steffen Pingel + * @author Guy Perron */ public class ReviewUiTest extends TestCase { @@ -42,6 +45,12 @@ public class ReviewUiTest extends TestCase { // ignore return null; } + + @Override + public IStatus discardComment(IReviewItem fileItem, IComment comment, IProgressMonitor monitor) { + // ignore + return null; + } }; ReviewUi.setActiveReview(activeReview); assertEquals(activeReview, ReviewUi.getActiveReview()); |