summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOsana Babayan <osanababayan@Osanas-MBP.localdomain>2017-10-30 13:00:16 -0700
committerOsana Babayan <osanababayan@Osanas-MBP.localdomain>2017-10-30 13:00:16 -0700
commiteca94e4fa6bafff336301bcfe1ef8de02814de6f (patch)
treea3455b38483b7dc28a3f15427feb5cae378f8309
parent484c04a924565feade99f162826152fcf3acb8b9 (diff)
downloadqtlocation-mapboxgl-upstream/osana-10313.tar.gz
[android] MapboxMap.animate() and Mapbox.easeCamera() should throw IllegalArgumentupstream/osana-10313
if non-positive duration is passed in
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java7
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java58
2 files changed, 65 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
index c417b3fc26..f25e05429e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
@@ -834,6 +834,10 @@ public final class MapboxMap {
*/
public final void easeCamera(final CameraUpdate update, final int durationMs, final boolean easingInterpolator,
final MapboxMap.CancelableCallback callback, final boolean isDismissable) {
+
+ if (durationMs <= 0) {
+ throw new IllegalArgumentException("Null duration passed into easeCamera");
+ }
new Handler().post(new Runnable() {
@Override
public void run() {
@@ -906,6 +910,9 @@ public final class MapboxMap {
*/
public final void animateCamera(final CameraUpdate update, final int durationMs,
final MapboxMap.CancelableCallback callback) {
+ if (durationMs <= 0) {
+ throw new IllegalArgumentException("Null duration passed into animageCamera");
+ }
new Handler().post(new Runnable() {
@Override
public void run() {
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
new file mode 100644
index 0000000000..87c9549498
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
@@ -0,0 +1,58 @@
+package com.mapbox.mapboxsdk.maps;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.mapbox.mapboxsdk.camera.CameraPosition;
+import com.mapbox.mapboxsdk.camera.CameraUpdate;
+import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.mockito.InjectMocks;
+import static org.mockito.Mockito.mock;
+/**
+ * Created by osanababayan on 10/30/17.
+ */
+
+public class MapboxMapTest {
+
+
+ private MapboxMap mapboxMap;
+
+ @Before
+ public void beforeTest() {
+
+ mapboxMap = new MapboxMap(mock(NativeMapView.class),
+ mock(Transform.class),
+ mock(UiSettings.class),
+ mock(TrackingSettings.class),
+ mock(MyLocationViewSettings.class),
+ mock(Projection.class),
+ mock(MapboxMap.OnRegisterTouchListener.class),
+ mock(AnnotationManager.class),
+ mock(CameraChangeDispatcher.class));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testAnimateCameraChecksDurationPositive() {
+ mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(30.0,30.0)),
+ 0, null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testEaseCameraChecksDurationPositive() {
+ mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(new LatLng(30.0,30.0)),
+ 0, null);
+ }
+
+ @After
+ public void afterTest() {
+ mapboxMap = null;
+ }
+}