summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java')
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java102
1 files changed, 101 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
index e6c30f4aac..6cef1898bd 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
@@ -4,18 +4,36 @@ import android.os.Parcelable;
import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException;
import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.utils.MockParcel;
+import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public class MarkerViewTest {
+ @Mock
+ MapboxMap mapboxMap;
+
+ @Mock
+ MarkerViewManager markerViewManager;
+
+ @Before
+ public void beforeTest() {
+ MockitoAnnotations.initMocks(this);
+ }
+
@Test
public void testSanity() {
MarkerViewOptions markerOptions = new MarkerViewOptions();
@@ -29,7 +47,7 @@ public class MarkerViewTest {
}
@Test(expected = InvalidMarkerPositionException.class)
- public void testInvalidMarker(){
+ public void testInvalidMarker() {
new MarkerViewOptions().getMarker();
}
@@ -111,6 +129,88 @@ public class MarkerViewTest {
}
@Test
+ public void testRotationAboveMax() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(390).position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals(marker.getRotation(), 30, 0);
+ }
+
+ @Test
+ public void testRotationBelowMin() {
+ MarkerViewOptions markerOptions = new MarkerViewOptions().rotation(-10).position(new LatLng());
+ MarkerView marker = markerOptions.getMarker();
+ assertEquals(marker.getRotation(), 350, 0);
+ }
+
+ @Test
+ public void testRotationUpdatePositive() {
+ float startRotation = 45;
+ float endRotation = 180;
+ float animationValue = 135;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ }
+
+ @Test
+ public void testRotationUpdateNegative() {
+ float startRotation = 10;
+ float endRotation = 270;
+ float animationValue = -100;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ }
+
+ @Test
+ public void testRotationUpdateMax() {
+ float startRotation = 359;
+ float endRotation = 0;
+ float animationValue = 1;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ }
+
+ @Test
+ public void testRotationUpdateMin() {
+ float startRotation = 0;
+ float endRotation = 359;
+ float animationValue = -1;
+
+ // allow calls to our mock
+ when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
+
+ MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation);
+ MarkerView marker = markerOptions.getMarker();
+ marker.setMapboxMap(mapboxMap);
+
+ marker.setRotation(endRotation);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ }
+
+ @Test
public void testVisible() {
boolean visible = false;
MarkerViewOptions markerOptions = new MarkerViewOptions().visible(visible).position(new LatLng());