diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-04-23 10:44:02 -0400 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-04-23 10:44:02 -0400 |
commit | e08b6fe87f5824ab05a4cc67d9a76af5bb5ddd3b (patch) | |
tree | 886e10260bfa044f62943186ec837b9ccd02934c /platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps | |
parent | 2bb785dad2489d04db179fa9cf65514640db0a96 (diff) | |
parent | a45670cfb5752866b9c8130024a313944684c2db (diff) | |
download | qtlocation-mapboxgl-upstream/fabian-merge-v4.0.0.tar.gz |
Merge branch 'release-boba' into masterupstream/fabian-merge-v4.0.0
# Conflicts:
# circle.yml
# include/mbgl/style/expression/let.hpp
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
# platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
# platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
# platform/android/gradle/dependencies.gradle
# platform/android/src/example_custom_layer.cpp
# platform/android/src/geojson/point.cpp
# platform/darwin/src/NSPredicate+MGLAdditions.mm
# platform/darwin/test/MGLExpressionTests.mm
# platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec
# platform/ios/Mapbox-iOS-SDK-symbols.podspec
# platform/ios/Mapbox-iOS-SDK.podspec
# platform/ios/app/MBXViewController.m
# src/mbgl/renderer/layers/render_custom_layer.cpp
# src/mbgl/style/conversion/filter.cpp
# src/mbgl/style/expression/interpolate.cpp
# src/mbgl/style/expression/value.cpp
# test/style/filter.test.cpp
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps')
5 files changed, 76 insertions, 299 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java index 65bdff41ab..9dd0ca9285 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java @@ -119,13 +119,6 @@ public class MapboxMapOptionsTest { } @Test - public void testLocationEnabled() { - assertFalse(new MapboxMapOptions().getLocationEnabled()); - assertTrue(new MapboxMapOptions().locationEnabled(true).getLocationEnabled()); - assertFalse(new MapboxMapOptions().locationEnabled(false).getLocationEnabled()); - } - - @Test public void testTiltGesturesEnabled() { assertTrue(new MapboxMapOptions().getTiltGesturesEnabled()); assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled()); @@ -176,18 +169,6 @@ public class MapboxMapOptionsTest { } @Test - public void testMyLocationForegroundTint() { - assertEquals(Color.BLUE, new MapboxMapOptions() - .myLocationForegroundTintColor(Color.BLUE).getMyLocationForegroundTintColor()); - } - - @Test - public void testMyLocationBackgroundTint() { - assertEquals(Color.BLUE, new MapboxMapOptions() - .myLocationBackgroundTintColor(Color.BLUE).getMyLocationBackgroundTintColor()); - } - - @Test public void testPrefetchesTiles() { // Default value assertTrue(new MapboxMapOptions().getPrefetchesTiles()); 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 index d61947f00e..9a323a1d75 100644 --- 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 @@ -2,7 +2,6 @@ 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; @@ -20,8 +19,6 @@ public class MapboxMapTest { mapboxMap = new MapboxMap(mock(NativeMapView.class), mock(Transform.class), mock(UiSettings.class), - mock(TrackingSettings.class), - mock(MyLocationViewSettings.class), mock(Projection.class), mock(MapboxMap.OnGesturesManagerInteractionListener.class), mock(AnnotationManager.class), diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java deleted file mode 100644 index de5f364a5b..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.mapbox.mapboxsdk.maps; - -import android.Manifest; -import android.content.Context; -import android.content.pm.PackageManager; -import android.graphics.PointF; - -import com.mapbox.mapboxsdk.constants.MyLocationTracking; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class TrackingSettingsTest { - - @InjectMocks - MyLocationView myLocationView = mock(MyLocationView.class); - - @InjectMocks - UiSettings uiSettings = mock(UiSettings.class); - - @InjectMocks - FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); - - @InjectMocks - TrackingSettings.CameraZoomInvalidator zoomInvalidator = mock(TrackingSettings.CameraZoomInvalidator.class); - - private TrackingSettings trackingSettings; - - @Before - public void beforeTest() { - trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener, zoomInvalidator); - } - - @Test - public void testSanity() { - assertNotNull("trackingsettings should not be null", trackingSettings); - } - - @Test - public void testDismissTrackingModesOnGesture() { - trackingSettings.setDismissAllTrackingOnGesture(false); - assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isAllDismissTrackingOnGesture()); - } - - @Test - public void testValidateGesturesForTrackingModes() { - trackingSettings.setDismissAllTrackingOnGesture(false); - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - assertFalse("DismissTrackingOnGesture should be false", trackingSettings.isAllDismissTrackingOnGesture()); - } - - @Test - public void testMyLocationEnabled() { - // setup mock context to provide accepted location permission - Context context = mock(Context.class); - when(myLocationView.getContext()).thenReturn(context); - when(context.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION), anyInt(), - anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED); - - assertFalse("Location should be disabled by default.", trackingSettings.isMyLocationEnabled()); - trackingSettings.setMyLocationEnabled(true); - assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled()); - } - - @Test - public void testCameraZoomTo2forTracking() { - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - verify(zoomInvalidator, atLeast(1)).zoomTo(2.0); - } - - @Test - public void testFocalPointChangeForTracking() { - final float centerX = 32.3f; - final float centerY = 46.3f; - final PointF pointF = new PointF(centerX, centerY); - when(myLocationView.getCenter()).thenReturn(pointF); - - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(pointF); - } - - @Test - public void testFocalPointChangeForNonTracking() { - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); - verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(null); - } -} diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java index fbe00b4dce..cfce56e6e9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java @@ -181,13 +181,6 @@ public class UiSettingsTest { } @Test - public void testRotateGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isRotateGestureChangeAllowed()); - uiSettings.setRotateGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isRotateGestureChangeAllowed()); - } - - @Test public void testRotateGestureChangeAllowed() { uiSettings.setRotateGesturesEnabled(false); assertEquals("Rotate gesture should be false", false, uiSettings.isRotateGesturesEnabled()); @@ -196,14 +189,6 @@ public class UiSettingsTest { } @Test - public void testRotateGestureChangeDisallowed() { - assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled()); - uiSettings.setRotateGestureChangeAllowed(false); - uiSettings.setRotateGesturesEnabled(false); - assertEquals("Rotate gesture change should be ignored", true, uiSettings.isRotateGesturesEnabled()); - } - - @Test public void testTiltGesturesEnabled() { uiSettings.setTiltGesturesEnabled(true); assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled()); @@ -216,13 +201,6 @@ public class UiSettingsTest { } @Test - public void testTiltGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isTiltGestureChangeAllowed()); - uiSettings.setTiltGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isTiltGestureChangeAllowed()); - } - - @Test public void testTiltGestureChangeAllowed() { uiSettings.setTiltGesturesEnabled(false); assertEquals("Tilt gesture should be false", false, uiSettings.isTiltGesturesEnabled()); @@ -231,14 +209,6 @@ public class UiSettingsTest { } @Test - public void testTiltGestureChangeDisallowed() { - assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled()); - uiSettings.setTiltGestureChangeAllowed(false); - uiSettings.setTiltGesturesEnabled(false); - assertEquals("Tilt gesture change should be ignored", true, uiSettings.isTiltGesturesEnabled()); - } - - @Test public void testZoomGesturesEnabled() { uiSettings.setZoomGesturesEnabled(true); assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled()); @@ -251,13 +221,6 @@ public class UiSettingsTest { } @Test - public void testZoomGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isZoomGestureChangeAllowed()); - uiSettings.setZoomGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isZoomGestureChangeAllowed()); - } - - @Test public void testZoomGestureChangeAllowed() { uiSettings.setZoomGesturesEnabled(false); assertEquals("Zoom gesture should be false", false, uiSettings.isZoomGesturesEnabled()); @@ -266,14 +229,6 @@ public class UiSettingsTest { } @Test - public void testZoomGestureChangeDisallowed() { - assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled()); - uiSettings.setZoomGestureChangeAllowed(false); - uiSettings.setZoomGesturesEnabled(false); - assertEquals("Zooom gesture change should be ignored", true, uiSettings.isZoomGesturesEnabled()); - } - - @Test public void testZoomControlsEnabled() { uiSettings.setZoomControlsEnabled(true); assertEquals("Zoom controls should be enabled", true, uiSettings.isZoomControlsEnabled()); @@ -298,13 +253,6 @@ public class UiSettingsTest { } @Test - public void testDoubleTapGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isDoubleTapGestureChangeAllowed()); - uiSettings.setDoubleTapGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isDoubleTapGestureChangeAllowed()); - } - - @Test public void testDoubleTapGestureChangeAllowed() { uiSettings.setDoubleTapGesturesEnabled(false); assertEquals("DoubleTap gesture should be false", false, uiSettings.isDoubleTapGesturesEnabled()); @@ -313,14 +261,6 @@ public class UiSettingsTest { } @Test - public void testDoubleTapGestureChangeDisallowed() { - assertEquals("DoubleTap gesture should be true", true, uiSettings.isDoubleTapGesturesEnabled()); - uiSettings.setDoubleTapGestureChangeAllowed(false); - uiSettings.setDoubleTapGesturesEnabled(false); - assertEquals("DoubleTap gesture change should be ignored", true, uiSettings.isDoubleTapGesturesEnabled()); - } - - @Test public void testScrollGesturesEnabled() { uiSettings.setScrollGesturesEnabled(true); assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled()); @@ -333,13 +273,6 @@ public class UiSettingsTest { } @Test - public void testScrollGestureChange() { - assertEquals("Default state should be true", true, uiSettings.isScrollGestureChangeAllowed()); - uiSettings.setScrollGestureChangeAllowed(false); - assertEquals("State should have been changed", false, uiSettings.isScrollGestureChangeAllowed()); - } - - @Test public void testScrollGestureChangeAllowed() { uiSettings.setScrollGesturesEnabled(false); assertEquals("Scroll gesture should be false", false, uiSettings.isScrollGesturesEnabled()); @@ -348,11 +281,82 @@ public class UiSettingsTest { } @Test - public void testScrollGestureChangeDisallowed() { - assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled()); - uiSettings.setScrollGestureChangeAllowed(false); - uiSettings.setScrollGesturesEnabled(false); - assertEquals("Scroll gesture change should be ignored", true, uiSettings.isScrollGesturesEnabled()); + public void testScaleVelocityAnimationEnabled() { + uiSettings.setScaleVelocityAnimationEnabled(true); + assertEquals("Scale velocity animation should be enabled", true, uiSettings.isScaleVelocityAnimationEnabled()); + } + + @Test + public void testScaleVelocityAnimationDisabled() { + uiSettings.setScaleVelocityAnimationEnabled(false); + assertEquals("Scale velocity animation should be disabled", false, uiSettings.isScaleVelocityAnimationEnabled()); + } + + @Test + public void testRotateVelocityAnimationEnabled() { + uiSettings.setRotateVelocityAnimationEnabled(true); + assertEquals("Rotate velocity animation should be enabled", true, uiSettings.isRotateVelocityAnimationEnabled()); + } + + @Test + public void testRotateVelocityAnimationDisabled() { + uiSettings.setRotateVelocityAnimationEnabled(false); + assertEquals("Rotate velocity animation should be disabled", false, uiSettings.isRotateVelocityAnimationEnabled()); + } + + @Test + public void testFlingVelocityAnimationEnabled() { + uiSettings.setFlingVelocityAnimationEnabled(true); + assertEquals("Fling velocity animation should be enabled", true, uiSettings.isFlingVelocityAnimationEnabled()); + } + + @Test + public void testFlingVelocityAnimationDisabled() { + uiSettings.setFlingVelocityAnimationEnabled(false); + assertEquals("Fling velocity animation should be disabled", false, uiSettings.isFlingVelocityAnimationEnabled()); + } + + @Test + public void testAllVelocityAnimationsEnabled() { + uiSettings.setAllVelocityAnimationsEnabled(true); + assertEquals("Scale velocity animation should be enabled", true, uiSettings.isScaleVelocityAnimationEnabled()); + assertEquals("Rotate velocity animation should be enabled", true, uiSettings.isRotateVelocityAnimationEnabled()); + assertEquals("Fling velocity animation should be enabled", true, uiSettings.isFlingVelocityAnimationEnabled()); + } + + @Test + public void testAllVelocityAnimationsDisabled() { + uiSettings.setAllVelocityAnimationsEnabled(false); + assertEquals("Scale velocity animation should be disabled", false, uiSettings.isScaleVelocityAnimationEnabled()); + assertEquals("Rotate velocity animation should be disabled", false, uiSettings.isRotateVelocityAnimationEnabled()); + assertEquals("Fling velocity animation should be disabled", false, uiSettings.isFlingVelocityAnimationEnabled()); + } + + @Test + public void testIncreaseRotateThresholdWhenScalingEnabled() { + uiSettings.setIncreaseRotateThresholdWhenScaling(true); + assertEquals("Rotate threshold increase should be enabled", true, + uiSettings.isIncreaseRotateThresholdWhenScaling()); + } + + @Test + public void testIncreaseRotateThresholdWhenScalingDisabled() { + uiSettings.setIncreaseRotateThresholdWhenScaling(false); + assertEquals("Rotate threshold increase should be disabled", false, + uiSettings.isIncreaseRotateThresholdWhenScaling()); + } + + @Test + public void testIncreaseScaleThresholdWhenRotatingEnabled() { + uiSettings.setIncreaseScaleThresholdWhenRotating(true); + assertEquals("Scale threshold increase should be enabled", true, uiSettings.isIncreaseScaleThresholdWhenRotating()); + } + + @Test + public void testIncreaseScaleThresholdWhenRotatingDisabled() { + uiSettings.setIncreaseScaleThresholdWhenRotating(false); + assertEquals("Scale threshold increase should be disabled", false, + uiSettings.isIncreaseScaleThresholdWhenRotating()); } @Test diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java deleted file mode 100644 index c9ce19dc85..0000000000 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.mapbox.mapboxsdk.maps.widgets; - -import android.graphics.Color; -import android.graphics.drawable.Drawable; - -import com.mapbox.mapboxsdk.maps.FocalPointChangeListener; -import com.mapbox.mapboxsdk.maps.Projection; -import com.mapbox.mapboxsdk.maps.TrackingSettings; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; - -import java.util.Arrays; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class MyLocationViewSettingsTest { - - @InjectMocks - Projection projection = mock(Projection.class); - - @InjectMocks - MyLocationView myLocationView = mock(MyLocationView.class); - - @InjectMocks - TrackingSettings trackingSettings = mock(TrackingSettings.class); - - @InjectMocks - FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); - - private MyLocationViewSettings locationViewSettings; - - @Before - public void beforeTest() { - locationViewSettings = new MyLocationViewSettings(myLocationView, projection, focalPointChangeListener); - } - - @Test - public void testSanity() { - assertNotNull("should not be null", locationViewSettings); - } - - @Test - public void testForegroundDrawables() { - Drawable foregroundDrawable = mock(Drawable.class); - Drawable foregroundBearingDrawable = mock(Drawable.class); - Drawable.ConstantState constantState = mock(Drawable.ConstantState.class); - when(foregroundDrawable.getConstantState()).thenReturn(constantState); - when(constantState.newDrawable()).thenReturn(foregroundDrawable); - locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable); - assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable()); - assertEquals("foreground bearing should match", foregroundBearingDrawable, - locationViewSettings.getForegroundBearingDrawable()); - } - - @Test - public void testBackgroundDrawable() { - Drawable backgroundDrawable = mock(Drawable.class); - int[] offset = new int[] {1, 2, 3, 4}; - locationViewSettings.setBackgroundDrawable(backgroundDrawable, offset); - assertEquals("foreground should match", backgroundDrawable, locationViewSettings.getBackgroundDrawable()); - assertTrue("offsets should match", Arrays.equals(offset, locationViewSettings.getBackgroundOffset())); - } - - @Test - public void testForegroundTint() { - int color = Color.RED; - locationViewSettings.setForegroundTintColor(Color.RED); - assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); - } - - @Test - public void testForegroundTransparentTint() { - int color = Color.TRANSPARENT; - locationViewSettings.setForegroundTintColor(Color.TRANSPARENT); - assertEquals("color should match", color, locationViewSettings.getForegroundTintColor()); - } - - @Test - public void testBackgroundTint() { - int color = Color.RED; - locationViewSettings.setBackgroundTintColor(Color.RED); - assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); - } - - @Test - public void testBackgroundTransparentTint() { - int color = Color.TRANSPARENT; - locationViewSettings.setBackgroundTintColor(Color.TRANSPARENT); - assertEquals("color should match", color, locationViewSettings.getBackgroundTintColor()); - } - - @Test - public void testEnabled() { - assertFalse("initial state should be false", locationViewSettings.isEnabled()); - locationViewSettings.setEnabled(true); - assertTrue("state should be true", locationViewSettings.isEnabled()); - } -} - |