summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorOsana Babayan <32496536+osana@users.noreply.github.com>2017-10-30 16:48:56 -0700
committerTobrun <tobrun@mapbox.com>2017-10-31 15:30:48 -0700
commit9aa2c197cad27efa2be26c50ff1e185860a270a5 (patch)
treea64785af3b437107753bf70254b4178258c58fc9 /platform/android
parent0f1296c01c08dc8569150fd7cbc0d953636033c6 (diff)
downloadqtlocation-mapboxgl-9aa2c197cad27efa2be26c50ff1e185860a270a5.tar.gz
[android] MapboxMap.animate() and Mapbox.easeCamera() should throw IllegalArgument (#10321)
if non-positive duration is passed in
Diffstat (limited to 'platform/android')
-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.java47
2 files changed, 54 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 ee21ddaaa5..7988a466be 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
@@ -846,6 +846,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() {
@@ -918,6 +922,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..5e9f94db28
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java
@@ -0,0 +1,47 @@
+package com.mapbox.mapboxsdk.maps;
+
+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.Test;
+
+import static org.mockito.Mockito.mock;
+
+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;
+ }
+}