summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/test')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/AccountsManagerTest.java59
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxInjector.java48
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java109
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java93
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java56
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java86
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java160
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java75
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java75
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java322
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java131
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/constants/AppConstant.java6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java813
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java65
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java286
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java66
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java95
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/CompassEngineTest.java89
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt532
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java1001
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentActivationOptionsTest.java119
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java81
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentPositionManagerTest.kt130
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt453
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java718
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt43
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/UtilsTest.java28
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt93
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java86
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AttributionDialogManagerTest.java99
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapChangeReceiverTest.java586
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java157
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsAttrsTest.kt101
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java196
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.kt214
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleBuilderTest.kt237
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt408
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TransformTest.kt183
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java433
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUrlTest.kt67
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtilTest.kt35
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/MapEventFactoryTest.java149
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/SchemaTest.java270
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java1537
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java20
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/ColorUtilsTest.kt22
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java267
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker1
48 files changed, 0 insertions, 10900 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/AccountsManagerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/AccountsManagerTest.java
deleted file mode 100644
index 5ce71ceacf..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/AccountsManagerTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.mapbox.mapboxsdk;
-
-import android.content.SharedPreferences;
-import android.text.format.DateUtils;
-
-import org.junit.Test;
-
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.KEY_PREFERENCE_SKU_TOKEN;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AccountsManagerTest {
- @Test
- public void testIsExpired() {
- long now = AccountsManager.getNow();
-
- long defaultValue = 0L;
- long tooOld = now - DateUtils.HOUR_IN_MILLIS - 1;
- long futureValue = now + 1;
- long immediatePast = now - 1;
-
- assertTrue(AccountsManager.isExpired(now, defaultValue));
- assertTrue(AccountsManager.isExpired(now, tooOld));
-
- assertFalse(AccountsManager.isExpired(now, futureValue));
- assertFalse(AccountsManager.isExpired(now, immediatePast));
- }
-
- @Test
- public void checksSkuTokenExternalManagement() {
- SharedPreferences mockedSharedPreferences = mock(SharedPreferences.class);
- when(mockedSharedPreferences.getString(KEY_PREFERENCE_SKU_TOKEN, "")).thenReturn("external-sku-token");
- boolean isNotManaged = false;
- AccountsManager theAccountsManager = new AccountsManager(mockedSharedPreferences, isNotManaged);
-
- String skuToken = theAccountsManager.getSkuToken();
-
- assertEquals("external-sku-token", skuToken);
- }
-
- @Test
- public void checksSkuTokenInternalManagement() {
- SharedPreferences mockedSharedPreferences = mock(SharedPreferences.class, RETURNS_DEEP_STUBS);
- when(mockedSharedPreferences.getString("com.mapbox.mapboxsdk.accounts.userid", ""))
- .thenReturn("any-user-id");
- boolean isManaged = true;
- AccountsManager theAccountsManager = new AccountsManager(mockedSharedPreferences, isManaged);
-
- String skuToken = theAccountsManager.getSkuToken();
-
- assertFalse(skuToken.isEmpty());
- assertTrue(skuToken.startsWith("100"));
- assertTrue(skuToken.endsWith("any-user-id"));
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxInjector.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxInjector.java
deleted file mode 100644
index 966c756318..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxInjector.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.mapbox.mapboxsdk;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import java.lang.reflect.Field;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MapboxInjector {
-
- private static final String FIELD_INSTANCE = "INSTANCE";
- private static final String FIELD_ACCOUNTS = "accounts";
-
- public static void inject(@NonNull Context context, @NonNull String accessToken) {
- inject(context, accessToken, null);
- }
-
- public static void inject(@NonNull Context context, @NonNull String accessToken, @Nullable String skuToken) {
- Mapbox mapbox = new Mapbox(context, accessToken);
- try {
- Field instance = Mapbox.class.getDeclaredField(FIELD_INSTANCE);
- instance.setAccessible(true);
- instance.set(mapbox, mapbox);
-
- Field accounts = Mapbox.class.getDeclaredField(FIELD_ACCOUNTS);
- accounts.setAccessible(true);
-
- AccountsManager manager = mock(AccountsManager.class);
- when(manager.getSkuToken()).thenReturn(skuToken);
- accounts.set(mapbox, manager);
- } catch (Exception exception) {
- throw new AssertionError();
- }
- }
-
- public static void clear() {
- try {
- Field field = Mapbox.class.getDeclaredField(FIELD_INSTANCE);
- field.setAccessible(true);
- field.set(field, null);
- } catch (Exception exception) {
- throw new AssertionError();
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java
deleted file mode 100644
index a4b5736729..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/MapboxTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.mapbox.mapboxsdk;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-
-import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
-import com.mapbox.mapboxsdk.maps.MapView;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static junit.framework.TestCase.assertNotNull;
-import static junit.framework.TestCase.assertSame;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MapboxTest {
-
- private Context context;
- private Context appContext;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
- context = mock(Context.class);
- appContext = mock(Context.class);
- when(context.getApplicationContext()).thenReturn(appContext);
- }
-
- @Test
- public void testGetAccessToken() {
- final String accessToken = "pk.0000000001";
- MapboxInjector.inject(context, accessToken);
- assertSame(accessToken, Mapbox.getAccessToken());
- }
-
- @Test
- public void testApplicationContext() {
- MapboxInjector.inject(context, "pk.0000000001");
- assertNotNull(Mapbox.getApplicationContext());
- assertNotEquals(context, appContext);
- assertEquals(appContext, appContext);
- }
-
- @Test
- public void testPkTokenValid() {
- assertTrue(Mapbox.isAccessTokenValid("pk.0000000001"));
- }
-
- @Test
- public void testSkTokenValid() {
- assertTrue(Mapbox.isAccessTokenValid("sk.0000000001"));
- }
-
- @Test
- public void testEmptyToken() {
- assertFalse(Mapbox.isAccessTokenValid(""));
- }
-
- @Test
- public void testNullToken() {
- assertFalse(Mapbox.isAccessTokenValid(null));
- }
-
- @Test
- public void testBlaBlaToken() {
- assertFalse(Mapbox.isAccessTokenValid("blabla"));
- }
-
- @Test
- public void testNoInstance() {
- DisplayMetrics displayMetrics = mock(DisplayMetrics.class);
- Resources resources = mock(Resources.class);
- when(resources.getDisplayMetrics()).thenReturn(displayMetrics);
- when(context.getResources()).thenReturn(resources);
- TypedArray typedArray = mock(TypedArray.class);
- when(context.obtainStyledAttributes(nullable(AttributeSet.class), any(int[].class), anyInt(), anyInt()))
- .thenReturn(typedArray);
-
- expectedException.expect(MapboxConfigurationException.class);
- expectedException.expectMessage(
- "\nUsing MapView requires calling Mapbox.getInstance(Context context, String accessToken) before "
- + "inflating or creating the view. The access token parameter is required when using a Mapbox service."
- + "\nPlease see https://www.mapbox.com/help/create-api-access-token/ to learn how to create one."
- + "\nMore information in this guide https://www.mapbox.com/help/first-steps-android-sdk/#access-tokens."
- );
- new MapView(context);
- }
-
- @After
- public void after() {
- MapboxInjector.clear();
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java
deleted file mode 100644
index 0c61b01be6..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.mapbox.mapboxsdk.annotations;
-
-import android.support.annotation.NonNull;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-public class AnnotationTest {
-
- @InjectMocks
- private MapboxMap mapboxMap = mock(MapboxMap.class);
- private Annotation annotation;
- @NonNull
- private Annotation compare = new Annotation() {
- @Override
- public long getId() {
- return 1;
- }
- };
-
- @Before
- public void beforeTest() {
- annotation = new Annotation() {
- // empty child
- };
- }
-
- @Test
- public void testSanity() {
- assertNotNull("markerOptions should not be null", annotation);
- }
-
- @Test
- public void testRemove() {
- annotation.setId(1);
- annotation.setMapboxMap(mapboxMap);
- annotation.remove();
- verify(mapboxMap, times(1)).removeAnnotation(annotation);
- }
-
- @Test
- public void testRemoveUnboundMapboxMap() {
- annotation.setId(1);
- annotation.remove();
- verify(mapboxMap, times(0)).removeAnnotation(annotation);
- }
-
- @Test
- public void testCompareToEqual() {
- annotation.setId(1);
- assertEquals("conparable equal", 0, annotation.compareTo(compare));
- }
-
- @Test
- public void testCompareToHigher() {
- annotation.setId(3);
- assertEquals("conparable higher", -1, annotation.compareTo(compare));
- }
-
- @Test
- public void testCompareTolower() {
- annotation.setId(0);
- assertEquals("conparable lower", 1, annotation.compareTo(compare));
- }
-
- @Test
- public void testEquals() {
- Annotation holder = null;
- assertFalse(annotation.equals(holder));
- holder = annotation;
- assertTrue(annotation.equals(holder));
- assertFalse(annotation.equals(new Object()));
- }
-
- @Test
- public void testHashcode() {
- int id = 1;
- annotation.setId(id);
- assertSame("hashcode should match", annotation.hashCode(), id);
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java
deleted file mode 100644
index e56ca559d4..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/IconTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.mapbox.mapboxsdk.annotations;
-
-import android.graphics.Bitmap;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotSame;
-import static org.mockito.Mockito.when;
-
-public class IconTest {
-
- @Mock
- Bitmap bitmap;
-
- @Before
- public void beforeTest() {
- MockitoAnnotations.initMocks(this);
- when(bitmap.getConfig()).thenReturn(Bitmap.Config.ARGB_8888);
- }
-
- @Test
- public void testId() {
- String id = "test";
- Icon icon = IconFactory.recreate(id, Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
- assertEquals("id should match", id, icon.getId());
- }
-
- @Test
- public void testBitmap() {
- Icon icon = IconFactory.recreate("test", bitmap);
- assertEquals("bitmap should match", bitmap, icon.getBitmap());
- }
-
- @Test
- public void testEquals() {
- Icon icon1 = IconFactory.recreate("test", bitmap);
- Icon icon2 = IconFactory.recreate("test", bitmap);
- assertEquals("icons should not match", icon1, icon2);
- }
-
- @Test
- public void testEqualsObject() {
- Icon icon = IconFactory.recreate("test", Bitmap.createBitmap(0, 0, Bitmap.Config.ALPHA_8));
- assertNotSame("icon should not match", new Object(), icon);
- }
-
- @Test
- public void testHashcode() {
- Icon icon = IconFactory.recreate("test", bitmap);
- long expectedHashcode = 31 * bitmap.hashCode() + "test".hashCode();
- assertEquals("hashcode should match", expectedHashcode, icon.hashCode());
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java
deleted file mode 100644
index 94b629860e..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/InfoWindowTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.mapbox.mapboxsdk.annotations;
-
-import android.graphics.PointF;
-
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.maps.MapView;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.Projection;
-
-import org.junit.Test;
-import org.mockito.InjectMocks;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class InfoWindowTest {
-
- @InjectMocks
- MapView mMapView = mock(MapView.class);
-
- @InjectMocks
- MapboxMap mMapboxMap = mock(MapboxMap.class);
-
- @Test
- public void testSanity() {
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- assertNotNull("infoWindow should exist", infoWindow);
- }
-
- @Test
- public void testBoundMarker() {
- MarkerOptions markerOptions = new MarkerOptions();
- Marker marker = markerOptions.position(new LatLng()).getMarker();
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap).setBoundMarker(marker);
- assertEquals("marker should match", marker, infoWindow.getBoundMarker());
- }
-
- @Test
- public void testClose() {
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.close();
- assertEquals("infowindow should not be visible", false, infoWindow.isVisible());
- }
-
-
- @Test
- public void testOpen() {
- LatLng latLng = new LatLng(0, 0);
- Projection projection = mock(Projection.class);
- when(mMapboxMap.getProjection()).thenReturn(projection);
- when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
-
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.open(mMapView, new MarkerOptions().position(new LatLng()).getMarker(), latLng, 0, 0);
- assertEquals("infowindow should not be visible", true, infoWindow.isVisible());
- }
-
- @Test
- public void testOpenClose() {
- LatLng latLng = new LatLng(0, 0);
- Projection projection = mock(Projection.class);
- when(mMapboxMap.getProjection()).thenReturn(projection);
- when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
-
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.open(mMapView, new MarkerOptions().position(new LatLng()).getMarker(), latLng, 0, 0);
- infoWindow.close();
- assertEquals("infowindow should not be visible", false, infoWindow.isVisible());
- }
-
-
- @Test
- public void testUpdate() {
- LatLng latLng = new LatLng(0, 0);
- Projection projection = mock(Projection.class);
- when(mMapboxMap.getProjection()).thenReturn(projection);
- when(projection.toScreenLocation(latLng)).thenReturn(new PointF(0, 0));
-
- InfoWindow infoWindow = new InfoWindow(mMapView, mMapboxMap);
- infoWindow.open(mMapView, new MarkerOptions().position(latLng).getMarker(), latLng, 0, 0);
- infoWindow.update();
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java
deleted file mode 100644
index fa571e06b1..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package com.mapbox.mapboxsdk.annotations;
-
-import android.graphics.Bitmap;
-import android.os.Parcelable;
-
-import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.utils.MockParcel;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-
-public class MarkerTest {
-
- @Test
- public void testSanity() {
- MarkerOptions markerOptions = new MarkerOptions();
- assertNotNull("markerOptions should not be null", markerOptions);
- }
-
- @Test
- public void testMarker() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng());
- assertNotNull("marker should not be null", markerOptions.getMarker());
- }
-
- @Test(expected = InvalidMarkerPositionException.class)
- public void testInvalidMarker() {
- new MarkerOptions().getMarker();
- }
-
- @Test
- public void testPosition() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
- Marker marker = markerOptions.getMarker();
- assertEquals(marker.getPosition(), new LatLng(10, 12));
- assertEquals(markerOptions.getPosition(), new LatLng(10, 12));
- }
-
- @Test
- public void testTitle() {
- MarkerOptions markerOptions = new MarkerOptions().title("Mapbox").position(new LatLng());
- Marker marker = markerOptions.getMarker();
- assertEquals(marker.getTitle(), "Mapbox");
- assertEquals(markerOptions.getTitle(), "Mapbox");
- }
-
- @Test
- public void testSnippet() {
- MarkerOptions markerOptions = new MarkerOptions().snippet("Mapbox").position(new LatLng());
- Marker marker = markerOptions.getMarker();
- assertEquals(marker.getSnippet(), "Mapbox");
- }
-
- @Test
- public void testBuilder() {
- Marker marker = new MarkerOptions().title("title").snippet("snippet").position(new LatLng(10, 12)).getMarker();
- assertEquals(marker.getSnippet(), "snippet");
-
- assertEquals(marker.getPosition(), new LatLng(10, 12));
- }
-
- @Test
- public void testIcon() {
- Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
- Icon icon = IconFactory.recreate("test", bitmap);
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()).icon(icon);
- Marker marker = markerOptions.getMarker();
- assertEquals("Icon should match", icon, marker.getIcon());
- assertEquals("Icon should match", icon, markerOptions.getIcon());
- }
-
- @Test
- public void testHashCode() {
- Marker marker = new MarkerOptions().position(new LatLng()).getMarker();
- assertEquals("hash code should match", marker.hashCode(), 0);
- }
-
- @Test
- public void testHashCodeBuilder() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(10, 12));
- assertEquals("hash code should match", markerOptions.hashCode(), 579999617);
- }
-
- @Test
- public void testEquals() {
- Marker markerOne = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
- Marker markerTwo = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
- assertEquals(markerOne, markerTwo);
- }
-
- @Test
- public void testEqualityDifferentLocation() {
- MarkerOptions marker = new MarkerOptions().position(new LatLng(0, 0));
- MarkerOptions other = new MarkerOptions().position(new LatLng(1, 0));
- assertNotEquals("Should not match", other, marker);
- }
-
-
- @Test
- public void testEqualityDifferentSnippet() {
- MarkerOptions marker = new MarkerOptions().snippet("s");
- MarkerOptions other = new MarkerOptions();
- assertNotEquals("Should not match", other, marker);
- }
-
- @Test
- public void testEqualityDifferentIcon() {
- MarkerOptions marker = new MarkerOptions().icon(mock(Icon.class));
- MarkerOptions other = new MarkerOptions();
- assertNotEquals("Should not match", other, marker);
- }
-
- @Test
- public void testEqualityDifferentTitle() {
- MarkerOptions marker = new MarkerOptions().title("t");
- MarkerOptions other = new MarkerOptions();
- assertNotEquals("Should not match", other, marker);
- }
-
- @Test
- public void testEqualsItself() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
- Marker marker = markerOptions.getMarker();
- assertEquals("Marker should match", marker, marker);
- assertEquals("MarkerOptions should match", markerOptions, markerOptions);
- }
-
- @Test
- public void testNotEquals() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(0, 0));
- Marker marker = markerOptions.getMarker();
- assertNotEquals("MarkerOptions should match", markerOptions, new Object());
- assertNotEquals("Marker should match", marker, new Object());
- }
-
- @Test
- public void testEqualityBuilder() {
- MarkerOptions markerOne = new MarkerOptions().position(new LatLng(0, 0));
- MarkerOptions markerTwo = new MarkerOptions().position(new LatLng(0, 0));
- assertEquals(markerOne, markerTwo);
- }
-
- @Test
- public void testToString() {
- Marker marker = new MarkerOptions().position(new LatLng(0, 0)).getMarker();
- assertEquals(marker.toString(), "Marker [position[" + "LatLng [latitude=0.0, longitude=0.0, altitude=0.0]" + "]]");
- }
-
- @Test
- public void testParcelable() {
- MarkerOptions markerOptions = new MarkerOptions().position(new LatLng()).title("t").snippet("s");
- Parcelable parcelable = MockParcel.obtain(markerOptions);
- assertEquals("Parcel should match original object", parcelable, markerOptions);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java
deleted file mode 100644
index 3933c68887..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolygonTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.mapbox.mapboxsdk.annotations;
-
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class PolygonTest {
-
- @Test
- public void testSanity() {
- PolygonOptions polygonOptions = new PolygonOptions();
- assertNotNull("polygonOptions should not be null", polygonOptions);
- }
-
- @Test
- public void testPolygon() {
- Polygon polygon = new PolygonOptions().getPolygon();
- assertNotNull("polyline should not be null", polygon);
- }
-
- @Test
- public void testAlpha() {
- Polygon polygon = new PolygonOptions().alpha(0.5f).getPolygon();
- assertEquals(0.5f, polygon.getAlpha(), 0.0f);
- }
-
- @Test
- public void testStrokeColor() {
- Polygon polygon = new PolygonOptions().strokeColor(1).getPolygon();
- assertEquals(1, polygon.getStrokeColor());
- }
-
- @Test
- public void testFillColor() {
- Polygon polygon = new PolygonOptions().fillColor(1).getPolygon();
- assertEquals(1, polygon.getFillColor());
- }
-
- @Test
- public void testLatLng() {
- Polygon polygon = new PolygonOptions().add(new LatLng(0, 0)).getPolygon();
- assertNotNull("points should not be null", polygon.getPoints());
- assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
- }
-
- @Test
- public void testAddAllLatLng() {
- List<LatLng> coordinates = new ArrayList<>();
- coordinates.add(new LatLng(0, 0));
- Polygon polygon = new PolygonOptions().addAll(coordinates).getPolygon();
- assertNotNull(polygon.getPoints());
- assertEquals(new LatLng(0, 0), polygon.getPoints().get(0));
- }
-
- @Test
- public void testBuilder() {
- PolylineOptions polylineOptions = new PolylineOptions();
- polylineOptions.width(1.0f);
- polylineOptions.color(2);
- polylineOptions.add(new LatLng(0, 0));
-
- Polyline polyline = polylineOptions.getPolyline();
- assertEquals(1.0f, polyline.getWidth(), 0);
- assertEquals(2, polyline.getColor());
- assertNotNull("Points should not be null", polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java
deleted file mode 100644
index 54bb0e8cf4..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/annotations/PolylineTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.mapbox.mapboxsdk.annotations;
-
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class PolylineTest {
-
- @Test
- public void testSanity() {
- PolylineOptions polylineOptions = new PolylineOptions();
- assertNotNull("polylineOptions should not be null", polylineOptions);
- }
-
- @Test
- public void testPolyline() {
- Polyline polyline = new PolylineOptions().getPolyline();
- assertNotNull("polyline should not be null", polyline);
- }
-
- @Test
- public void testAlpha() {
- Polyline polyline = new PolylineOptions().alpha(0.2f).getPolyline();
- assertEquals(0.2f, polyline.getAlpha(), 0.0f);
- }
-
- @Test
- public void testWidth() {
- Polyline polyline = new PolylineOptions().width(1).getPolyline();
- assertEquals(1.0f, polyline.getWidth(), 0);
- }
-
- @Test
- public void testColor() {
- Polyline polyline = new PolylineOptions().color(1).getPolyline();
- assertEquals(1, polyline.getColor());
- }
-
- @Test
- public void testAddLatLng() {
- Polyline polyline = new PolylineOptions().add(new LatLng(0, 0)).getPolyline();
- assertNotNull("Points should not be null", polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
-
- @Test
- public void testAddAllLatLng() {
- List<LatLng> coordinates = new ArrayList<>();
- coordinates.add(new LatLng(0, 0));
- Polyline polyline = new PolylineOptions().addAll(coordinates).getPolyline();
- assertNotNull(polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
-
- @Test
- public void testBuilder() {
- PolylineOptions polylineOptions = new PolylineOptions();
- polylineOptions.width(1.0f);
- polylineOptions.color(2);
- polylineOptions.add(new LatLng(0, 0));
-
- Polyline polyline = polylineOptions.getPolyline();
- assertEquals(1.0f, polyline.getWidth(), 0);
- assertEquals(2, polyline.getColor());
- assertNotNull("Points should not be null", polyline.getPoints());
- assertEquals(new LatLng(0, 0), polyline.getPoints().get(0));
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java
deleted file mode 100644
index b72e85270d..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/attribution/AttributionParseTest.java
+++ /dev/null
@@ -1,322 +0,0 @@
-package com.mapbox.mapboxsdk.attribution;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.Set;
-
-import static junit.framework.Assert.assertEquals;
-
-@RunWith(RobolectricTestRunner.class)
-public class AttributionParseTest {
-
- private static final String STREETS_ATTRIBUTION = "<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://apps.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a>\n";
- private static final String SATELLITE_ATTRIBUTION = "<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">&copy; Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">&copy; OpenStreetMap</a> <a class=\"mapbox-improve-map\" href=\"https://apps.mapbox.com/feedback/\" target=\"_blank\">Improve this map</a> <a href=\"https://www.digitalglobe.com/\" target=\"_blank\">&copy; DigitalGlobe</a>\n";
-
- @Test
- public void testParseAttributionStringSatellite() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(SATELLITE_ATTRIBUTION)
- .build();
-
- Set<Attribution> attributionList = attributionParser.getAttributions();
- assertEquals("Size of list should match", 4, attributionList.size());
-
- int counter = 0;
- for (Attribution attribution : attributionList) {
- switch (counter) {
- case 0:
- assertEquals("URL mapbox should match", "https://www.mapbox.com/about/maps/", attribution.getUrl());
- assertEquals("Title mapbox should match", "© Mapbox", attribution.getTitle());
- break;
- case 1:
- assertEquals("URL openstreetmap should match", "http://www.openstreetmap.org/about/", attribution.getUrl());
- assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
- break;
- case 2:
- assertEquals("URL improve map should match", "https://apps.mapbox.com/feedback/", attribution.getUrl());
- assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle());
- break;
- case 3:
- assertEquals("URL digital globe should match", "https://www.digitalglobe.com/", attribution.getUrl());
- assertEquals("Title digital globe should match", "© DigitalGlobe", attribution.getTitle());
- break;
- }
- counter++;
- }
- }
-
- @Test
- public void testParseAttributionStringStreets() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION)
- .build();
-
- Set<Attribution> attributionList = attributionParser.getAttributions();
- assertEquals("Size of list should match", 3, attributionList.size());
-
- int counter = 0;
- for (Attribution attribution : attributionList) {
- switch (counter) {
- case 0:
- assertEquals("URL mapbox should match", "https://www.mapbox.com/about/maps/", attribution.getUrl());
- assertEquals("Title mapbox should match", "© Mapbox", attribution.getTitle());
- break;
- case 1:
- assertEquals("URL openstreetmap should match", "http://www.openstreetmap.org/about/", attribution.getUrl());
- assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
- break;
- case 2:
- assertEquals("URL improve map should match", "https://apps.mapbox.com/feedback/", attribution.getUrl());
- assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle());
- break;
- }
- counter++;
- }
- }
-
- @Test
- public void testParseAttributionWithoutMapbox() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION)
- .withMapboxAttribution(false)
- .build();
-
- Set<Attribution> attributionList = attributionParser.getAttributions();
- assertEquals("Size of list should match", 2, attributionList.size());
-
- int counter = 0;
- for (Attribution attribution : attributionList) {
- switch (counter) {
- case 0:
- assertEquals("URL openstreetmap should match", "http://www.openstreetmap.org/about/", attribution.getUrl());
- assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
- break;
- case 1:
- assertEquals("URL improve map should match", "https://apps.mapbox.com/feedback/", attribution.getUrl());
- assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle());
- break;
- }
- counter++;
- }
- }
-
- @Test
- public void testParseAttributionArrayString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(new String[] {STREETS_ATTRIBUTION, "", SATELLITE_ATTRIBUTION})
- .build();
- Set<Attribution> attributionList = attributionParser.getAttributions();
- assertEquals("Size of list should match", 4, attributionList.size());
-
- int counter = 0;
- for (Attribution attribution : attributionList) {
- switch (counter) {
- case 0:
- assertEquals("URL mapbox should match", "https://www.mapbox.com/about/maps/", attribution.getUrl());
- assertEquals("Title mapbox should match", "© Mapbox", attribution.getTitle());
- break;
- case 1:
- assertEquals("URL openstreetmap should match", "http://www.openstreetmap.org/about/", attribution.getUrl());
- assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
- break;
- case 2:
- assertEquals("URL improve map should match", "https://apps.mapbox.com/feedback/", attribution.getUrl());
- assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle());
- break;
- case 3:
- assertEquals("URL digital globe should match", "https://www.digitalglobe.com/", attribution.getUrl());
- assertEquals("Title digital globe should match", "© DigitalGlobe", attribution.getTitle());
- break;
- }
- counter++;
- }
- }
-
- @Test
- public void testHideImproveThisMapAttributionArrayString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(SATELLITE_ATTRIBUTION)
- .withImproveMap(false)
- .build();
- Set<Attribution> attributionList = attributionParser.getAttributions();
- assertEquals("Size of list should match", 3, attributionList.size());
-
- int counter = 0;
- for (Attribution attribution : attributionList) {
- switch (counter) {
- case 0:
- assertEquals("URL mapbox should match", "https://www.mapbox.com/about/maps/", attribution.getUrl());
- assertEquals("Title mapbox should match", "© Mapbox", attribution.getTitle());
- break;
- case 1:
- assertEquals("URL openstreetmap should match", "http://www.openstreetmap.org/about/", attribution.getUrl());
- assertEquals("Title openstreetmap should match", "© OpenStreetMap", attribution.getTitle());
- break;
- case 2:
- assertEquals("URL digital globe should match", "https://www.digitalglobe.com/", attribution.getUrl());
- assertEquals("Title digital globe should match", "© DigitalGlobe", attribution.getTitle());
- break;
- }
- counter++;
- }
- }
-
- @Test
- public void testParseHideCopyrightAttributionArrayString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION, "", SATELLITE_ATTRIBUTION)
- .withCopyrightSign(false)
- .build();
- Set<Attribution> attributionList = attributionParser.getAttributions();
- assertEquals("Size of list should match", 4, attributionList.size());
-
- int counter = 0;
- for (Attribution attribution : attributionList) {
- switch (counter) {
- case 0:
- assertEquals("URL mapbox should match", "https://www.mapbox.com/about/maps/", attribution.getUrl());
- assertEquals("Title mapbox should match", "Mapbox", attribution.getTitle());
- break;
- case 1:
- assertEquals("URL openstreetmap should match", "http://www.openstreetmap.org/about/", attribution.getUrl());
- assertEquals("Title openstreetmap should match", "OpenStreetMap", attribution.getTitle());
- break;
- case 2:
- assertEquals("URL improve map should match", "https://apps.mapbox.com/feedback/", attribution.getUrl());
- assertEquals("Title improve map should match", "Improve This Map", attribution.getTitle());
- break;
- case 3:
- assertEquals("URL digital globe should match", "https://www.digitalglobe.com/", attribution.getUrl());
- assertEquals("Title digital globe should match", "DigitalGlobe", attribution.getTitle());
- break;
- }
- counter++;
- }
- }
-
- @Test
- public void testOutputWithoutCopyRightString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION)
- .withCopyrightSign(false)
- .withImproveMap(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© Mapbox / OpenStreetMap",
- attributionParser.createAttributionString()
- );
- }
-
-
- @Test
- public void testOutputWithCopyRightString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION)
- .withImproveMap(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© Mapbox / © OpenStreetMap",
- attributionParser.createAttributionString()
- );
- }
-
- @Test
- public void testOutputWithoutCopyRightWithoutMapboxString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION)
- .withCopyrightSign(false)
- .withImproveMap(false)
- .withMapboxAttribution(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© OpenStreetMap",
- attributionParser.createAttributionString()
- );
- }
-
- @Test
- public void testOutputWithCopyRightWithoutMapboxString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION)
- .withImproveMap(false)
- .withMapboxAttribution(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© OpenStreetMap",
- attributionParser.createAttributionString()
- );
- }
-
- @Test
- public void testOutputSatelliteString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION, SATELLITE_ATTRIBUTION, "blabla", "")
- .withImproveMap(false)
- .withCopyrightSign(false)
- .withMapboxAttribution(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© OpenStreetMap / DigitalGlobe",
- attributionParser.createAttributionString()
- );
- }
-
- @Test
- public void testShortOpenStreetMapString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION, SATELLITE_ATTRIBUTION, "blabla", "")
- .withImproveMap(false)
- .withCopyrightSign(false)
- .withMapboxAttribution(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© OSM / DigitalGlobe",
- attributionParser.createAttributionString(true)
- );
- }
-
- @Test
- public void testShortOpenStreetMapWithoutCopyrightString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION, SATELLITE_ATTRIBUTION, "blabla", "")
- .withImproveMap(false)
- .withCopyrightSign(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© Mapbox / OSM / DigitalGlobe",
- attributionParser.createAttributionString(true)
- );
- }
-
- @Test
- public void testWithImproveThisMapString() throws Exception {
- AttributionParser attributionParser = new AttributionParser.Options(RuntimeEnvironment.application)
- .withAttributionData(STREETS_ATTRIBUTION, "blabla", "")
- .withImproveMap(true)
- .withCopyrightSign(false)
- .build();
-
- assertEquals(
- "Attribution string should match",
- "© Mapbox / OSM / Improve This Map",
- attributionParser.createAttributionString(true)
- );
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java
deleted file mode 100644
index dcf84c87b3..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package com.mapbox.mapboxsdk.camera;
-
-import android.content.res.TypedArray;
-import android.os.Parcel;
-
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(RobolectricTestRunner.class)
-public class CameraPositionTest {
-
- private static final double DELTA = 1e-15;
-
- @Test
- public void testSanity() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5, new double[] {0, 500, 0, 0});
- assertNotNull("cameraPosition should not be null", cameraPosition);
- }
-
- @Test
- public void testDefaultTypedArrayBuilder() {
- TypedArray typedArray = null;
- CameraPosition cameraPosition = new CameraPosition.Builder(typedArray).build();
- assertEquals("bearing should match", -1, cameraPosition.bearing, DELTA);
- assertNull("latlng should be null", cameraPosition.target);
- assertEquals("tilt should match", -1, cameraPosition.tilt, DELTA);
- assertEquals("zoom should match", -1, cameraPosition.zoom, DELTA);
- assertNull("padding should be null", cameraPosition.padding);
- }
-
- @Test
- public void testTypedArrayBuilder() {
- float bearing = 180;
- float zoom = 12;
- float latitude = 10;
- float longitude = 11;
- float tilt = 44;
-
- TypedArray typedArray = mock(TypedArray.class);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraBearing, 0.0f)).thenReturn(bearing);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTargetLat, 0.0f)).thenReturn(latitude);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTargetLng, 0.0f)).thenReturn(longitude);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraZoom, 0.0f)).thenReturn(zoom);
- when(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraTilt, 0.0f)).thenReturn(tilt);
- doNothing().when(typedArray).recycle();
-
- CameraPosition cameraPosition = new CameraPosition.Builder(typedArray).build();
- assertEquals("bearing should match", bearing, cameraPosition.bearing, DELTA);
- assertEquals("latlng should match", new LatLng(latitude, longitude), cameraPosition.target);
- assertEquals("tilt should match", tilt, cameraPosition.tilt, DELTA);
- assertEquals("zoom should match", zoom, cameraPosition.zoom, DELTA);
- }
-
- @Test
- public void testToString() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5, new double[] {0, 500, 0, 0});
- assertEquals("toString should match", "Target: LatLng [latitude=1.0, longitude=2.0, altitude=0.0], Zoom:3.0, "
- + "Bearing:5.0, Tilt:4.0, Padding:[0.0, 500.0, 0.0, 0.0]", cameraPosition.toString());
- }
-
- @Test
- public void testHashcode() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5, new double[] {0, 500, 0, 0});
- assertEquals("hashCode should match", -420915327, cameraPosition.hashCode());
- }
-
- @Test
- public void testZoomUpdateBuilder() {
- float zoomLevel = 5;
- CameraPosition.Builder builder = new CameraPosition.Builder(
- (CameraUpdateFactory.ZoomUpdate) CameraUpdateFactory.zoomTo(zoomLevel));
- assertEquals("zoom should match", zoomLevel, builder.build().zoom, 0);
- }
-
- @Test
- public void testEquals() {
- LatLng latLng = new LatLng(1, 2);
- CameraPosition cameraPosition = new CameraPosition(latLng, 3, 4, 5, new double[] {0, 500, 0, 0});
- CameraPosition cameraPositionBearing = new CameraPosition(latLng, 3, 4, 9, new double[] {0, 500, 0, 0});
- CameraPosition cameraPositionTilt = new CameraPosition(latLng, 3, 9, 5, new double[] {0, 500, 0, 0});
- CameraPosition cameraPositionZoom = new CameraPosition(latLng, 9, 4, 5, new double[] {0, 500, 0, 0});
- CameraPosition cameraPositionTarget = new CameraPosition(new LatLng(), 3, 4, 5, new double[] {0, 500, 0, 0});
- CameraPosition cameraPositionPadding = new CameraPosition(new LatLng(), 3, 4, 5, new double[] {0, 501, 0, 0});
-
- assertEquals("cameraPosition should match itself", cameraPosition, cameraPosition);
- assertNotEquals("cameraPosition should not match null", null, cameraPosition);
- assertNotEquals("cameraPosition should not match object", new Object(), cameraPosition);
- assertNotEquals("cameraPosition should not match for bearing", cameraPositionBearing, cameraPosition);
- assertNotEquals("cameraPosition should not match for tilt", cameraPositionTilt, cameraPosition);
- assertNotEquals("cameraPosition should not match for zoom", cameraPositionZoom, cameraPosition);
- assertNotEquals("cameraPosition should not match for target", cameraPositionTarget, cameraPosition);
- assertNotEquals("cameraPosition should not match for padding", cameraPositionPadding, cameraPosition);
- }
-
- @Test
- public void testParcelable() {
- CameraPosition cameraPosition1 = new CameraPosition(new LatLng(1, 2), 3, 4, 5, new double[] {0, 500, 0, 0});
- Parcel parcel = Parcel.obtain();
- cameraPosition1.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
-
- CameraPosition cameraPosition2 = CameraPosition.CREATOR.createFromParcel(parcel);
- assertEquals("Parcel should match original object", cameraPosition1, cameraPosition2);
- }
-
- @Test
- public void testParcelableNulls() {
- CameraPosition cameraPosition1 = new CameraPosition(null, 3, 4, 5, null);
- Parcel parcel = Parcel.obtain();
- cameraPosition1.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
-
- CameraPosition cameraPosition2 = CameraPosition.CREATOR.createFromParcel(parcel);
- assertEquals("Parcel should match original object", cameraPosition1, cameraPosition2);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/constants/AppConstant.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/constants/AppConstant.java
deleted file mode 100644
index cb654aa556..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/constants/AppConstant.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.mapbox.mapboxsdk.constants;
-
-public class AppConstant {
-
- public static final int STYLE_VERSION = 9;
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
deleted file mode 100644
index 6c44c29e3b..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java
+++ /dev/null
@@ -1,813 +0,0 @@
-package com.mapbox.mapboxsdk.geometry;
-
-import android.os.Parcelable;
-import com.mapbox.mapboxsdk.constants.GeometryConstants;
-import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException;
-import com.mapbox.mapboxsdk.utils.MockParcel;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static junit.framework.Assert.assertNotNull;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-public class LatLngBoundsTest {
-
- private static final double DELTA = 1e-15;
-
- private LatLngBounds latLngBounds;
- private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
- private static final LatLng LAT_LNG_NOT_NULL_ISLAND = new LatLng(2, 2);
-
- @Before
- public void beforeTest() {
- latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
- }
-
- @Test
- public void testSanity() {
- LatLngBounds.Builder latLngBoundsBuilder = new LatLngBounds.Builder();
- latLngBoundsBuilder.include(LAT_LNG_NULL_ISLAND).include(LAT_LNG_NOT_NULL_ISLAND);
- assertNotNull("latLng should not be null", latLngBoundsBuilder.build());
- }
-
- @Test(expected = InvalidLatLngBoundsException.class)
- public void noLatLngs() {
- new LatLngBounds.Builder().build();
- }
-
- @Test(expected = InvalidLatLngBoundsException.class)
- public void oneLatLngs() {
- new LatLngBounds.Builder().include(LAT_LNG_NULL_ISLAND).build();
- }
-
- @Test
- public void latitiudeSpan() {
- assertEquals("Span should be the same", 2, latLngBounds.getLatitudeSpan(), DELTA);
- }
-
- @Test
- public void longitudeSpan() {
- assertEquals("Span should be the same", 2, latLngBounds.getLongitudeSpan(), DELTA);
- }
-
- @Test
- public void coordinateSpan() {
- LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be the same", new LatLngSpan(2, 2), latLngSpan);
- }
-
- @Test
- public void dateLineSpanBuilder1() {
- latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, -170))
- .include(new LatLng(-10, 170))
- .build();
-
- LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 340),
- latLngSpan);
- }
-
- @Test
- public void dateLineSpanBuilder2() {
- latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(-10, -170))
- .include(new LatLng(10, 170))
- .build();
-
- LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 340),
- latLngSpan);
- }
-
- @Test
- public void dateLineSpanFrom1() {
- latLngBounds = LatLngBounds.from(10, -170, -10, -190);
- LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 20),
- latLngSpan);
- }
-
- @Test
- public void dateLineSpanFrom2() {
- latLngBounds = LatLngBounds.from(10, 170, -10, -170);
- LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be the same", new LatLngSpan(20, 340),
- latLngSpan);
- }
-
- @Test
- public void zeroLongitudeSpan() {
- latLngBounds = LatLngBounds.from(10, 10, -10, 10);
- LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be shortest distance", new LatLngSpan(20, 0),
- latLngSpan);
- }
-
- @Test
- public void nearDateLineCenter1() {
- latLngBounds = LatLngBounds.from(10, -175, -10, -195);
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, -185), center);
- }
-
- @Test
- public void nearDateLineCenter2() {
- latLngBounds = LatLngBounds.from(10, 195, -10, 175);
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, 185), center);
- }
-
- @Test
- public void nearDateLineCenter3() {
- latLngBounds = LatLngBounds.from(10, -170, -10, -190);
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, -180), center);
- }
-
- @Test
- public void nearDateLineCenter4() {
- latLngBounds = LatLngBounds.from(10, 180, -10, 0);
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, 90), center);
- }
-
- @Test
- public void nearDateLineCenter5() {
- latLngBounds = LatLngBounds.from(10, 180, -10, 0);
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, 90), center);
- }
-
- @Test
- public void centerForBoundsWithSameLongitude() {
- latLngBounds = LatLngBounds.from(10, 10, -10, 10);
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(0, 10), center);
- }
-
- @Test
- public void centerForBoundsWithSameLatitude() {
- latLngBounds = LatLngBounds.from(10, 10, 10, -10);
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(10, 0), center);
- }
-
- @Test
- public void center() {
- LatLng center = latLngBounds.getCenter();
- assertEquals("Center should match", new LatLng(1, 1), center);
- }
-
- @Test
- public void notEmptySpan() {
- latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertFalse("Should not be empty", latLngBounds.isEmptySpan());
- }
-
- @Test
- public void includeSameLatLngs() {
- latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertEquals(latLngBounds.getNorthEast(), LAT_LNG_NOT_NULL_ISLAND);
- assertEquals(latLngBounds.getSouthWest(), LAT_LNG_NULL_ISLAND);
- }
-
- @Test
- public void toLatLngs() {
- latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .include(LAT_LNG_NULL_ISLAND)
- .build();
-
- assertArrayEquals("LatLngs should match",
- new LatLng[] {LAT_LNG_NOT_NULL_ISLAND, LAT_LNG_NULL_ISLAND},
- latLngBounds.toLatLngs());
- }
-
- @Test
- public void include() {
- assertTrue("LatLng should be included", latLngBounds.contains(new LatLng(1, 1)));
- }
-
- @Test
- public void includes() {
- List<LatLng> points = new ArrayList<>();
- points.add(LAT_LNG_NULL_ISLAND);
- points.add(LAT_LNG_NOT_NULL_ISLAND);
-
- LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .includes(points)
- .build();
-
- LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
-
- assertEquals("LatLngBounds should match", latLngBounds1, latLngBounds2);
- }
-
- @Test
- public void includesOrderDoesNotMatter() {
- LatLngBounds sameLongitudeFirst = new LatLngBounds.Builder()
- .include(new LatLng(50, 10)) // southWest
- .include(new LatLng(60, 10))
- .include(new LatLng(60, 20)) // northEast
- .include(new LatLng(50, 20))
- .include(new LatLng(50, 10)) // southWest again
- .build();
-
- LatLngBounds sameLatitudeFirst = new LatLngBounds.Builder()
- .include(new LatLng(50, 20))
- .include(new LatLng(50, 10)) // southWest
- .include(new LatLng(60, 10))
- .include(new LatLng(60, 20)) // northEast
- .include(new LatLng(50, 20))
- .build();
-
- assertEquals(sameLatitudeFirst, sameLongitudeFirst);
- }
-
- @Test
- public void includesOverDateline1() {
-
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, -170))
- .include(new LatLng(-10, -175))
- .include(new LatLng(0, -190))
- .build();
-
- LatLngSpan latLngSpan = latLngBounds.getSpan();
- assertEquals("LatLngSpan should be the same",
- new LatLngSpan(20, 20), latLngSpan);
- }
-
- @Test
- public void includesOverDateline2() {
-
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 170))
- .include(new LatLng(-10, 175))
- .include(new LatLng(0, 190))
- .build();
-
- assertEquals("LatLngSpan should be the same",
- new LatLngSpan(20, 20), latLngBounds.getSpan());
- }
-
- @Test
- public void includesOverDateline3() {
-
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, -190))
- .include(new LatLng(-10, -170))
- .include(new LatLng(0, -180))
- .include(new LatLng(5, -180))
- .build();
-
- assertEquals("LatLngSpan should be the same",
- new LatLngSpan(20, 20), latLngBounds.getSpan());
- }
-
- @Test
- public void containsNot() {
- assertFalse("LatLng should not be included",
- latLngBounds.contains(new LatLng(3, 1)));
- }
-
- @Test
- public void containsBoundsInWorld() {
- assertTrue("LatLngBounds should be contained in the world",
- LatLngBounds.world().contains(latLngBounds));
- }
-
- @Test
- public void worldSpan() {
- assertEquals("LatLngBounds world span should be 180, 360",
- GeometryConstants.LATITUDE_SPAN, LatLngBounds.world().getLatitudeSpan(), DELTA);
- assertEquals("LatLngBounds world span should be 180, 360",
- GeometryConstants.LONGITUDE_SPAN, LatLngBounds.world().getLongitudeSpan(), DELTA);
- }
-
- @Test
- public void emptySpan() {
- LatLngBounds latLngBounds = LatLngBounds.from(
- GeometryConstants.MIN_LATITUDE, GeometryConstants.MAX_LONGITUDE,
- GeometryConstants.MIN_LATITUDE, GeometryConstants.MAX_LONGITUDE);
- assertTrue("LatLngBounds empty span", latLngBounds.isEmptySpan());
- }
-
- @Test
- public void containsBounds() {
- LatLngBounds inner = new LatLngBounds.Builder()
- .include(new LatLng(-5, -5))
- .include(new LatLng(5, 5))
- .build();
- LatLngBounds outer = new LatLngBounds.Builder()
- .include(new LatLng(-10, -10))
- .include(new LatLng(10, 10))
- .build();
- assertTrue(outer.contains(inner));
- assertFalse(inner.contains(outer));
- }
-
- @Test
- public void testHashCode() {
- assertEquals(2147483647, latLngBounds.hashCode(), -1946419200);
- }
-
- @Test
- public void equality() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(LAT_LNG_NULL_ISLAND)
- .include(LAT_LNG_NOT_NULL_ISLAND)
- .build();
- assertEquals("equality should match", this.latLngBounds, latLngBounds);
- assertEquals("not equal to a different object type",
- this.latLngBounds.equals(LAT_LNG_NOT_NULL_ISLAND), false);
- }
-
- @Test
- public void testToString() {
- assertEquals(latLngBounds.toString(), "N:2.0; E:2.0; S:0.0; W:0.0");
- }
-
- @Test
- public void intersect() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(1, 1))
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertEquals("intersect should match", latLngBounds,
- latLngBounds.intersect(this.latLngBounds.getLatNorth(),
- this.latLngBounds.getLonEast(),
- this.latLngBounds.getLatSouth(),
- this.latLngBounds.getLonWest()));
- }
-
- @Test
- public void intersectNot() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
- assertNull(latLngBounds.intersect(this.latLngBounds));
- }
-
- @Test
- public void intersectNorthCheck() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds intersectLatLngBounds =
- LatLngBounds.from(10, 10, 0, 0)
- .intersect(200, 200, 0, 0);
- }
-
- @Test
- public void intersectSouthCheck() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds intersectLatLngBounds =
- LatLngBounds.from(0, 0, -10, -10)
- .intersect(0, 0, -200, -200);
- }
-
- @Test
- public void intersectSouthLessThanNorthCheck() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latNorth cannot be less than latSouth");
- LatLngBounds intersectLatLngBounds =
- LatLngBounds.from(10, 10, 0, 0)
- .intersect(0, 200, 20, 0);
- }
-
- @Test
- public void intersectEastLessThanWestCheck() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("lonEast cannot be less than lonWest");
- LatLngBounds intersectLatLngBounds =
- LatLngBounds.from(10, -10, 0, 0)
- .intersect(0, 200, 20, 0);
- }
-
- public void intersectEastDoesNotWrapCheck() {
-
- LatLngBounds latLngBounds1 = LatLngBounds.from(10, 210, 0, 0);
- LatLngBounds latLngBounds2 = LatLngBounds.from(90, 200, 0, 0);
-
- LatLngBounds intersectLatLngBounds = LatLngBounds.from(10, 200, 0, 0);
-
- assertEquals(latLngBounds1.intersect(latLngBounds2), intersectLatLngBounds);
- assertEquals(latLngBounds2.intersect(latLngBounds1), intersectLatLngBounds);
- }
-
- @Test
- public void intersectDoesNotWestWrapCheck() {
- LatLngBounds latLngBounds1 = LatLngBounds.from(0, 0, -10, -210);
- LatLngBounds latLngBounds2 = LatLngBounds.from(0, 0, -90, -200);
-
- LatLngBounds intersectLatLngBounds = LatLngBounds.from(0, 0, -10, -200);
-
- assertEquals(latLngBounds1.intersect(latLngBounds2), intersectLatLngBounds);
- assertEquals(latLngBounds2.intersect(latLngBounds1), intersectLatLngBounds);
- }
-
- @Test
- public void innerUnion() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(1, 1))
- .include(LAT_LNG_NULL_ISLAND)
- .build();
- assertEquals("union should match", latLngBounds, latLngBounds.intersect(this.latLngBounds));
- }
-
- @Test
- public void outerUnion() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
- assertEquals("outer union should match",
- latLngBounds.union(this.latLngBounds),
- new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(LAT_LNG_NULL_ISLAND)
- .build());
- }
-
- @Test
- public void unionOverDateLine() {
- LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, 170))
- .include(new LatLng(0, 160))
- .build();
-
- LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, 190))
- .include(new LatLng(-10, 200))
- .build();
-
- LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
- LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
-
- assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, 200))
- .build());
-
- assertEquals(union1, union2);
- }
-
- @Test
- public void unionOverDateLine2() {
- LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, 170))
- .include(new LatLng(0, 160))
- .build();
-
- LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, 165))
- .include(new LatLng(-10, 200))
- .build();
-
- LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
- LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
-
- assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, 200))
- .build());
-
- assertEquals(union1, union2);
- }
-
- @Test
- public void unionOverDateLine3() {
- LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, 195))
- .include(new LatLng(0, 160))
- .build();
-
- LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, 190))
- .include(new LatLng(-10, 200))
- .build();
-
- LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
- LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
-
- assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, 200))
- .build());
-
- assertEquals(union1, union2);
- }
-
- @Test
- public void unionOverDateLine4() {
- LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, -160))
- .include(new LatLng(0, -200))
- .build();
-
- LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, -170))
- .include(new LatLng(-10, -175))
- .build();
-
- LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
- LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
-
- assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, -200))
- .include(new LatLng(-10, -160))
- .build());
-
- assertEquals(union1, union2);
- }
-
- @Test
- public void unionOverDateLine5() {
- LatLngBounds latLngBounds1 = new LatLngBounds.Builder()
- .include(new LatLng(10, 200))
- .include(new LatLng(0, 160))
- .build();
-
- LatLngBounds latLngBounds2 = new LatLngBounds.Builder()
- .include(new LatLng(0, 170))
- .include(new LatLng(-10, 175))
- .build();
-
- LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
- LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
-
- assertEquals(union1,
- new LatLngBounds.Builder()
- .include(new LatLng(10, 160))
- .include(new LatLng(-10, 200))
- .build());
-
- assertEquals(union1, union2);
- }
-
- @Test
- public void unionOverDateLineReturnLongerThanWorldLonSpan() {
- LatLngBounds latLngBounds1 = LatLngBounds.from(10, 200, -10, -10);
- LatLngBounds latLngBounds2 = LatLngBounds.from(10, 10, -10, -200);
-
- LatLngBounds union1 = latLngBounds1.union(latLngBounds2);
- LatLngBounds union2 = latLngBounds2.union(latLngBounds1);
-
- assertEquals(union1, union2);
- assertEquals(union1, LatLngBounds.from(10, 200, -10, -200));
- }
-
- @Test
- public void unionNorthCheck() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds unionLatLngBounds =
- LatLngBounds.from(10, 10, 0, 0)
- .union(200, 200, 0, 0);
- }
-
- @Test
- public void unionSouthCheck() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds unionLatLngBounds =
- LatLngBounds.from(0, 0, -10, -10)
- .union(0, 0, -200, -200);
- }
-
- @Test
- public void unionSouthLessThanNorthCheck() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latNorth cannot be less than latSouth");
-
- LatLngBounds unionLatLngBounds =
- LatLngBounds.from(10, 10, 0, 0)
- .union(0, 200, 20, 0);
- }
-
-
- @Test
- public void unionEastDoesNotWrapCheck() {
-
- LatLngBounds latLngBounds1 = LatLngBounds.from(10, 10, 0, 0);
- LatLngBounds latLngBounds2 = LatLngBounds.from(90, 200, 0, 0);
- LatLngBounds unionLatLngBounds = LatLngBounds.from(90, 200, 0, 0);
-
- assertEquals(latLngBounds1.union(latLngBounds2), unionLatLngBounds);
- assertEquals(latLngBounds2.union(latLngBounds1), unionLatLngBounds);
- }
-
- @Test
- public void unionWestDoesNotWrapCheck() {
- LatLngBounds latLngBounds1 = LatLngBounds.from(0, 0, -10, -10);
- LatLngBounds latLngBounds2 = LatLngBounds.from(0, 0, -90, -200);
-
- LatLngBounds unionLatLngBounds = LatLngBounds.from(0, 0, -90, -200);
-
- assertEquals(latLngBounds1.union(latLngBounds2), unionLatLngBounds);
- assertEquals(latLngBounds2.union(latLngBounds1), unionLatLngBounds);
- }
-
- @Test
- public void northWest() {
- double minLat = 5;
- double minLon = 6;
- double maxLat = 20;
- double maxLon = 21;
-
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
-
- assertEquals("NorthWest should match", latLngBounds.getNorthWest(), new LatLng(maxLat, minLon));
- }
-
- @Test
- public void southWest() {
- double minLat = 5;
- double minLon = 6;
- double maxLat = 20;
- double maxLon = 21;
-
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
-
- assertEquals("SouthWest should match", latLngBounds.getSouthWest(), new LatLng(minLat, minLon));
- }
-
- @Test
- public void northEast() {
- double minLat = 5;
- double minLon = 6;
- double maxLat = 20;
- double maxLon = 21;
-
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
-
- assertEquals("NorthEast should match", latLngBounds.getNorthEast(), new LatLng(maxLat, maxLon));
- }
-
- @Test
- public void southEast() {
- double minLat = 5;
- double minLon = 6;
- double maxLat = 20;
- double maxLon = 21;
-
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(minLat, minLon))
- .include(new LatLng(maxLat, maxLon))
- .build();
-
- assertEquals("SouthEast should match", latLngBounds.getSouthEast(), new LatLng(minLat, maxLon));
- }
-
- @Test
- public void testParcelable() {
- LatLngBounds latLngBounds = new LatLngBounds.Builder()
- .include(new LatLng(10, 10))
- .include(new LatLng(9, 8))
- .build();
- Parcelable parcel = MockParcel.obtain(latLngBounds);
- assertEquals("Parcel should match original object", parcel, latLngBounds);
- }
-
- @Test
- public void fromTileID() {
- LatLngBounds bounds = LatLngBounds.from(0, 0, 0);
- assertEquals(GeometryConstants.MIN_WRAP_LONGITUDE, bounds.getLonWest(), DELTA);
- assertEquals(GeometryConstants.MIN_MERCATOR_LATITUDE, bounds.getLatSouth(), DELTA);
- assertEquals(GeometryConstants.MAX_WRAP_LONGITUDE, bounds.getLonEast(), DELTA);
- assertEquals(GeometryConstants.MAX_MERCATOR_LATITUDE, bounds.getLatNorth(), DELTA);
-
- bounds = LatLngBounds.from(10, 288, 385);
- assertEquals(-78.75, bounds.getLonWest(), DELTA);
- assertEquals(40.446947059600497, bounds.getLatSouth(), DELTA);
- assertEquals(-78.3984375, bounds.getLonEast(), DELTA);
- assertEquals(40.713955826286039, bounds.getLatNorth(), DELTA);
-
- }
-
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- @Test
- public void testConstructorChecksNorthLatitudeNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must not be NaN");
- LatLngBounds.from(Double.NaN, 0, -20, -20);
- }
-
- @Test
- public void testConstructorChecksEastLongitudeNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be NaN");
- LatLngBounds.from(0, Double.NaN, -20, -20);
- }
-
- @Test
- public void testConstructorChecksNorthLatitudeGreaterThan90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds.from(95, 0, -20, -20);
- }
-
- @Test
- public void testConstructorChecksNorthLatitudeLessThanThanNegative90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds.from(-95, 0, -20, -20);
- }
-
- @Test
- public void testConstructorChecksEastLongitudeInfinity() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be infinite");
- LatLngBounds.from(0, Double.POSITIVE_INFINITY, -20, -20);
- }
-
- @Test
- public void testConstructorChecksSouthLatitudeNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must not be NaN");
- LatLngBounds.from(20, 20, Double.NaN, 0);
- }
-
- @Test
- public void testConstructorChecksWesttLongitudeNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be NaN");
- LatLngBounds.from(20, 20, 0, Double.NaN);
- }
-
- @Test
- public void testConstructorChecksSouthLatitudeGreaterThan90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds.from(20, 20, 95, 0);
- }
-
- @Test
- public void testConstructorChecksSouthLatitudeLessThanThanNegative90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- LatLngBounds.from(20, 20, -95, 0);
- }
-
- @Test
- public void testConstructorChecksWestLongitudeInfinity() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be infinite");
- LatLngBounds.from(20, 20, 0, Double.POSITIVE_INFINITY);
- }
-
- @Test
- public void testConstructorCheckLatSouthGreaterLatNorth() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latNorth cannot be less than latSouth");
- LatLngBounds.from(0, 20, 20, 0);
- }
-
- @Test
- public void testConstructorCheckLonWestGreaterLonEast() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("lonEast cannot be less than lonWest");
- LatLngBounds.from(20, 0, 0, 20);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java
deleted file mode 100644
index 12297247cf..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngSpanTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.mapbox.mapboxsdk.geometry;
-
-import android.os.Parcelable;
-
-import com.mapbox.mapboxsdk.utils.MockParcel;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class LatLngSpanTest {
-
- private static final double DELTA = 1e-15;
- private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
-
- @Test
- public void testSanity() {
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- assertNotNull("latLngSpan should not be null", latLngSpan);
- }
-
- @Test
- public void testEquality() {
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- assertEquals("latLngSpan is not equal to a LatLng", latLngSpan.equals(LAT_LNG_NULL_ISLAND), false);
- }
-
- @Test
- public void testLatitudeConstructor() {
- double latitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(latitude, 0.0);
- assertEquals("latitude in constructor", latLngSpan.getLatitudeSpan(), latitude, DELTA);
- }
-
- @Test
- public void testLongitudeConstructor() {
- double longitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(0.0, longitude);
- assertEquals("latitude in constructor", latLngSpan.getLongitudeSpan(), longitude, DELTA);
- }
-
- @Test
- public void testLatitudeMethod() {
- double latitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- latLngSpan.setLatitudeSpan(latitude);
- assertEquals("latitude in constructor", latLngSpan.getLatitudeSpan(), latitude, DELTA);
- }
-
- @Test
- public void testLongitudeMethod() {
- double longitude = 1.23;
- LatLngSpan latLngSpan = new LatLngSpan(0.0, 0.0);
- latLngSpan.setLongitudeSpan(longitude);
- assertEquals("latitude in constructor", latLngSpan.getLongitudeSpan(), longitude, DELTA);
- }
-
- @Test
- public void testParcelable() {
- LatLngSpan object = new LatLngSpan(1, 2);
- Parcelable parcel = MockParcel.obtain(object);
- assertEquals("parcel should match initial object", object, parcel);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java
deleted file mode 100644
index 862c56a526..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java
+++ /dev/null
@@ -1,286 +0,0 @@
-package com.mapbox.mapboxsdk.geometry;
-
-import android.location.Location;
-import android.os.Parcelable;
-
-import com.mapbox.mapboxsdk.utils.MockParcel;
-
-import org.junit.Test;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class LatLngTest {
-
- private static final double DELTA = 1e-15;
-
- @Test
- public void testSanity() {
- LatLng latLng = new LatLng(0.0, 0.0);
- assertNotNull("latLng should not be null", latLng);
- }
-
- @Test
- public void testLatitudeEmptyConstructor() {
- LatLng latLng = new LatLng();
- assertEquals("latitude default value", latLng.getLatitude(), 0, DELTA);
- }
-
- @Test
- public void testLongitudeEmptyConstructor() {
- LatLng latLng = new LatLng();
- assertEquals("longitude default value", latLng.getLongitude(), 0, DELTA);
- }
-
- @Test
- public void testAltitudeEmptyConstructor() {
- LatLng latLng1 = new LatLng();
- assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA);
- }
-
- @Test
- public void testLatitudeConstructor() {
- double latitude = 1.2;
- LatLng latLng = new LatLng(latitude, 3.4);
- assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
- }
-
- @Test
- public void testLongitudeConstructor() {
- double longitude = 3.4;
- LatLng latLng = new LatLng(1.2, longitude);
- assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
- }
-
- @Test
- public void testAltitudeConstructor() {
- LatLng latLng1 = new LatLng(1.2, 3.4);
- assertEquals("altitude default value", latLng1.getAltitude(), 0.0, DELTA);
-
- double altitude = 5.6;
- LatLng latLng2 = new LatLng(1.2, 3.4, altitude);
- assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA);
- }
-
- @Test
- public void testLatitudeSetter() {
- LatLng latLng = new LatLng(1.2, 3.4);
- latLng.setLatitude(3);
- assertEquals("latitude should match", 3, latLng.getLatitude(), DELTA);
- }
-
- @Test
- public void testLongitudeSetter() {
- LatLng latLng = new LatLng(1.2, 3.4);
- latLng.setLongitude(3);
- assertEquals("longitude should match", 3, latLng.getLongitude(), DELTA);
- }
-
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- @Test
- public void testConstructorChecksLatitudeNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must not be NaN");
- new LatLng(Double.NaN, 0);
- }
-
- @Test
- public void testConstructorChecksLongitudeNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be NaN");
- new LatLng(0, Double.NaN);
- }
-
- @Test
- public void testConstructorChecksLatitudeGreaterThan90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- new LatLng(95, 0);
- }
-
- @Test
- public void testConstructorChecksLatitudeLessThanThanNegative90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- new LatLng(-95, 0);
- }
-
- @Test
- public void testConstructorChecksLongitudeInfinity() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be infinite");
- new LatLng(0, Double.POSITIVE_INFINITY);
- }
-
- @Test
- public void testLatitudeSetterChecksNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must not be NaN");
- new LatLng().setLatitude(Double.NaN);
- }
-
- @Test
- public void testLongitudeSetterChecksNaN() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be NaN");
- new LatLng().setLongitude(Double.NaN);
- }
-
- @Test
- public void testLatitudeSetterChecksGreaterThan90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- new LatLng().setLatitude(95);
- }
-
- @Test
- public void testLatitudeSetterChecksLessThanThanNegative90() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("latitude must be between -90 and 90");
- new LatLng().setLatitude(-95);
- }
-
- @Test
- public void testLongitudeSetterChecksInfinity() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("longitude must not be infinite");
- new LatLng().setLongitude(Double.NEGATIVE_INFINITY);
- }
-
- @Test
- public void testAltitudeSetter() {
- LatLng latLng = new LatLng(1.2, 3.4);
- latLng.setAltitude(3);
- assertEquals("altitude should match", 3, latLng.getAltitude(), DELTA);
- }
-
- @Test
- public void testLatLngConstructor() {
- LatLng latLng1 = new LatLng(1.2, 3.4);
- LatLng latLng2 = new LatLng(latLng1);
- assertEquals("latLng should match", latLng1, latLng2);
- }
-
- @Test
- public void testDistanceTo() {
- LatLng latLng1 = new LatLng(0.0, 0.0);
- LatLng latLng2 = new LatLng(1.0, 1.0);
- assertEquals("distances should match",
- latLng1.distanceTo(latLng2),
- 157298.7453847275, DELTA);
- }
-
- @Test
- public void testDistanceToSamePoint() {
- LatLng latLng1 = new LatLng(40.71199035644531, -74.0081);
- LatLng latLng2 = new LatLng(40.71199035644531, -74.0081);
- double distance = latLng1.distanceTo(latLng2);
- assertEquals("distance should match", 0.0, distance, DELTA);
- }
-
- // Regression test for #14216
- @Test
- public void testDistanceToClosePointNotNaN() {
- LatLng latLng = new LatLng(40.00599, -105.29261);
- LatLng other = new LatLng(40.005990000000025, -105.29260999999997);
- double distance = latLng.distanceTo(other);
- assertNotEquals(distance, Double.NaN);
- }
-
- @Test
- public void testLocationProvider() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
-
- // Mock the location class
- Location locationMocked = mock(Location.class);
- when(locationMocked.getLatitude()).thenReturn(latitude);
- when(locationMocked.getLongitude()).thenReturn(longitude);
- when(locationMocked.getAltitude()).thenReturn(altitude);
-
- // Test the constructor
- LatLng latLng = new LatLng(locationMocked);
- assertEquals("latitude should match", latLng.getLatitude(), latitude, DELTA);
- assertEquals("longitude should match", latLng.getLongitude(), longitude, DELTA);
- assertEquals("altitude should match", latLng.getAltitude(), altitude, DELTA);
- }
-
- @Test
- public void testHashCode() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
- LatLng latLng = new LatLng(latitude, longitude, altitude);
- assertEquals("hash code should match", latLng.hashCode(), -151519232);
- }
-
- @Test
- public void testToString() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
- LatLng latLng = new LatLng(latitude, longitude, altitude);
- assertEquals("string should match",
- latLng.toString(),
- "LatLng [latitude=1.2, longitude=3.4, altitude=5.6]");
- }
-
- @Test
- public void testEqualsOther() {
- double latitude = 1.2;
- double longitude = 3.4;
- double altitude = 5.6;
- LatLng latLng1 = new LatLng(latitude, longitude, altitude);
- LatLng latLng2 = new LatLng(latitude, longitude, altitude);
- assertEquals("LatLng should match", latLng1, latLng2);
- }
-
- @Test
- public void testEqualsItself() {
- LatLng latLng = new LatLng(1, 2, 3);
- assertEquals("LatLng should match", latLng, latLng);
- }
-
- @Test
- public void testNotEquals() {
- LatLng latLng = new LatLng(1, 2);
- assertNotEquals("LatLng should match", latLng, new Object());
- }
-
- @Test
- public void testParcelable() {
- LatLng latLng = new LatLng(45.0, -185.0);
- Parcelable parcel = MockParcel.obtain(latLng);
- assertEquals("parcel should match initial object", latLng, parcel);
- }
-
- @Test
- public void testWrapped() {
- LatLng originalLatLng = new LatLng(45.0, -185.0);
- LatLng newLatlng = originalLatLng.wrap();
- assertNotSame(" new wrapped LatLng is created", originalLatLng, newLatlng);
- assertEquals("longitude wrapped value", originalLatLng.getLongitude(), -185.0, DELTA);
- assertEquals("longitude wrapped value", newLatlng.getLongitude(), 175.0, DELTA);
-
- newLatlng = new LatLng(45.0, 180.0).wrap();
- assertEquals("longitude wrapped max value", newLatlng.getLongitude(), 180.0, DELTA);
-
- newLatlng = new LatLng(45.0, -180.0).wrap();
- assertEquals("longitude wrapped min value", newLatlng.getLongitude(), -180.0, DELTA);
- }
-
- @Test
- public void testUnnecessaryWrapped() {
- LatLng latLng = new LatLng(45.0, 50.0).wrap();
- assertEquals("longitude wrapped value", latLng.getLongitude(), 50.0, DELTA);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java
deleted file mode 100644
index 00fd125a1a..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/ProjectedMetersTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.mapbox.mapboxsdk.geometry;
-
-import android.os.Parcelable;
-
-import com.mapbox.mapboxsdk.utils.MockParcel;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class ProjectedMetersTest {
-
- private static final LatLng LAT_LNG_NULL_ISLAND = new LatLng(0, 0);
-
- @Test
- public void testSanity() {
- ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0);
- assertNotNull("projectedMeters should not be null", projectedMeters);
- }
-
- @Test
- public void testEquality() {
- ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 0.0);
- assertEquals("projectedMeters is not equal to a LatLng", projectedMeters.equals(LAT_LNG_NULL_ISLAND), false);
- assertEquals("projectedMeters is equal to itself", projectedMeters.equals(projectedMeters), true);
- }
-
- @Test
- public void testNorthing() {
- ProjectedMeters projectedMeters = new ProjectedMeters(1.0, 0.0);
- assertEquals("northing should be 1", 1, projectedMeters.getNorthing(), 0);
- }
-
- @Test
- public void testEasting() {
- ProjectedMeters projectedMeters = new ProjectedMeters(0.0, 1.0);
- assertEquals("easting should be 1", 1, projectedMeters.getEasting(), 0);
- }
-
- @Test
- public void testConstructor() {
- ProjectedMeters projectedMeters1 = new ProjectedMeters(1, 2);
- ProjectedMeters projectedMeters2 = new ProjectedMeters(projectedMeters1);
- assertEquals("projectedmeters should match", projectedMeters1, projectedMeters2);
- }
-
- @Test
- public void testHashcode() {
- ProjectedMeters meters = new ProjectedMeters(1, 2);
- assertEquals("hashcode should match", -1048576, meters.hashCode());
- }
-
- @Test
- public void testToString() {
- ProjectedMeters meters = new ProjectedMeters(1, 1);
- assertEquals("toString should match", "ProjectedMeters [northing=1.0, easting=1.0]", meters.toString());
- }
-
- @Test
- public void testParcelable() {
- ProjectedMeters meters = new ProjectedMeters(1, 1);
- Parcelable parcel = MockParcel.obtain(meters);
- assertEquals("parcel should match initial object", meters, parcel);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java
deleted file mode 100644
index 12b779de5d..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/VisibleRegionTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package com.mapbox.mapboxsdk.geometry;
-
-import android.os.Parcelable;
-
-import com.mapbox.mapboxsdk.utils.MockParcel;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class VisibleRegionTest {
-
- private static final LatLng FAR_LEFT = new LatLng(52, -12);
- private static final LatLng NEAR_LEFT = new LatLng(34, -12);
- private static final LatLng FAR_RIGHT = new LatLng(52, 26);
- private static final LatLng NEAR_RIGHT = new LatLng(34, 26);
- private static final LatLngBounds BOUNDS =
- new LatLngBounds.Builder().include(FAR_LEFT).include(FAR_RIGHT).include(NEAR_LEFT).include(NEAR_RIGHT).build();
-
- @Test
- public void testSanity() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertNotNull("region should not be null", region);
- }
-
- @Test
- public void testEquality() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("visibleRegion is not equal to a LatLng", region.equals(FAR_LEFT), false);
- assertEquals("visibleRegion is equal to itself", region.equals(region), true);
- }
-
- @Test
- public void testFarLeftConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.farLeft, FAR_LEFT);
- }
-
- @Test
- public void testNearLeftConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.nearLeft, NEAR_LEFT);
- }
-
- @Test
- public void testFarRightConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.farRight, FAR_RIGHT);
- }
-
- @Test
- public void testNearRightConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLng should match", region.nearRight, NEAR_RIGHT);
- }
-
- @Test
- public void testLatLngBoundsConstructor() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("LatLngBounds should match", region.latLngBounds, BOUNDS);
- }
-
- @Test
- public void testEquals() {
- VisibleRegion regionLeft = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- VisibleRegion regionRight = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("VisibleRegions should match", regionLeft, regionRight);
- }
-
- @Test
- public void testHashcode() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("hashcode should match", -923534102, region.hashCode());
- }
-
- @Test
- public void testToString() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- assertEquals("string should match",
- "[farLeft [LatLng [latitude=52.0, longitude=-12.0, altitude=0.0]], "
- + "farRight [LatLng [latitude=52.0, longitude=26.0, altitude=0.0]], "
- + "nearLeft [LatLng [latitude=34.0, longitude=-12.0, altitude=0.0]], "
- + "nearRight [LatLng [latitude=34.0, longitude=26.0, altitude=0.0]], "
- + "latLngBounds [N:52.0; E:26.0; S:34.0; W:-12.0]]",
- region.toString());
- }
-
- @Test
- public void testParcelable() {
- VisibleRegion region = new VisibleRegion(FAR_LEFT, FAR_RIGHT, NEAR_LEFT, NEAR_RIGHT, BOUNDS);
- Parcelable parcel = MockParcel.obtain(region);
- assertEquals("parcel should match initial object", region, parcel);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/CompassEngineTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/CompassEngineTest.java
deleted file mode 100644
index bebd828118..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/CompassEngineTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-import android.hardware.Sensor;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.view.WindowManager;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import static com.mapbox.mapboxsdk.location.LocationComponentCompassEngine.SENSOR_DELAY_MICROS;
-import static junit.framework.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class CompassEngineTest {
-
- private LocationComponentCompassEngine compassEngine;
-
- @Mock
- private WindowManager windowManager;
-
- @Mock
- private SensorManager sensorManager;
-
- @Mock
- private Sensor compassSensor;
-
- @Mock
- private CompassListener compassListener;
-
- @Before
- public void setUp() throws Exception {
- when(sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR)).thenReturn(compassSensor);
- compassEngine = new LocationComponentCompassEngine(windowManager, sensorManager);
- }
-
- @Test
- public void lastKnownCompassBearingAccuracyDefault() {
- assertEquals("Last accuracy should match", compassEngine.getLastAccuracySensorStatus(), 0);
- }
-
- @Test
- public void lastKnownCompassAccuracyStatusValue() {
- Sensor sensor = mock(Sensor.class);
- compassEngine.onAccuracyChanged(sensor, 2);
- assertEquals("Last accuracy should match", compassEngine.getLastAccuracySensorStatus(), 2);
- }
-
- @Test
- public void whenGyroscopeIsNull_fallbackToGravity() {
- SensorManager sensorManager = mock(SensorManager.class);
- when(sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)).thenReturn(null);
- new LocationComponentCompassEngine(windowManager, sensorManager);
-
- verify(sensorManager, times(1)).getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
- }
-
- @Test
- public void whenGyroscopeIsNull_fallbackToMagneticField() {
- SensorManager sensorManager = mock(SensorManager.class);
- when(sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)).thenReturn(null);
- new LocationComponentCompassEngine(windowManager, sensorManager);
-
- verify(sensorManager, times(1)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
- }
-
- @Test
- public void listener_registerOnAdd() {
- compassEngine.addCompassListener(compassListener);
- verify(sensorManager)
- .registerListener(any(SensorEventListener.class), eq(compassSensor), eq(SENSOR_DELAY_MICROS));
- }
-
- @Test
- public void listener_unregisterOnRemove() {
- compassEngine.addCompassListener(compassListener);
- compassEngine.removeCompassListener(compassListener);
- verify(sensorManager).unregisterListener(any(SensorEventListener.class), eq(compassSensor));
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt
deleted file mode 100644
index 1b927d213a..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinatorTest.kt
+++ /dev/null
@@ -1,532 +0,0 @@
-package com.mapbox.mapboxsdk.location
-
-import android.animation.Animator
-import android.location.Location
-import android.util.SparseArray
-import android.view.animation.LinearInterpolator
-import com.mapbox.mapboxsdk.camera.CameraPosition
-import com.mapbox.mapboxsdk.geometry.LatLng
-import com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION
-import com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION
-import com.mapbox.mapboxsdk.location.MapboxAnimator.*
-import com.mapbox.mapboxsdk.location.modes.CameraMode
-import com.mapbox.mapboxsdk.location.modes.RenderMode
-import com.mapbox.mapboxsdk.maps.MapboxMap
-import com.mapbox.mapboxsdk.maps.Projection
-import io.mockk.*
-import junit.framework.Assert.assertEquals
-import junit.framework.Assert.assertTrue
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mockito
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class LocationAnimatorCoordinatorTest {
-
- private lateinit var locationAnimatorCoordinator: LocationAnimatorCoordinator
- private val cameraPosition: CameraPosition = CameraPosition.DEFAULT
-
- private val animatorProvider: MapboxAnimatorProvider = mockk()
- private val animatorSetProvider: MapboxAnimatorSetProvider = mockk()
-
- private val projection: Projection = mockk()
-
- @Before
- fun setUp() {
- locationAnimatorCoordinator = LocationAnimatorCoordinator(projection, animatorSetProvider, animatorProvider)
- configureAnimatorProvider()
- every { projection.getMetersPerPixelAtLatitude(any()) } answers { 1.0 }
- every { animatorSetProvider.startAnimation(any(), any(), any()) } answers {}
- locationAnimatorCoordinator.updateAnimatorListenerHolders(getListenerHoldersSet(
- ANIMATOR_LAYER_LATLNG,
- ANIMATOR_CAMERA_LATLNG,
- ANIMATOR_LAYER_GPS_BEARING,
- ANIMATOR_LAYER_COMPASS_BEARING,
- ANIMATOR_CAMERA_GPS_BEARING,
- ANIMATOR_CAMERA_COMPASS_BEARING,
- ANIMATOR_LAYER_ACCURACY,
- ANIMATOR_ZOOM,
- ANIMATOR_TILT
- ))
- }
-
- private fun configureAnimatorProvider() {
- // workaround https://github.com/mockk/mockk/issues/229#issuecomment-457816131
- registerInstanceFactory { AnimationsValueChangeListener<Float> {} }
- registerInstanceFactory { AnimationsValueChangeListener<LatLng> {} }
- val previousFloatSlot = slot<Float>()
- val targetFloatSlot = slot<Float>()
- val listenerSlot = slot<MapboxAnimator.AnimationsValueChangeListener<*>>()
- val maxFpsSlot = slot<Int>()
- every {
- animatorProvider.floatAnimator(capture(previousFloatSlot), capture(targetFloatSlot), capture(listenerSlot), capture(maxFpsSlot))
- } answers {
- MapboxFloatAnimator(previousFloatSlot.captured, targetFloatSlot.captured, listenerSlot.captured, maxFpsSlot.captured)
- }
-
- val previousLatLngSlot = slot<LatLng>()
- val targetLatLngSlot = slot<LatLng>()
- every {
- animatorProvider.latLngAnimator(capture(previousLatLngSlot), capture(targetLatLngSlot), capture(listenerSlot), capture(maxFpsSlot))
- } answers {
- MapboxLatLngAnimator(previousLatLngSlot.captured, targetLatLngSlot.captured, listenerSlot.captured, maxFpsSlot.captured)
- }
-
- val callback = slot<MapboxMap.CancelableCallback>()
- every {
- animatorProvider.cameraAnimator(capture(previousFloatSlot), capture(targetFloatSlot), capture(listenerSlot), capture(callback))
- } answers {
- MapboxCameraAnimatorAdapter(previousFloatSlot.captured, targetFloatSlot.captured, listenerSlot.captured, callback.captured)
- }
- every {
- animatorProvider.cameraAnimator(capture(previousFloatSlot), capture(targetFloatSlot), capture(listenerSlot), null)
- } answers {
- MapboxCameraAnimatorAdapter(previousFloatSlot.captured, targetFloatSlot.captured, listenerSlot.captured, null)
- }
- }
-
- @Test
- fun feedNewLocation_animatorsAreCreated() {
- locationAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, false)
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_LATLNG] != null)
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_GPS_BEARING] != null)
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_LATLNG] != null)
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING] != null)
- }
-
- @Test
- fun feedNewLocation_animatorValue() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 35f
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- val cameraLatLngTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
- assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
-
- val layerLatLngTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_LATLNG]?.target as LatLng
- assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
-
- val cameraBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
- assertEquals(location.bearing, cameraBearingTarget)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(location.bearing, layerBearingTarget)
- }
-
- @Test
- fun feedNewLocation_animatorValue_correctRotation_1() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 0f
-
- val animator = mockk<MapboxFloatAnimator>(relaxed = true)
- every { animator.animatedValue } returns 270f
- locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
-
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(360f, layerBearingTarget)
- }
-
- @Test
- fun feedNewLocation_animatorValue_correctRotation_2() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 90f
-
- val animator = mockk<MapboxFloatAnimator>(relaxed = true)
- every { animator.animatedValue } returns 280f
- locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
-
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(450f, layerBearingTarget)
- }
-
- @Test
- fun feedNewLocation_animatorValue_correctRotation_3() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 300f
-
- val animator = mockk<MapboxFloatAnimator>(relaxed = true)
- every { animator.animatedValue } returns 450f
- locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
-
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(-60f, layerBearingTarget)
- }
-
- @Test
- fun feedNewLocation_animatorValue_correctRotation_4() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 350f
-
- val animator = mockk<MapboxFloatAnimator>(relaxed = true)
- every { animator.animatedValue } returns 10f
- locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
-
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(-10f, layerBearingTarget)
- }
-
- @Test
- fun feedNewLocation_animatorValue_correctRotation_5() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 90f
-
- val animator = mockk<MapboxFloatAnimator>(relaxed = true)
- every { animator.animatedValue } returns -280f
- locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
-
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(90f, layerBearingTarget)
- }
-
- @Test
- fun feedNewLocation_animatorValue_correctRotation_6() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 270f
-
- val animator = mockk<MapboxFloatAnimator>(relaxed = true)
- every { animator.animatedValue } returns -350f
- locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
-
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(-90f, layerBearingTarget)
- }
-
- @Test
- fun feedNewLocation_isNorth_animatorsAreCreated() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 35f
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_LATLNG] != null)
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_GPS_BEARING] != null)
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_LATLNG] != null)
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING] != null)
- }
-
- @Test
- fun feedNewLocation_isNorth_animatorValue() {
- val location = Location("")
- location.latitude = 51.0
- location.longitude = 17.0
- location.bearing = 35f
- locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, true)
-
- val cameraLatLngTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
- assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
-
- val layerLatLngTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_LATLNG]?.target as LatLng
- assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
-
- val cameraBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
- assertEquals(0f, cameraBearingTarget)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
- assertEquals(location.bearing, layerBearingTarget)
- }
-
- @Test
- fun feedNewCompassBearing_animatorsAreCreated() {
- locationAnimatorCoordinator.feedNewCompassBearing(77f, cameraPosition)
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_COMPASS_BEARING] != null)
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_COMPASS_BEARING] != null)
- }
-
- @Test
- fun feedNewCompassBearing_animatorValue() {
- val bearing = 77f
- locationAnimatorCoordinator.feedNewCompassBearing(bearing, cameraPosition)
-
- val cameraBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_COMPASS_BEARING]?.target as Float
- assertEquals(bearing, cameraBearingTarget)
-
- val layerBearingTarget = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_COMPASS_BEARING]?.target as Float
- assertEquals(bearing, layerBearingTarget)
- }
-
- @Test
- fun feedNewAccuracyRadius_animatorsCreated() {
- locationAnimatorCoordinator.feedNewAccuracyRadius(150f, false)
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_ACCURACY] != null)
- }
-
- @Test
- fun feedNewAccuracyRadius_animatorValue() {
- val accuracy = 150f
- locationAnimatorCoordinator.feedNewAccuracyRadius(accuracy, false)
-
- val layerAccuracy = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_ACCURACY]?.target as Float
- assertEquals(layerAccuracy, accuracy)
- }
-
- @Test
- fun feedNewAccuracyRadius_noAnimation_animatorsCreated() {
- locationAnimatorCoordinator.feedNewAccuracyRadius(150f, true)
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_ACCURACY] != null)
- }
-
- @Test
- fun feedNewAccuracyRadius_noAnimation_animatorValue() {
- val accuracy = 150f
- locationAnimatorCoordinator.feedNewAccuracyRadius(accuracy, true)
-
- val layerAccuracy = locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_ACCURACY]?.target as Float
- assertEquals(layerAccuracy, accuracy)
- }
-
- @Test
- fun feedNewZoomLevel_animatorsCreated() {
- locationAnimatorCoordinator.feedNewZoomLevel(
- 15.0,
- cameraPosition,
- DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
- null
- )
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_ZOOM] != null)
- }
-
- @Test
- fun feedNewZoomLevel_animatorValue() {
- val zoom = 15.0f
- locationAnimatorCoordinator.feedNewZoomLevel(
- zoom.toDouble(),
- cameraPosition,
- DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
- null
- )
-
- val animator = locationAnimatorCoordinator.animatorArray[ANIMATOR_ZOOM]
- assertEquals(zoom, animator.target)
- verify { animatorSetProvider.startAnimation(eq(listOf(animator)), any<LinearInterpolator>(), DEFAULT_TRACKING_ZOOM_ANIM_DURATION) }
- }
-
- @Test
- fun feedNewTiltLevel_animatorsCreated() {
- locationAnimatorCoordinator.feedNewTilt(
- 30.0,
- cameraPosition,
- DEFAULT_TRACKING_TILT_ANIM_DURATION,
- null
- )
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_TILT] != null)
- }
-
- @Test
- fun feedNewTiltLevel_animatorValue() {
- val tilt = 30.0f
- locationAnimatorCoordinator.feedNewTilt(
- tilt.toDouble(),
- cameraPosition,
- DEFAULT_TRACKING_TILT_ANIM_DURATION,
- null
- )
-
- val animator = locationAnimatorCoordinator.animatorArray[ANIMATOR_TILT]
- assertEquals(tilt, animator.target)
- verify { animatorSetProvider.startAnimation(eq(listOf(animator)), any<LinearInterpolator>(), DEFAULT_TRACKING_TILT_ANIM_DURATION) }
- }
-
- @Test
- fun cancelAllAnimators() {
- locationAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, true)
- locationAnimatorCoordinator.cancelAllAnimations()
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_LATLNG] == null)
- }
-
- @Test
- fun cancelZoomAnimators() {
- locationAnimatorCoordinator.feedNewZoomLevel(
- 15.0,
- cameraPosition,
- DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
- null
- )
- locationAnimatorCoordinator.cancelZoomAnimation()
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_ZOOM] == null)
- }
-
- @Test
- fun cancelTiltAnimation() {
- locationAnimatorCoordinator.feedNewTilt(
- 30.0,
- cameraPosition,
- DEFAULT_TRACKING_TILT_ANIM_DURATION,
- null
- )
-
- locationAnimatorCoordinator.cancelTiltAnimation()
-
- assertTrue(locationAnimatorCoordinator.animatorArray[ANIMATOR_TILT] == null)
- }
-
- @Test
- fun resetAllCameraAnimations_empty() {
- locationAnimatorCoordinator.resetAllCameraAnimations(cameraPosition, false)
- assertTrue(locationAnimatorCoordinator.animatorArray.size() == 0)
- }
-
- @Test
- fun resetAllLayerAnimations_empty() {
- locationAnimatorCoordinator.resetAllLayerAnimations()
- assertTrue(locationAnimatorCoordinator.animatorArray.size() == 0)
- }
-
- @Test
- fun addNewListener() {
- val listener = Mockito.mock(AnimationsValueChangeListener::class.java)
- val holder = AnimatorListenerHolder(RenderMode.NORMAL, listener)
- val set = HashSet<AnimatorListenerHolder>().also {
- it.add(holder)
- }
- locationAnimatorCoordinator.updateAnimatorListenerHolders(set)
-
- assertTrue(locationAnimatorCoordinator.listeners.contains(listener))
- }
-
- @Test
- fun updateListeners() {
- val listener = Mockito.mock(AnimationsValueChangeListener::class.java)
- val holder = AnimatorListenerHolder(RenderMode.NORMAL, listener)
- val set = HashSet<AnimatorListenerHolder>().also {
- it.add(holder)
- }
- locationAnimatorCoordinator.updateAnimatorListenerHolders(set)
-
- val listener2 = Mockito.mock(AnimationsValueChangeListener::class.java)
- val holder2 = AnimatorListenerHolder(RenderMode.NORMAL, listener2)
- val listener3 = Mockito.mock(AnimationsValueChangeListener::class.java)
- val holder3 = AnimatorListenerHolder(CameraMode.TRACKING_GPS, listener3)
- val set2 = HashSet<AnimatorListenerHolder>().also {
- it.add(holder2)
- it.add(holder3)
- }
- locationAnimatorCoordinator.updateAnimatorListenerHolders(set2)
-
- assertTrue(locationAnimatorCoordinator.listeners.size() == 2)
- assertTrue(locationAnimatorCoordinator.listeners.contains(listener2))
- assertTrue(locationAnimatorCoordinator.listeners.contains(listener3))
- }
-
- @Test
- fun feedNewCompassBearing_withAnimation() {
- locationAnimatorCoordinator.setCompassAnimationEnabled(true)
- locationAnimatorCoordinator.feedNewCompassBearing(77f, cameraPosition)
-
- val animators = mutableListOf<Animator>(
- locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_COMPASS_BEARING],
- locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_COMPASS_BEARING])
-
- verify(exactly = 1) { animatorSetProvider.startAnimation(eq(animators), ofType(LinearInterpolator::class), eq(LocationComponentConstants.COMPASS_UPDATE_RATE_MS)) }
- }
-
- @Test
- fun feedNewCompassBearing_withoutAnimation() {
- locationAnimatorCoordinator.setCompassAnimationEnabled(false)
- locationAnimatorCoordinator.feedNewCompassBearing(77f, cameraPosition)
-
- val animators = mutableListOf<Animator>(
- locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_COMPASS_BEARING],
- locationAnimatorCoordinator.animatorArray[ANIMATOR_CAMERA_COMPASS_BEARING])
-
- verify(exactly = 1) { animatorSetProvider.startAnimation(eq(animators), ofType(LinearInterpolator::class), eq(0)) }
- }
-
- @Test
- fun feedNewAccuracy_withAnimation() {
- locationAnimatorCoordinator.setAccuracyAnimationEnabled(true)
- locationAnimatorCoordinator.feedNewAccuracyRadius(150f, false)
-
- val animators = mutableListOf<Animator>(
- locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_ACCURACY])
-
- verify(exactly = 1) { animatorSetProvider.startAnimation(eq(animators), ofType(LinearInterpolator::class), eq(LocationComponentConstants.ACCURACY_RADIUS_ANIMATION_DURATION)) }
- }
-
- @Test
- fun feedNewAccuracy_withoutAnimation() {
- locationAnimatorCoordinator.setAccuracyAnimationEnabled(false)
- locationAnimatorCoordinator.feedNewAccuracyRadius(150f, false)
-
- val animators = mutableListOf<Animator>(
- locationAnimatorCoordinator.animatorArray[ANIMATOR_LAYER_ACCURACY])
-
- verify(exactly = 1) { animatorSetProvider.startAnimation(eq(animators), ofType(LinearInterpolator::class), eq(0)) }
- }
-
- @Test
- fun maxFps_setter() {
- locationAnimatorCoordinator.setMaxAnimationFps(5)
- assertEquals(5, locationAnimatorCoordinator.maxAnimationFps)
- }
-
- @Test
- fun maxFps_moreThanZeroRequired() {
- locationAnimatorCoordinator.setMaxAnimationFps(0)
- assertEquals(Int.MAX_VALUE, locationAnimatorCoordinator.maxAnimationFps)
- locationAnimatorCoordinator.setMaxAnimationFps(-1)
- assertEquals(Int.MAX_VALUE, locationAnimatorCoordinator.maxAnimationFps)
- }
-
- @Test
- fun maxFps_givenToAnimator() {
- locationAnimatorCoordinator.setMaxAnimationFps(5)
- locationAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, false)
- verify { animatorProvider.latLngAnimator(any(), any(), any(), 5) }
- verify { animatorProvider.floatAnimator(any(), any(), any(), 5) }
- }
-
- private fun getListenerHoldersSet(vararg animatorTypes: Int): Set<AnimatorListenerHolder> {
- return HashSet<AnimatorListenerHolder>().also {
- for (type in animatorTypes) {
- it.add(AnimatorListenerHolder(type, mockk()))
- }
- }
- }
-}
-
-private fun <E> SparseArray<E>.contains(listener: AnimationsValueChangeListener<*>?): Boolean {
- for (i in 0 until this.size()) {
- val element = this.get(this.keyAt(i))
- if (element == listener) {
- return true
- }
- }
- return false
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java
deleted file mode 100644
index d1b8642c31..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java
+++ /dev/null
@@ -1,1001 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-import android.graphics.PointF;
-import android.location.Location;
-
-import com.mapbox.android.gestures.AndroidGesturesManager;
-import com.mapbox.android.gestures.MoveGestureDetector;
-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.MapboxMap;
-import com.mapbox.mapboxsdk.maps.Projection;
-import com.mapbox.mapboxsdk.maps.Transform;
-import com.mapbox.mapboxsdk.maps.UiSettings;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.util.Set;
-
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.TRANSITION_ANIMATION_DURATION_MS;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_CAMERA_COMPASS_BEARING;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_CAMERA_GPS_BEARING;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_CAMERA_LATLNG;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_TILT;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_ZOOM;
-import static com.mapbox.mapboxsdk.location.modes.CameraMode.NONE;
-import static com.mapbox.mapboxsdk.location.modes.CameraMode.NONE_COMPASS;
-import static com.mapbox.mapboxsdk.location.modes.CameraMode.NONE_GPS;
-import static com.mapbox.mapboxsdk.location.modes.CameraMode.TRACKING;
-import static com.mapbox.mapboxsdk.location.modes.CameraMode.TRACKING_COMPASS;
-import static com.mapbox.mapboxsdk.location.modes.CameraMode.TRACKING_GPS;
-import static com.mapbox.mapboxsdk.location.modes.CameraMode.TRACKING_GPS_NORTH;
-import static junit.framework.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class LocationCameraControllerTest {
-
- @Test
- public void setCameraMode_mapTransitionsAreCancelled() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- LocationCameraController camera = buildCamera(mapboxMap);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(TRACKING_GPS);
-
- verify(mapboxMap).cancelTransitions();
- }
-
- @Test
- public void setCameraMode_gestureThresholdIsAdjusted() {
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- LocationCameraController camera = buildCamera(moveGestureDetector);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- float moveThreshold = 5f;
- when(options.trackingInitialMoveThreshold()).thenReturn(moveThreshold);
- when(options.trackingGesturesManagement()).thenReturn(true);
- camera.initializeOptions(options);
-
- camera.setCameraMode(TRACKING_GPS);
-
- verify(moveGestureDetector).setMoveThreshold(moveThreshold);
- }
-
- @Test
- public void setCameraMode_gestureThresholdNotAdjustedWhenDisabled() {
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- LocationCameraController camera = buildCamera(moveGestureDetector);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- float moveThreshold = 5f;
- when(options.trackingInitialMoveThreshold()).thenReturn(moveThreshold);
- when(options.trackingGesturesManagement()).thenReturn(false);
- camera.initializeOptions(options);
-
- camera.setCameraMode(TRACKING_GPS);
-
- verify(moveGestureDetector, times(0)).setMoveThreshold(moveThreshold);
- verify(moveGestureDetector, times(0)).setMoveThreshold(0f);
- }
-
- @Test
- public void setCameraMode_gestureThresholdIsResetWhenNotTracking() {
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- LocationCameraController camera = buildCamera(moveGestureDetector);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.trackingGesturesManagement()).thenReturn(true);
- camera.initializeOptions(options);
-
- camera.setCameraMode(NONE);
-
- verify(moveGestureDetector, times(2)).setMoveThreshold(0f); // one for initialization
- }
-
- @Test
- public void setCameraMode_notTrackingAdjustsFocalPoint() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- LocationCameraController camera = buildCamera(mapboxMap);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(TRACKING_GPS);
- camera.setCameraMode(NONE);
-
- verify(mapboxMap.getUiSettings()).setFocalPoint(null);
- }
-
- @Test
- public void setCameraMode_trackingChangeListenerCameraDismissedIsCalled() {
- OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- LocationCameraController camera = buildCamera(internalTrackingChangedListener);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(TRACKING_GPS);
- camera.setCameraMode(NONE);
-
- verify(internalTrackingChangedListener).onCameraTrackingDismissed();
- }
-
- @Test
- public void setCameraMode_internalCameraTrackingChangeListenerIsCalled() {
- OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- LocationCameraController camera = buildCamera(internalTrackingChangedListener);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- int cameraMode = NONE;
-
- camera.setCameraMode(cameraMode);
-
- verify(internalTrackingChangedListener).onCameraTrackingChanged(cameraMode);
- }
-
- @Test
- public void setCameraMode_doNotNotifyAboutDuplicates_NONE() {
- OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- LocationCameraController camera = buildCamera(internalTrackingChangedListener);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- int cameraMode = NONE;
-
- camera.setCameraMode(cameraMode);
- camera.setCameraMode(cameraMode);
-
- verify(internalTrackingChangedListener, times(1)).onCameraTrackingChanged(cameraMode);
- }
-
- @Test
- public void setCameraMode_doNotNotifyAboutDuplicates_TRACKING_GPS() {
- OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- LocationCameraController camera = buildCamera(internalTrackingChangedListener);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- int cameraMode = TRACKING_GPS;
-
- camera.setCameraMode(cameraMode);
- camera.setCameraMode(cameraMode);
-
- verify(internalTrackingChangedListener, times(1)).onCameraTrackingChanged(cameraMode);
- }
-
- @Test
- public void setCameraMode_cancelTransitionsWhenSet() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
- LocationCameraController camera = buildCamera(mapboxMap);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(NONE_COMPASS);
- verify(mapboxMap, times(1)).cancelTransitions();
-
- camera.setCameraMode(NONE_GPS);
- verify(mapboxMap, times(2)).cancelTransitions();
-
- camera.setCameraMode(TRACKING);
- verify(mapboxMap, times(3)).cancelTransitions();
-
- camera.setCameraMode(TRACKING_COMPASS);
- verify(mapboxMap, times(4)).cancelTransitions();
-
- camera.setCameraMode(TRACKING_GPS);
- verify(mapboxMap, times(5)).cancelTransitions();
-
- camera.setCameraMode(TRACKING_GPS_NORTH);
- verify(mapboxMap, times(6)).cancelTransitions();
- }
-
- @Test
- public void setCameraMode_dontCancelTransitionsWhenNoneSet() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
- LocationCameraController camera = buildCamera(mapboxMap);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(NONE);
- verify(mapboxMap, never()).cancelTransitions();
- }
-
- @Test
- public void onNewLatLngValue_cameraModeTrackingUpdatesLatLng() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING);
- LatLng latLng = mock(LatLng.class);
-
- getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()).onNewAnimationValue(latLng);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewLatLngValue_cameraModeTrackingGpsNorthUpdatesLatLng() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING_GPS_NORTH);
- LatLng latLng = mock(LatLng.class);
-
- getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()).onNewAnimationValue(latLng);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewLatLngValue_cameraModeTrackingGpsUpdatesLatLng() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING_GPS);
- LatLng latLng = mock(LatLng.class);
-
- getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()).onNewAnimationValue(latLng);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewLatLngValue_cameraModeTrackingCompassUpdatesLatLng() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING_COMPASS);
- LatLng latLng = mock(LatLng.class);
-
- getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()).onNewAnimationValue(latLng);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewLatLngValue_cameraModeNoneIgnored() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(NONE);
-
- assertNull(getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()));
- verify(transform, times(0)).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewLatLngValue_focalPointIsAdjusted() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- UiSettings uiSettings = mock(UiSettings.class);
- when(mapboxMap.getUiSettings()).thenReturn(uiSettings);
- Projection projection = mock(Projection.class);
- PointF pointF = mock(PointF.class);
- when(projection.toScreenLocation(any(LatLng.class))).thenReturn(pointF);
- when(mapboxMap.getProjection()).thenReturn(projection);
- LocationCameraController camera = buildCamera(mapboxMap);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.trackingGesturesManagement()).thenReturn(true);
- camera.initializeOptions(options);
- camera.setCameraMode(TRACKING);
- LatLng latLng = mock(LatLng.class);
-
- getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()).onNewAnimationValue(latLng);
-
- verify(uiSettings).setFocalPoint(pointF);
- }
-
- @Test
- public void onNewGpsBearingValue_cameraModeTrackingGpsUpdatesBearing() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING_GPS);
- float gpsBearing = 5f;
-
- getAnimationListener(ANIMATOR_CAMERA_GPS_BEARING, camera.getAnimationListeners()).onNewAnimationValue(gpsBearing);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewGpsBearingValue_cameraModeNoneGpsUpdatesBearing() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(NONE_GPS);
- float gpsBearing = 5f;
-
- getAnimationListener(ANIMATOR_CAMERA_GPS_BEARING, camera.getAnimationListeners()).onNewAnimationValue(gpsBearing);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewGpsBearingValue_cameraModeTrackingNorthUpdatesBearing() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- CameraPosition cameraPosition = new CameraPosition.Builder().bearing(7d).build();
- when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING_GPS_NORTH);
- float gpsBearing = 5f;
-
- getAnimationListener(ANIMATOR_CAMERA_GPS_BEARING, camera.getAnimationListeners()).onNewAnimationValue(gpsBearing);
-
- verify(transform).moveCamera(eq(mapboxMap), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewGpsBearingValue_cameraModeTrackingNorthBearingZeroIgnored() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- CameraPosition cameraPosition = new CameraPosition.Builder().bearing(0d).build();
- when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING_GPS_NORTH);
- float gpsBearing = 5f;
-
- getAnimationListener(ANIMATOR_CAMERA_GPS_BEARING, camera.getAnimationListeners()).onNewAnimationValue(gpsBearing);
-
- verify(transform, times(0)).moveCamera(eq(mapboxMap), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewGpsBearingValue_cameraModeNoneIgnored() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(NONE);
-
- assertNull(getAnimationListener(ANIMATOR_CAMERA_GPS_BEARING, camera.getAnimationListeners()));
- verify(transform, times(0)).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewCompassBearingValue_cameraModeTrackingCompassUpdatesBearing() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING_COMPASS);
- float compassBearing = 5f;
-
- getAnimationListener(ANIMATOR_CAMERA_COMPASS_BEARING, camera.getAnimationListeners())
- .onNewAnimationValue(compassBearing);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewCompassBearingValue_cameraModeNoneCompassUpdatesBearing() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(NONE_COMPASS);
- float compassBearing = 5f;
-
- getAnimationListener(ANIMATOR_CAMERA_COMPASS_BEARING, camera.getAnimationListeners())
- .onNewAnimationValue(compassBearing);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewCompassBearingValue_cameraModeNoneIgnored() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(NONE);
-
- assertNull(getAnimationListener(ANIMATOR_CAMERA_COMPASS_BEARING, camera.getAnimationListeners()));
- verify(transform, times(0)).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNewZoomValue_cameraIsUpdated() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING);
- float zoom = 5f;
-
- getAnimationListener(ANIMATOR_ZOOM, camera.getAnimationListeners()).onNewAnimationValue(zoom);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void onNeTiltValue_cameraIsUpdated() {
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- camera.setCameraMode(TRACKING);
- float tilt = 5f;
-
- getAnimationListener(ANIMATOR_TILT, camera.getAnimationListeners()).onNewAnimationValue(tilt);
-
- verify(transform).moveCamera(any(MapboxMap.class), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void gesturesManagement_enabled() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- when(mapboxMap.getGesturesManager()).thenReturn(initialGesturesManager);
- LocationCameraController camera = buildCamera(mapboxMap, initialGesturesManager, internalGesturesManager);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.trackingGesturesManagement()).thenReturn(true);
- camera.initializeOptions(options);
-
- verify(mapboxMap).setGesturesManager(internalGesturesManager, true, true);
- }
-
- @Test
- public void gesturesManagement_disabled() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- when(mapboxMap.getGesturesManager()).thenReturn(internalGesturesManager);
- LocationCameraController camera = buildCamera(mapboxMap, initialGesturesManager, internalGesturesManager);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.trackingGesturesManagement()).thenReturn(false);
- camera.initializeOptions(options);
-
- verify(mapboxMap).setGesturesManager(initialGesturesManager, true, true);
- }
-
- @Test
- public void gesturesManagement_optionNotChangedInitial() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- when(mapboxMap.getGesturesManager()).thenReturn(initialGesturesManager);
- LocationCameraController camera = buildCamera(mapboxMap, initialGesturesManager, internalGesturesManager);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.trackingGesturesManagement()).thenReturn(false);
- camera.initializeOptions(options);
-
- verify(mapboxMap, times(0)).setGesturesManager(initialGesturesManager, true, true);
- }
-
- @Test
- public void gesturesManagement_optionNotChangedInternal() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- when(mapboxMap.getGesturesManager()).thenReturn(internalGesturesManager);
- LocationCameraController camera = buildCamera(mapboxMap, initialGesturesManager, internalGesturesManager);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.trackingGesturesManagement()).thenReturn(true);
- camera.initializeOptions(options);
-
- verify(mapboxMap, times(0)).setGesturesManager(internalGesturesManager, true, true);
- }
-
- @Test
- public void onMove_notCancellingTransitionWhileNone() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- LocationCameraController camera = buildCamera(mapboxMap);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(NONE);
- camera.onMoveListener.onMove(moveGestureDetector);
- verify(mapboxMap, times(0)).cancelTransitions();
- verify(moveGestureDetector, times(0)).interrupt();
-
- // testing subsequent calls
- camera.onMoveListener.onMove(moveGestureDetector);
- verify(mapboxMap, times(0)).cancelTransitions();
- verify(moveGestureDetector, times(0)).interrupt();
- }
-
- @Test
- public void onMove_cancellingTransitionWhileGps() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- LocationCameraController camera = buildCamera(mapboxMap);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(TRACKING);
- camera.onMoveListener.onMove(moveGestureDetector);
- verify(mapboxMap, times(1)).cancelTransitions();
- verify(moveGestureDetector, times(1)).interrupt();
-
- // testing subsequent calls
- camera.onMoveListener.onMove(moveGestureDetector);
- verify(mapboxMap, times(1)).cancelTransitions();
- verify(moveGestureDetector, times(1)).interrupt();
- }
-
- @Test
- public void onMove_cancellingTransitionWhileBearing() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- LocationCameraController camera = buildCamera(mapboxMap);
- camera.initializeOptions(mock(LocationComponentOptions.class));
-
- camera.setCameraMode(NONE_COMPASS);
- camera.onMoveListener.onMove(moveGestureDetector);
- verify(mapboxMap, times(1)).cancelTransitions();
- verify(moveGestureDetector, times(1)).interrupt();
-
- // testing subsequent calls
- camera.onMoveListener.onMove(moveGestureDetector);
- verify(mapboxMap, times(1)).cancelTransitions();
- verify(moveGestureDetector, times(1)).interrupt();
- }
-
- @Test
- public void transition_locationIsNull() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
-
- camera.setCameraMode(TRACKING, null, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
- Assert.assertEquals(TRACKING, camera.getCameraMode());
- verify(listener).onLocationCameraTransitionFinished(TRACKING);
- verify(transform, times(0))
- .animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_notTracking() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
-
- camera.setCameraMode(NONE, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
- verify(listener, times(1)).onLocationCameraTransitionFinished(NONE);
- verify(transform, times(0))
- .animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_trackingChanged() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
-
- doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- listener.onLocationCameraTransitionFinished(TRACKING);
- return null;
- }
- }).when(transform).animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
-
- camera.setCameraMode(TRACKING, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
- verify(listener).onLocationCameraTransitionFinished(TRACKING);
- verify(transform)
- .animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_trackingNotChanged() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
-
- camera.setCameraMode(TRACKING, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
-
- doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- listener.onLocationCameraTransitionFinished(TRACKING_GPS_NORTH);
- return null;
- }
- }).when(transform).animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
-
- camera.setCameraMode(TRACKING_GPS_NORTH, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
- verify(listener, times(1)).onLocationCameraTransitionFinished(TRACKING_GPS_NORTH);
- verify(transform, times(1))
- .animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_canceled() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
-
- doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- listener.onLocationCameraTransitionCanceled(TRACKING);
- return null;
- }
- }).when(transform).animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
-
- camera.setCameraMode(TRACKING, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
- verify(listener).onLocationCameraTransitionCanceled(TRACKING);
- verify(transform)
- .animateCamera(eq(mapboxMap), any(CameraUpdate.class), any(Integer.class),
- any(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_mapboxCallbackFinished() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
- when(location.getLatitude()).thenReturn(1.0);
- when(location.getLongitude()).thenReturn(1.0);
- when(location.getBearing()).thenReturn(30f);
- when(location.getAltitude()).thenReturn(0.0);
-
- ArgumentCaptor<MapboxMap.CancelableCallback> callbackCaptor
- = ArgumentCaptor.forClass(MapboxMap.CancelableCallback.class);
-
- camera.setCameraMode(TRACKING, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
-
- CameraPosition.Builder builder = new CameraPosition.Builder().target(new LatLng(location));
- verify(transform).animateCamera(
- eq(mapboxMap),
- eq(CameraUpdateFactory.newCameraPosition(builder.build())),
- eq((int) TRANSITION_ANIMATION_DURATION_MS),
- callbackCaptor.capture());
-
- Assert.assertTrue(camera.isTransitioning());
-
- callbackCaptor.getValue().onFinish();
-
- Assert.assertFalse(camera.isTransitioning());
-
- verify(listener).onLocationCameraTransitionFinished(TRACKING);
- }
-
- @Test
- public void transition_mapboxCallbackFinishedImmediately() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
- when(location.getLatitude()).thenReturn(1.0);
- when(location.getLongitude()).thenReturn(1.0);
- when(location.getBearing()).thenReturn(30f);
- when(location.getAltitude()).thenReturn(0.0);
-
- ArgumentCaptor<MapboxMap.CancelableCallback> callbackCaptor
- = ArgumentCaptor.forClass(MapboxMap.CancelableCallback.class);
-
- camera.setCameraMode(TRACKING, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
-
- CameraPosition.Builder builder = new CameraPosition.Builder().target(new LatLng(location));
- verify(transform).moveCamera(
- eq(mapboxMap),
- eq(CameraUpdateFactory.newCameraPosition(builder.build())),
- callbackCaptor.capture());
-
- Assert.assertTrue(camera.isTransitioning());
-
- callbackCaptor.getValue().onFinish();
-
- Assert.assertFalse(camera.isTransitioning());
-
- verify(listener).onLocationCameraTransitionFinished(TRACKING);
- }
-
- @Test
- public void transition_mapboxCallbackCanceled() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
- when(location.getLatitude()).thenReturn(1.0);
- when(location.getLongitude()).thenReturn(1.0);
- when(location.getBearing()).thenReturn(30f);
- when(location.getAltitude()).thenReturn(0.0);
-
- ArgumentCaptor<MapboxMap.CancelableCallback> callbackCaptor
- = ArgumentCaptor.forClass(MapboxMap.CancelableCallback.class);
-
- camera.setCameraMode(TRACKING, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
-
- CameraPosition.Builder builder = new CameraPosition.Builder().target(new LatLng(location));
- verify(transform).animateCamera(
- eq(mapboxMap),
- eq(CameraUpdateFactory.newCameraPosition(builder.build())),
- eq((int) TRANSITION_ANIMATION_DURATION_MS),
- callbackCaptor.capture());
-
- Assert.assertTrue(camera.isTransitioning());
-
- callbackCaptor.getValue().onCancel();
-
- Assert.assertFalse(camera.isTransitioning());
-
- verify(listener).onLocationCameraTransitionCanceled(TRACKING);
- }
-
- @Test
- public void transition_mapboxAnimateBearing() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
- when(location.getLatitude()).thenReturn(1.0);
- when(location.getLongitude()).thenReturn(1.0);
- when(location.getBearing()).thenReturn(30f);
- when(location.getAltitude()).thenReturn(0.0);
-
- camera.setCameraMode(TRACKING_GPS, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
-
- CameraPosition.Builder builder = new CameraPosition.Builder().target(new LatLng(location)).bearing(30);
- verify(transform).animateCamera(
- eq(mapboxMap),
- eq(CameraUpdateFactory.newCameraPosition(builder.build())),
- eq((int) TRANSITION_ANIMATION_DURATION_MS),
- any(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_mapboxAnimateNorth() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
- when(location.getLatitude()).thenReturn(1.0);
- when(location.getLongitude()).thenReturn(1.0);
- when(location.getBearing()).thenReturn(30f);
- when(location.getAltitude()).thenReturn(0.0);
-
- camera.setCameraMode(TRACKING_GPS_NORTH, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
-
- CameraPosition.Builder builder = new CameraPosition.Builder().target(new LatLng(location)).bearing(0);
- verify(transform).animateCamera(
- eq(mapboxMap),
- eq(CameraUpdateFactory.newCameraPosition(builder.build())),
- eq((int) TRANSITION_ANIMATION_DURATION_MS),
- any(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_animatorValuesDuringTransition() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- final OnLocationCameraTransitionListener listener = mock(OnLocationCameraTransitionListener.class);
- Location location = mock(Location.class);
-
- ArgumentCaptor<MapboxMap.CancelableCallback> callbackCaptor
- = ArgumentCaptor.forClass(MapboxMap.CancelableCallback.class);
-
- camera.setCameraMode(TRACKING_GPS, location, TRANSITION_ANIMATION_DURATION_MS, null, null, null, listener);
-
- verify(transform).animateCamera(
- eq(mapboxMap),
- any(CameraUpdate.class),
- eq((int) TRANSITION_ANIMATION_DURATION_MS),
- callbackCaptor.capture());
-
- LatLng latLng = new LatLng(10, 10);
- getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()).onNewAnimationValue(latLng);
- getAnimationListener(ANIMATOR_CAMERA_GPS_BEARING, camera.getAnimationListeners()).onNewAnimationValue(10f);
- getAnimationListener(ANIMATOR_TILT, camera.getAnimationListeners()).onNewAnimationValue(10f);
- getAnimationListener(ANIMATOR_ZOOM, camera.getAnimationListeners()).onNewAnimationValue(10f);
-
- verify(transform, times(0)).moveCamera(eq(mapboxMap), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
-
- callbackCaptor.getValue().onFinish();
-
- getAnimationListener(ANIMATOR_CAMERA_LATLNG, camera.getAnimationListeners()).onNewAnimationValue(latLng);
- getAnimationListener(ANIMATOR_CAMERA_GPS_BEARING, camera.getAnimationListeners()).onNewAnimationValue(10f);
- getAnimationListener(ANIMATOR_TILT, camera.getAnimationListeners()).onNewAnimationValue(10f);
- getAnimationListener(ANIMATOR_ZOOM, camera.getAnimationListeners()).onNewAnimationValue(10f);
-
- verify(transform, times(4)).moveCamera(eq(mapboxMap), any(CameraUpdate.class),
- nullable(MapboxMap.CancelableCallback.class));
- }
-
- @Test
- public void transition_customAnimation() {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- Transform transform = mock(Transform.class);
- when(mapboxMap.getCameraPosition()).thenReturn(CameraPosition.DEFAULT);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- LocationCameraController camera = buildCamera(mapboxMap, transform);
- camera.initializeOptions(mock(LocationComponentOptions.class));
- Location location = mock(Location.class);
- CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder()
- .target(new LatLng(location))
- .zoom(14.0)
- .bearing(13.0)
- .tilt(45.0)
- .build()
- );
-
- camera.setCameraMode(TRACKING, location, 1200, 14.0, 13.0, 45.0, null);
- verify(transform)
- .animateCamera(eq(mapboxMap), eq(cameraUpdate), eq(1200), any(MapboxMap.CancelableCallback.class));
- }
-
- private LocationCameraController buildCamera(OnCameraTrackingChangedListener onCameraTrackingChangedListener) {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- Transform transform = mock(Transform.class);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- return new LocationCameraController(mapboxMap, transform, moveGestureDetector,
- onCameraTrackingChangedListener, onCameraMoveInvalidateListener, initialGesturesManager, internalGesturesManager);
- }
-
- private LocationCameraController buildCamera(MoveGestureDetector moveGestureDetector) {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- Transform transform = mock(Transform.class);
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- return new LocationCameraController(mapboxMap, transform, moveGestureDetector,
- onCameraTrackingChangedListener, onCameraMoveInvalidateListener, initialGesturesManager, internalGesturesManager);
- }
-
- private LocationCameraController buildCamera(MapboxMap mapboxMap) {
- Transform transform = mock(Transform.class);
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- return new LocationCameraController(mapboxMap, transform, moveGestureDetector,
- onCameraTrackingChangedListener, onCameraMoveInvalidateListener, initialGesturesManager, internalGesturesManager);
- }
-
- private LocationCameraController buildCamera(Transform transform) {
- MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- Projection projection = mock(Projection.class);
- when(mapboxMap.getProjection()).thenReturn(projection);
- when(projection.getMetersPerPixelAtLatitude(any(Double.class))).thenReturn(Double.valueOf(1000));
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- return new LocationCameraController(mapboxMap, transform, moveGestureDetector,
- onCameraTrackingChangedListener, onCameraMoveInvalidateListener, initialGesturesManager, internalGesturesManager);
- }
-
- private LocationCameraController buildCamera(MapboxMap mapboxMap, Transform transform) {
- when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
- AndroidGesturesManager initialGesturesManager = mock(AndroidGesturesManager.class);
- AndroidGesturesManager internalGesturesManager = mock(AndroidGesturesManager.class);
- return new LocationCameraController(mapboxMap, transform, moveGestureDetector,
- onCameraTrackingChangedListener, onCameraMoveInvalidateListener, initialGesturesManager, internalGesturesManager);
- }
-
- private LocationCameraController buildCamera(MapboxMap mapboxMap, AndroidGesturesManager initialGesturesManager,
- AndroidGesturesManager internalGesturesManager) {
- Transform transform = mock(Transform.class);
- MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
- OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
- OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
- return new LocationCameraController(mapboxMap, transform, moveGestureDetector,
- onCameraTrackingChangedListener, onCameraMoveInvalidateListener, initialGesturesManager, internalGesturesManager);
- }
-
- private <T> MapboxAnimator.AnimationsValueChangeListener<T> getAnimationListener(
- @MapboxAnimator.Type int animatorType,
- Set<AnimatorListenerHolder> holders) {
- for (AnimatorListenerHolder holder : holders) {
- @MapboxAnimator.Type int type = holder.getAnimatorType();
- if (type == animatorType) {
- return holder.getListener();
- }
- }
-
- return null;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentActivationOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentActivationOptionsTest.java
deleted file mode 100644
index 2660c819d4..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentActivationOptionsTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.maps.Style;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.mockito.junit.MockitoRule;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LocationComponentActivationOptionsTest {
-
- @Mock
- private Context context;
- @Mock
- private TypedArray array;
- @Mock
- private Resources resources;
- @Mock
- private Style style;
-
- @Rule
- public MockitoRule mockitoRule = MockitoJUnit.rule();
-
- @NonNull
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void setUp() throws Exception {
- when(context.obtainStyledAttributes(R.style.mapbox_LocationComponent, R.styleable.mapbox_LocationComponent))
- .thenReturn(array);
- when(array.getResourceId(R.styleable.mapbox_LocationComponent_mapbox_foregroundDrawable, -1))
- .thenReturn(R.drawable.mapbox_user_icon);
- when(context.getResources()).thenReturn(resources);
- }
-
- @Test
- public void sanity() throws Exception {
- when(style.isFullyLoaded()).thenReturn(true);
-
- LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
- .accuracyAlpha(0.5f)
- .build();
- assertNotNull(locationComponentOptions);
-
- LocationComponentActivationOptions locationComponentActivationOptions =
- LocationComponentActivationOptions.builder(context, style)
- .locationComponentOptions(locationComponentOptions)
- .useDefaultLocationEngine(true)
- .build();
- assertNotNull(locationComponentActivationOptions);
- }
-
- @Test
- public void includingBothStyleResAndComponentOptions_causesExceptionToBeThrown() throws Exception {
-
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("You've provided both a style resource and a LocationComponentOptions"
- + " object to the LocationComponentActivationOptions builder. You can't use both and "
- + "you must choose one of the two to style the LocationComponent.");
-
- LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
- .accuracyAlpha(0.5f)
- .build();
-
- LocationComponentActivationOptions.builder(context, style)
- .locationComponentOptions(locationComponentOptions)
- .styleRes(R.style.mapbox_LocationComponent)
- .build();
- }
-
- @Test
- public void nullContext_causesExceptionToBeThrown() throws Exception {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage("Context in LocationComponentActivationOptions is null.");
-
- LocationComponentActivationOptions.builder(null, style)
- .build();
- }
-
- @Test
- public void nullStyle_causesExceptionToBeThrown() throws Exception {
- thrown.expect(NullPointerException.class);
- thrown.expectMessage("Style in LocationComponentActivationOptions is null. Make sure the Style object isn't null."
- + " Wait for the map to fully load before passing the Style object to LocationComponentActivationOptions.");
-
- LocationComponentActivationOptions.builder(context, null)
- .build();
- }
-
- @Test
- public void locationComponent_exceptionThrownWithDefaultLocationEngineButNotFullyLoadedStyle() throws Exception {
-
- when(style.isFullyLoaded()).thenReturn(false);
-
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Style in LocationComponentActivationOptions isn't fully loaded. Wait for the "
- + "map to fully load before passing the Style object to "
- + "LocationComponentActivationOptions.");
-
- LocationComponentActivationOptions.builder(context, style)
- .build();
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java
deleted file mode 100644
index b1e1f14cb1..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentOptionsTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-
-import android.support.annotation.NonNull;
-import com.mapbox.mapboxsdk.R;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class LocationComponentOptionsTest {
-
- @Mock
- private Context context;
- @Mock
- private TypedArray array;
- @Mock
- private Resources resources;
-
- @NonNull
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void setUp() throws Exception {
- when(context.obtainStyledAttributes(R.style.mapbox_LocationComponent, R.styleable.mapbox_LocationComponent))
- .thenReturn(array);
- when(array.getResourceId(R.styleable.mapbox_LocationComponent_mapbox_foregroundDrawable, -1))
- .thenReturn(R.drawable.mapbox_user_icon);
- when(context.getResources()).thenReturn(resources);
- }
-
- @Test
- public void sanity() throws Exception {
- LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
- .accuracyAlpha(0.5f)
- .build();
- assertNotNull(locationComponentOptions);
- }
-
- @Test
- public void passingOutOfRangeAccuracyAlpha_throwsException() throws Exception {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Accuracy alpha value must be between 0.0 and "
- + "1.0.");
- LocationComponentOptions.builder(context)
- .accuracyAlpha(2f)
- .build();
- }
-
- @Test
- public void negativeElevation_causesExceptionToBeThrown() throws Exception {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Invalid shadow size -500.0. Must be >= 0");
- LocationComponentOptions.builder(context)
- .elevation(-500)
- .build();
- }
-
- @Test
- public void passingBothLayerPositionOptions_throwsException() throws Exception {
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("You cannot set both layerAbove and layerBelow options."
- + "Choose one or the other.");
- LocationComponentOptions.builder(context)
- .layerAbove("above")
- .layerBelow("below")
- .build();
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentPositionManagerTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentPositionManagerTest.kt
deleted file mode 100644
index c8a75b6701..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentPositionManagerTest.kt
+++ /dev/null
@@ -1,130 +0,0 @@
-package com.mapbox.mapboxsdk.location
-
-import com.mapbox.mapboxsdk.maps.Style
-import com.mapbox.mapboxsdk.style.layers.Layer
-import io.mockk.mockk
-import io.mockk.verify
-import junit.framework.Assert.assertFalse
-import junit.framework.Assert.assertTrue
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.junit.MockitoJUnitRunner
-
-@RunWith(MockitoJUnitRunner::class)
-class LocationComponentPositionManagerTest {
-
- private lateinit var style: Style
- private lateinit var layer: Layer
-
- @Before
- fun setup() {
- style = mockk(relaxed = true)
- layer = mockk(relaxed = true)
- }
-
- @Test
- fun update_noChange_null() {
- val positionManager = LocationComponentPositionManager(style, null, null)
- val requiresUpdate = positionManager.update(null, null)
- assertFalse(requiresUpdate)
- }
-
- @Test
- fun update_noChange_above() {
- val positionManager = LocationComponentPositionManager(style, "above", null)
- val requiresUpdate = positionManager.update("above", null)
- assertFalse(requiresUpdate)
- }
-
- @Test
- fun update_noChange_below() {
- val positionManager = LocationComponentPositionManager(style, null, "below")
- val requiresUpdate = positionManager.update(null, "below")
- assertFalse(requiresUpdate)
- }
-
- @Test
- fun update_fromNull_above() {
- val positionManager = LocationComponentPositionManager(style, null, null)
- val requiresUpdate = positionManager.update("above", null)
- assertTrue(requiresUpdate)
- }
-
- @Test
- fun update_fromNull_below() {
- val positionManager = LocationComponentPositionManager(style, null, null)
- val requiresUpdate = positionManager.update(null, "below")
- assertTrue(requiresUpdate)
- }
-
- @Test
- fun update_toNull_above() {
- val positionManager = LocationComponentPositionManager(style, "above", null)
- val requiresUpdate = positionManager.update(null, null)
- assertTrue(requiresUpdate)
- }
-
- @Test
- fun update_toNull_below() {
- val positionManager = LocationComponentPositionManager(style, null, "below")
- val requiresUpdate = positionManager.update(null, null)
- assertTrue(requiresUpdate)
- }
-
- @Test
- fun update_fromValue_above() {
- val positionManager = LocationComponentPositionManager(style, "above1", null)
- val requiresUpdate = positionManager.update("above2", null)
- assertTrue(requiresUpdate)
- }
-
- @Test
- fun update_fromValue_below() {
- val positionManager = LocationComponentPositionManager(style, null, "below1")
- val requiresUpdate = positionManager.update(null, "below2")
- assertTrue(requiresUpdate)
- }
-
- @Test
- fun addLayer_noModifier() {
- val positionManager = LocationComponentPositionManager(style, null, null)
- positionManager.addLayerToMap(layer)
-
- verify { style.addLayer(layer) }
- }
-
- @Test
- fun addLayer_above() {
- val positionManager = LocationComponentPositionManager(style, "above", null)
- positionManager.addLayerToMap(layer)
-
- verify { style.addLayerAbove(layer, "above") }
- }
-
- @Test
- fun addLayer_below() {
- val positionManager = LocationComponentPositionManager(style, null, "below")
- positionManager.addLayerToMap(layer)
-
- verify { style.addLayerBelow(layer, "below") }
- }
-
- @Test
- fun addLayer_afterUpdate_above() {
- val positionManager = LocationComponentPositionManager(style, null, null)
- positionManager.update("above", null)
- positionManager.addLayerToMap(layer)
-
- verify { style.addLayerAbove(layer, "above") }
- }
-
- @Test
- fun addLayer_afterUpdate_below() {
- val positionManager = LocationComponentPositionManager(style, null, null)
- positionManager.update(null, "below")
- positionManager.addLayerToMap(layer)
-
- verify { style.addLayerBelow(layer, "below") }
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
deleted file mode 100644
index 2994c29d5b..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
+++ /dev/null
@@ -1,453 +0,0 @@
-package com.mapbox.mapboxsdk.location
-
-import android.content.Context
-import android.content.res.Resources
-import android.content.res.TypedArray
-import android.location.Location
-import android.os.Looper
-import com.mapbox.android.core.location.LocationEngine
-import com.mapbox.android.core.location.LocationEngineRequest
-import com.mapbox.mapboxsdk.R
-import com.mapbox.mapboxsdk.camera.CameraPosition
-import com.mapbox.mapboxsdk.location.LocationComponentConstants.TRANSITION_ANIMATION_DURATION_MS
-import com.mapbox.mapboxsdk.location.modes.CameraMode
-import com.mapbox.mapboxsdk.location.modes.RenderMode
-import com.mapbox.mapboxsdk.maps.MapboxMap
-import com.mapbox.mapboxsdk.maps.Style
-import com.mapbox.mapboxsdk.maps.Transform
-import org.junit.Assert
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.ArgumentCaptor
-import org.mockito.Mock
-import org.mockito.Mockito.*
-import org.mockito.MockitoAnnotations
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class LocationComponentTest {
- private lateinit var locationComponent: LocationComponent
-
- @Mock
- private lateinit var locationComponentOptions: LocationComponentOptions
-
- @Mock
- private lateinit var mapboxMap: MapboxMap
-
- @Mock
- private lateinit var transform: Transform
-
- @Mock
- private lateinit var context: Context
-
- @Mock
- private lateinit var locationEngine: LocationEngine
-
- @Mock
- private lateinit var locationEngineRequest: LocationEngineRequest
-
- @Mock
- private lateinit var currentListener: LocationComponent.CurrentLocationEngineCallback
-
- @Mock
- private lateinit var lastListener: LocationComponent.LastLocationEngineCallback
-
- @Mock
- private lateinit var compassEngine: CompassEngine
-
- @Mock
- private lateinit var locationLayerController: LocationLayerController
-
- @Mock
- private lateinit var locationCameraController: LocationCameraController
-
- @Mock
- private lateinit var locationAnimatorCoordinator: LocationAnimatorCoordinator
-
- @Mock
- private lateinit var staleStateManager: StaleStateManager
-
- @Mock
- private lateinit var locationEngineProvider: LocationComponent.InternalLocationEngineProvider
-
- @Mock
- private lateinit var style: Style
-
- private lateinit var developerAnimationListeners: List<MapboxMap.OnDeveloperAnimationListener>
-
- @Before
- fun before() {
- MockitoAnnotations.initMocks(this)
- developerAnimationListeners = mutableListOf()
- locationComponent = LocationComponent(mapboxMap, transform, developerAnimationListeners, currentListener, lastListener, locationLayerController, locationCameraController, locationAnimatorCoordinator, staleStateManager, compassEngine, locationEngineProvider)
- doReturn(locationEngine).`when`(locationEngineProvider).getBestLocationEngine(context, false)
- doReturn(style).`when`(mapboxMap).style
- }
-
- @Test
- fun activateWithRequestTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
-
- Assert.assertEquals(locationEngineRequest, locationComponent.locationEngineRequest)
-
- doReturn(mock(TypedArray::class.java)).`when`(context)
- .obtainStyledAttributes(R.style.mapbox_LocationComponent, R.styleable.mapbox_LocationComponent)
-
- val resources = mock(Resources::class.java)
-
- doReturn(resources).`when`(context).resources
- doReturn(0f).`when`(resources)
- .getDimension(R.dimen.mapbox_locationComponentTrackingMultiFingerMoveThreshold)
- doReturn(0f).`when`(resources)
- .getDimension(R.dimen.mapbox_locationComponentTrackingMultiFingerMoveThreshold)
- locationComponent.activateLocationComponent(context, mock(Style::class.java), true, locationEngineRequest)
- Assert.assertEquals(locationEngineRequest, locationComponent.locationEngineRequest)
- }
-
- @Test
- fun activateWithDefaultLocationEngineRequestAndOptionsTestDefaultLocationEngine() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), true, locationEngineRequest, locationComponentOptions)
- Assert.assertEquals(locationEngineRequest, locationComponent.locationEngineRequest)
- Assert.assertNotNull(locationComponent.locationEngine)
- }
-
- @Test
- fun activateWithDefaultLocationEngineRequestAndOptionsTestCustomLocationEngine() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), false, locationEngineRequest, locationComponentOptions)
- Assert.assertEquals(locationEngineRequest, locationComponent.locationEngineRequest)
- Assert.assertNull(locationComponent.locationEngine)
- }
-
- @Test
- fun locationUpdatesWhenEnabledDisableTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- verify(locationEngine, times(0)).removeLocationUpdates(currentListener)
- verify(locationEngine, times(0)).requestLocationUpdates(eq(locationEngineRequest), eq(currentListener), any(Looper::class.java))
-
- locationComponent.onStart()
- verify(locationEngine, times(0)).removeLocationUpdates(currentListener)
- verify(locationEngine, times(0)).requestLocationUpdates(eq(locationEngineRequest), eq(currentListener), any(Looper::class.java))
-
- locationComponent.isLocationComponentEnabled = true
- verify(locationEngine).requestLocationUpdates(eq(locationEngineRequest), eq(currentListener), any(Looper::class.java))
-
- locationComponent.isLocationComponentEnabled = false
- verify(locationEngine).requestLocationUpdates(eq(locationEngineRequest), eq(currentListener), any(Looper::class.java))
- verify(locationEngine).removeLocationUpdates(currentListener)
- }
-
- @Test
- fun locationUpdatesWhenStartedStoppedTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
-
- locationComponent.onStop()
- verify(locationEngine).removeLocationUpdates(currentListener)
-
- locationComponent.onStart()
- verify(locationEngine, times(2)).requestLocationUpdates(eq(locationEngineRequest), eq(currentListener), any(Looper::class.java))
- }
-
- @Test
- fun locationUpdatesWhenNewRequestTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
-
- val newRequest = mock(LocationEngineRequest::class.java)
- locationComponent.locationEngineRequest = newRequest
- verify(locationEngine).removeLocationUpdates(currentListener)
- verify(locationEngine).requestLocationUpdates(eq(newRequest), eq(currentListener), any(Looper::class.java))
- }
-
- @Test
- fun lastLocationUpdateOnStartTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
-
- verify(locationEngine).getLastLocation(lastListener)
- }
-
- @Test
- fun transitionCallbackFinishedTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- val listener = mock(OnLocationCameraTransitionListener::class.java)
-
- val callback = ArgumentCaptor.forClass(OnLocationCameraTransitionListener::class.java)
- locationComponent.setCameraMode(CameraMode.TRACKING, listener)
- verify(locationCameraController).setCameraMode(eq(CameraMode.TRACKING), any(), eq(TRANSITION_ANIMATION_DURATION_MS), isNull(), isNull(), isNull(), callback.capture())
- callback.value.onLocationCameraTransitionFinished(CameraMode.TRACKING)
-
- verify(listener).onLocationCameraTransitionFinished(CameraMode.TRACKING)
- verify(locationAnimatorCoordinator).resetAllCameraAnimations(CameraPosition.DEFAULT, false)
- }
-
- @Test
- fun transitionCallbackCanceledTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- val listener = mock(OnLocationCameraTransitionListener::class.java)
-
- val callback = ArgumentCaptor.forClass(OnLocationCameraTransitionListener::class.java)
- locationComponent.setCameraMode(CameraMode.TRACKING, listener)
- verify(locationCameraController).setCameraMode(eq(CameraMode.TRACKING), any(), eq(TRANSITION_ANIMATION_DURATION_MS), isNull(), isNull(), isNull(), callback.capture())
- callback.value.onLocationCameraTransitionCanceled(CameraMode.TRACKING)
-
- verify(listener).onLocationCameraTransitionCanceled(CameraMode.TRACKING)
- verify(locationAnimatorCoordinator).resetAllCameraAnimations(CameraPosition.DEFAULT, false)
- }
-
- @Test
- fun transitionCustomFinishedTest() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- val listener = mock(OnLocationCameraTransitionListener::class.java)
-
- val callback = ArgumentCaptor.forClass(OnLocationCameraTransitionListener::class.java)
- locationComponent.setCameraMode(CameraMode.TRACKING, 1200, 14.0, 13.0, 45.0, listener)
- verify(locationCameraController).setCameraMode(eq(CameraMode.TRACKING), any(), eq(1200L), eq(14.0), eq(13.0), eq(45.0), callback.capture())
- callback.value.onLocationCameraTransitionFinished(CameraMode.TRACKING)
-
- verify(listener).onLocationCameraTransitionFinished(CameraMode.TRACKING)
- verify(locationAnimatorCoordinator).resetAllCameraAnimations(CameraPosition.DEFAULT, false)
- }
-
- @Test
- fun compass_listenWhenConsumedByNoneCamera() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationCameraController.isConsumingCompass).thenReturn(true)
- locationComponent.cameraMode = CameraMode.NONE_COMPASS
- verify(compassEngine).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_listenWhenConsumedByTrackingCamera() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationCameraController.isConsumingCompass).thenReturn(true)
- locationComponent.cameraMode = CameraMode.TRACKING_COMPASS
- verify(compassEngine).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_listenWhenConsumedByLayer() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- verify(compassEngine).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_notListenWhenNotConsumed() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(false)
- `when`(locationCameraController.isConsumingCompass).thenReturn(false)
- locationComponent.renderMode = RenderMode.GPS
- locationComponent.renderMode = RenderMode.NORMAL
- locationComponent.cameraMode = CameraMode.TRACKING
- locationComponent.cameraMode = CameraMode.NONE
- locationComponent.cameraMode = CameraMode.NONE_GPS
- locationComponent.cameraMode = CameraMode.TRACKING_GPS
- locationComponent.cameraMode = CameraMode.TRACKING_GPS_NORTH
- verify(compassEngine, never()).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_removeListenerOnChange() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- `when`(locationLayerController.isConsumingCompass).thenReturn(false)
- locationComponent.renderMode = RenderMode.NORMAL
- verify(compassEngine).removeCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_removeListenerOnStop() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- locationComponent.onStop()
- verify(compassEngine).removeCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_reAddListenerOnStart() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- locationComponent.onStop()
- locationComponent.onStart()
- verify(compassEngine, times(2)).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_removeListenerOnStyleStartLoad() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- locationComponent.onStartLoadingMap()
- verify(compassEngine).removeCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_reAddListenerOnStyleLoadFinished() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- locationComponent.onStartLoadingMap()
- locationComponent.onFinishLoadingStyle()
- verify(compassEngine, times(2)).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_reAddListenerOnlyWhenEnabled() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- locationComponent.isLocationComponentEnabled = false
-
- locationComponent.onStartLoadingMap()
- locationComponent.onFinishLoadingStyle()
- verify(compassEngine).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_notAdListenerWhenDisabled() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.onStart()
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- verify(compassEngine, never()).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun compass_notAdListenerWhenStopped() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.isLocationComponentEnabled = true
- `when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
-
- `when`(locationLayerController.isConsumingCompass).thenReturn(true)
- locationComponent.renderMode = RenderMode.COMPASS
- verify(compassEngine, never()).addCompassListener(any(CompassListener::class.java))
- }
-
- @Test
- fun developerAnimationCalled() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.isLocationComponentEnabled = true
- for (listener in developerAnimationListeners) {
- listener.onDeveloperAnimationStarted()
- }
- verify(locationCameraController).setCameraMode(eq(CameraMode.NONE), isNull<Location>(), eq(TRANSITION_ANIMATION_DURATION_MS), isNull<Double>(), isNull<Double>(), isNull<Double>(), any())
- }
-
- @Test
- fun internal_cameraTrackingChangedListener_onCameraTrackingDismissed() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.isLocationComponentEnabled = true
-
- val cameraChangeListener: OnCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener::class.java)
- locationComponent.addOnCameraTrackingChangedListener(cameraChangeListener)
-
- locationComponent.cameraTrackingChangedListener.onCameraTrackingDismissed()
-
- verify(cameraChangeListener).onCameraTrackingDismissed()
- }
-
- @Test
- fun internal_cameraTrackingChangedListener_onCameraTrackingChanged() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.isLocationComponentEnabled = true
-
- val cameraValueListener: AnimatorListenerHolder = mock(AnimatorListenerHolder::class.java)
- val layerValueListener: AnimatorListenerHolder = mock(AnimatorListenerHolder::class.java)
- `when`(locationCameraController.animationListeners).thenReturn(setOf(cameraValueListener))
- `when`(locationLayerController.animationListeners).thenReturn(setOf(layerValueListener))
- val cameraChangeListener: OnCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener::class.java)
- locationComponent.addOnCameraTrackingChangedListener(cameraChangeListener)
-
- locationComponent.cameraTrackingChangedListener.onCameraTrackingChanged(CameraMode.TRACKING_GPS)
-
- verify(locationAnimatorCoordinator).cancelZoomAnimation()
- verify(locationAnimatorCoordinator).cancelTiltAnimation()
- verify(locationAnimatorCoordinator).updateAnimatorListenerHolders(eq(setOf(cameraValueListener, layerValueListener)))
- verify(locationAnimatorCoordinator).resetAllCameraAnimations(any(), anyBoolean())
- verify(locationAnimatorCoordinator).resetAllLayerAnimations()
- verify(cameraChangeListener).onCameraTrackingChanged(CameraMode.TRACKING_GPS)
- }
-
- @Test
- fun internal_renderModeChangedListener_onRenderModeChanged() {
- locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
- locationComponent.isLocationComponentEnabled = true
-
- val cameraListener: AnimatorListenerHolder = mock(AnimatorListenerHolder::class.java)
- val layerListener: AnimatorListenerHolder = mock(AnimatorListenerHolder::class.java)
- `when`(locationCameraController.animationListeners).thenReturn(setOf(cameraListener))
- `when`(locationLayerController.animationListeners).thenReturn(setOf(layerListener))
- val renderChangeListener: OnRenderModeChangedListener = mock(OnRenderModeChangedListener::class.java)
- locationComponent.addOnRenderModeChangedListener(renderChangeListener)
-
- locationComponent.renderModeChangedListener.onRenderModeChanged(RenderMode.NORMAL)
-
- verify(locationAnimatorCoordinator).updateAnimatorListenerHolders(eq(setOf(cameraListener, layerListener)))
- verify(locationAnimatorCoordinator).resetAllCameraAnimations(any(), anyBoolean())
- verify(locationAnimatorCoordinator).resetAllLayerAnimations()
- verify(renderChangeListener).onRenderModeChanged(RenderMode.NORMAL)
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
deleted file mode 100644
index ed2d015d85..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
+++ /dev/null
@@ -1,718 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-import android.graphics.Bitmap;
-import android.support.annotation.NonNull;
-
-import com.google.gson.JsonElement;
-import com.mapbox.geojson.Feature;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.location.modes.RenderMode;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.Style;
-import com.mapbox.mapboxsdk.style.layers.Layer;
-import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import java.util.Set;
-
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_LAYER;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_ICON;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_LAYER;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_STALE_ICON;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_ICON;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_LAYER;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_ICON;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_LAYER;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_STALE_ICON;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.LOCATION_SOURCE;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_RADIUS;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_SHADOW_ICON_OFFSET;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
-import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_LAYER;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_ACCURACY;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_COMPASS_BEARING;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_GPS_BEARING;
-import static com.mapbox.mapboxsdk.location.MapboxAnimator.ANIMATOR_LAYER_LATLNG;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class LocationLayerControllerTest {
-
- private MapboxMap mapboxMap = mock(MapboxMap.class);
- private Style style = mock(Style.class);
-
- @Before
- public void before() {
- when(mapboxMap.getStyle()).thenReturn(style);
- }
-
- @Test
- public void onInitialization_locationSourceIsAdded() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addSource(locationSource);
- }
-
- @Test
- public void onInitialization_shadowLayerIsAdded() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- Layer shadowLayer = mock(Layer.class);
- when(sourceProvider.generateLayer(SHADOW_LAYER)).thenReturn(shadowLayer);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addLayerBelow(shadowLayer, BACKGROUND_LAYER);
- }
-
- @Test
- public void onInitialization_backgroundLayerIsAdded() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- Layer backgroundLayer = mock(Layer.class);
- when(sourceProvider.generateLayer(BACKGROUND_LAYER)).thenReturn(backgroundLayer);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addLayerBelow(backgroundLayer, FOREGROUND_LAYER);
- }
-
- @Test
- public void onInitialization_foregroundLayerIsAdded() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- Layer foregroundLayer = mock(Layer.class);
- when(sourceProvider.generateLayer(FOREGROUND_LAYER)).thenReturn(foregroundLayer);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addLayerBelow(foregroundLayer, BEARING_LAYER);
- }
-
- @Test
- public void onInitialization_bearingLayerIsAdded() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- Layer bearingLayer = mock(Layer.class);
- when(sourceProvider.generateLayer(BEARING_LAYER)).thenReturn(bearingLayer);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- String layerBelow = "layer-below";
- when(options.layerBelow()).thenReturn(layerBelow);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addLayerBelow(bearingLayer, layerBelow);
- }
-
- @Test
- public void onInitialization_accuracyLayerIsAdded() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- Layer accuracyLayer = mock(Layer.class);
- when(sourceProvider.generateAccuracyLayer()).thenReturn(accuracyLayer);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addLayerBelow(accuracyLayer, BACKGROUND_LAYER);
- }
-
- @Test
- public void onInitialization_numberOfCachedLayerIdsIsConstant() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- LocationLayerController controller =
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- controller.initializeComponents(mapboxMap.getStyle(), options);
-
- assertEquals(5, controller.layerSet.size());
- }
-
- @Test
- public void applyStyle_styleShadowWithValidElevation() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.elevation()).thenReturn(2f);
-
- // Style is applied on initialization
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addImage(SHADOW_ICON, bitmap);
- }
-
- @Test
- public void applyStyle_ignoreStyleShadowWithInvalidElevation() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- when(options.elevation()).thenReturn(0f);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style, times(0)).addImage(SHADOW_ICON, bitmap);
- }
-
- @Test
- public void applyStyle_styleForegroundFromOptions() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- int drawableResId = 123;
- int tintColor = 456;
- when(options.foregroundDrawable()).thenReturn(drawableResId);
- when(options.foregroundTintColor()).thenReturn(tintColor);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addImage(FOREGROUND_ICON, bitmap);
- }
-
- @Test
- public void applyStyle_styleForegroundStaleFromOptions() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- int drawableResId = 123;
- int tintColor = 456;
- when(options.foregroundDrawableStale()).thenReturn(drawableResId);
- when(options.foregroundStaleTintColor()).thenReturn(tintColor);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addImage(FOREGROUND_STALE_ICON, bitmap);
- }
-
- @Test
- public void applyStyle_styleBackgroundFromOptions() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- int drawableResId = 123;
- int tintColor = 456;
- when(options.backgroundDrawable()).thenReturn(drawableResId);
- when(options.backgroundTintColor()).thenReturn(tintColor);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addImage(BACKGROUND_ICON, bitmap);
- }
-
- @Test
- public void applyStyle_styleBackgroundStaleFromOptions() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- int drawableResId = 123;
- int tintColor = 456;
- when(options.backgroundDrawableStale()).thenReturn(drawableResId);
- when(options.backgroundStaleTintColor()).thenReturn(tintColor);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addImage(BACKGROUND_STALE_ICON, bitmap);
- }
-
- @Test
- public void applyStyle_styleBearingFromOptions() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- int drawableResId = 123;
- int tintColor = 456;
- when(options.bearingDrawable()).thenReturn(drawableResId);
- when(options.bearingTintColor()).thenReturn(tintColor);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
-
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addImage(BEARING_ICON, bitmap);
- }
-
- @Test
- public void applyStyle_layerBelowChanged() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
-
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
-
- LocationLayerController layerController =
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- Layer bearingLayer2 = mock(Layer.class);
- when(sourceProvider.generateLayer(BEARING_LAYER)).thenReturn(bearingLayer2);
- Layer foregroundLayer2 = mock(Layer.class);
- when(sourceProvider.generateLayer(FOREGROUND_LAYER)).thenReturn(foregroundLayer2);
- Layer backgroundLayer2 = mock(Layer.class);
- when(sourceProvider.generateLayer(BACKGROUND_LAYER)).thenReturn(backgroundLayer2);
- Layer shadowLayer2 = mock(Layer.class);
- when(sourceProvider.generateLayer(SHADOW_LAYER)).thenReturn(shadowLayer2);
- Layer accuracyLayer2 = mock(Layer.class);
- when(sourceProvider.generateAccuracyLayer()).thenReturn(accuracyLayer2);
- String layerBelow = "layer-below";
- when(options.layerBelow()).thenReturn(layerBelow);
-
- layerController.applyStyle(options);
-
- verify(style).removeLayer(BEARING_LAYER);
- verify(style).removeLayer(FOREGROUND_LAYER);
- verify(style).removeLayer(BACKGROUND_LAYER);
- verify(style).removeLayer(SHADOW_LAYER);
- verify(style).removeLayer(ACCURACY_LAYER);
-
- verify(style).addLayerBelow(bearingLayer2, layerBelow);
- verify(style).addLayerBelow(foregroundLayer2, BEARING_LAYER);
- verify(style).addLayerBelow(backgroundLayer2, FOREGROUND_LAYER);
- verify(style).addLayerBelow(shadowLayer2, BACKGROUND_LAYER);
- verify(style).addLayerBelow(accuracyLayer2, BACKGROUND_LAYER);
- }
-
- @Test
- public void applyStyle_layerBelowNotChanged() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
-
- String layerBelow = "layer-below";
- when(options.layerBelow()).thenReturn(layerBelow);
-
- LocationLayerController layerController =
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- options = mock(LocationComponentOptions.class);
- layerBelow = "layer-below";
- when(options.layerBelow()).thenReturn(layerBelow);
- layerController.applyStyle(options);
-
- verify(style, times(0)).removeLayer(any(String.class));
- verify(style, times(5)).addLayerBelow(any(Layer.class), any(String.class));
- }
-
- @Test
- public void applyStyle_layerBelowNotChangedNull() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
-
- LocationLayerController layerController =
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- options = mock(LocationComponentOptions.class);
- layerController.applyStyle(options);
-
- verify(style, times(0)).removeLayer(any(String.class));
- verify(style, times(1)).addLayer(any(Layer.class));
- verify(style, times(4)).addLayerBelow(any(Layer.class), Mockito.<String>any());
- }
-
- @Test
- public void updateForegroundOffset_foregroundIconPropertyIsUpdated() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
-
- layer.updateForegroundOffset(2d);
-
- verify(locationFeature).addProperty(eq(PROPERTY_FOREGROUND_ICON_OFFSET), any(JsonElement.class));
- }
-
- @Test
- public void updateForegroundOffset_shadowPropertyIsUpdated() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
- layer.updateForegroundOffset(2d);
-
- verify(locationFeature).addProperty(eq(PROPERTY_SHADOW_ICON_OFFSET), any(JsonElement.class));
- }
-
- @Test
- public void onNewLatLngValue_locationFeatureIsUpdated() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(style.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
-
- getAnimationListener(ANIMATOR_LAYER_LATLNG, layer.getAnimationListeners()).onNewAnimationValue(new LatLng());
-
- // wanted twice (once for initialization)
- verify(locationSource, times(2)).setGeoJson(locationFeature);
- }
-
- @Test
- public void onNewGpsBearingValue_locationFeatureIsUpdated() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(style.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
- layer.setRenderMode(RenderMode.GPS);
- float gpsBearing = 2f;
-
- getAnimationListener(ANIMATOR_LAYER_GPS_BEARING, layer.getAnimationListeners()).onNewAnimationValue(gpsBearing);
-
- verify(locationFeature).addNumberProperty(PROPERTY_GPS_BEARING, gpsBearing);
- }
-
- @Test
- public void onNewGpsBearingValue_updateIgnoredWithInvalidRenderMode() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(style.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
- layer.setRenderMode(RenderMode.COMPASS);
- float gpsBearing = 2f;
-
- assertNull(getAnimationListener(ANIMATOR_LAYER_GPS_BEARING, layer.getAnimationListeners()));
- verify(locationFeature, times(0)).addNumberProperty(PROPERTY_GPS_BEARING, gpsBearing);
- }
-
- @Test
- public void onNewCompassBearingValue_locationFeatureIsUpdated() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(style.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
- layer.setRenderMode(RenderMode.COMPASS);
- float compassBearing = 2f;
-
- getAnimationListener(ANIMATOR_LAYER_COMPASS_BEARING, layer.getAnimationListeners())
- .onNewAnimationValue(compassBearing);
-
- verify(locationFeature).addNumberProperty(PROPERTY_COMPASS_BEARING, compassBearing);
- }
-
- @Test
- public void onNewCompassBearingValue_updateIgnoredWithInvalidRenderMode() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(style.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
- layer.setRenderMode(RenderMode.GPS);
- float compassBearing = 2f;
-
- assertNull(getAnimationListener(ANIMATOR_LAYER_COMPASS_BEARING, layer.getAnimationListeners()));
- verify(locationFeature, times(0)).addNumberProperty(PROPERTY_COMPASS_BEARING, compassBearing);
- }
-
- @Test
- public void onNewAccuracyRadiusValue_locationFeatureIsUpdated() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(style.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
- layer.setRenderMode(RenderMode.NORMAL);
- float accuracyRadiusValue = 2f;
-
- getAnimationListener(ANIMATOR_LAYER_ACCURACY, layer.getAnimationListeners())
- .onNewAnimationValue(accuracyRadiusValue);
-
- verify(locationFeature).addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracyRadiusValue);
- }
-
- @Test
- public void onNewAccuracyRadiusValue_updateIgnoredWithInvalidRenderMode() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(style.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- Feature locationFeature = mock(Feature.class);
- LocationLayerController layer = new LocationLayerController(
- mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
- bitmapProvider, options, internalRenderModeChangedListener
- );
- layer.setRenderMode(RenderMode.GPS);
- float accuracyRadiusValue = 2f;
-
- assertNull(getAnimationListener(ANIMATOR_LAYER_ACCURACY, layer.getAnimationListeners()));
- verify(locationFeature, times(0))
- .addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracyRadiusValue);
- }
-
- @Test
- public void renderModeChanged_doNotNotifyAboutDuplicates_NORMAL() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- LocationLayerController controller =
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- controller.setRenderMode(RenderMode.NORMAL);
- controller.setRenderMode(RenderMode.NORMAL);
-
- verify(internalRenderModeChangedListener, times(1)).onRenderModeChanged(RenderMode.NORMAL);
- }
-
- @Test
- public void renderModeChanged_doNotNotifyAboutDuplicates_GPS() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- GeoJsonSource locationSource = mock(GeoJsonSource.class);
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- LocationComponentOptions options = mock(LocationComponentOptions.class);
-
- LocationLayerController controller =
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- controller.setRenderMode(RenderMode.GPS);
- controller.setRenderMode(RenderMode.GPS);
-
- verify(internalRenderModeChangedListener, times(1)).onRenderModeChanged(RenderMode.GPS);
- }
-
- @Test
- public void layerHidden_renderModeChanged_layerShown_foregroundIconUpdated() {
- OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class);
- LayerSourceProvider sourceProvider = buildLayerProvider();
- when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
- LocationComponentOptions options = mock(LocationComponentOptions.class);
- int drawableResId = 123;
- int tintColor = 456;
- when(options.foregroundDrawable()).thenReturn(drawableResId);
- when(options.foregroundTintColor()).thenReturn(tintColor);
- LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
- Bitmap bitmap = mock(Bitmap.class);
- when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
-
- LocationLayerController controller =
- new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
- bitmapProvider, options, internalRenderModeChangedListener);
-
- verify(style).addImage(FOREGROUND_ICON, bitmap);
-
- int drawableGpsResId = 789;
- when(options.gpsDrawable()).thenReturn(drawableGpsResId);
-
- Bitmap bitmapGps = mock(Bitmap.class);
- when(bitmapProvider.generateBitmap(drawableGpsResId, tintColor)).thenReturn(bitmapGps);
-
- controller.hide();
-
- controller.setRenderMode(RenderMode.GPS);
-
- controller.show();
-
- verify(style).addImage(FOREGROUND_ICON, bitmapGps);
- }
-
- private LayerFeatureProvider buildFeatureProvider(@NonNull LocationComponentOptions options) {
- LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
- when(provider.generateLocationFeature(null, options)).thenReturn(mock(Feature.class));
- return provider;
- }
-
- private LayerFeatureProvider buildFeatureProvider(Feature feature, @NonNull LocationComponentOptions options) {
- LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
- when(provider.generateLocationFeature(null, options)).thenReturn(feature);
- return provider;
- }
-
- private LayerSourceProvider buildLayerProvider() {
- LayerSourceProvider layerSourceProvider = mock(LayerSourceProvider.class);
-
- Layer shadowLayer = mock(Layer.class);
- when(shadowLayer.getId()).thenReturn(SHADOW_LAYER);
- when(layerSourceProvider.generateLayer(SHADOW_LAYER)).thenReturn(shadowLayer);
-
- Layer backgroundLayer = mock(Layer.class);
- when(backgroundLayer.getId()).thenReturn(BACKGROUND_LAYER);
- when(layerSourceProvider.generateLayer(BACKGROUND_LAYER)).thenReturn(backgroundLayer);
-
- Layer foregroundLayer = mock(Layer.class);
- when(foregroundLayer.getId()).thenReturn(FOREGROUND_LAYER);
- when(layerSourceProvider.generateLayer(FOREGROUND_LAYER)).thenReturn(foregroundLayer);
-
- Layer bearingLayer = mock(Layer.class);
- when(bearingLayer.getId()).thenReturn(BEARING_LAYER);
- when(layerSourceProvider.generateLayer(BEARING_LAYER)).thenReturn(bearingLayer);
-
- Layer accuracyLayer = mock(Layer.class);
- when(accuracyLayer.getId()).thenReturn(ACCURACY_LAYER);
- when(layerSourceProvider.generateAccuracyLayer()).thenReturn(accuracyLayer);
- return layerSourceProvider;
- }
-
- private <T> MapboxAnimator.AnimationsValueChangeListener<T> getAnimationListener(
- @MapboxAnimator.Type int animatorType,
- Set<AnimatorListenerHolder> holders) {
- for (AnimatorListenerHolder holder : holders) {
- @MapboxAnimator.Type int type = holder.getAnimatorType();
- if (type == animatorType) {
- return holder.getListener();
- }
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt
deleted file mode 100644
index 7c126c7832..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/MapboxAnimatorTest.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.mapbox.mapboxsdk.location
-
-import android.animation.ValueAnimator
-import io.mockk.every
-import io.mockk.mockk
-import io.mockk.verify
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class MapboxAnimatorTest {
-
- @Test
- fun fps_unlimited() {
- val valueAnimator = mockk<ValueAnimator>()
- every { valueAnimator.animatedValue } answers { 5f }
- val listener = mockk<MapboxAnimator.AnimationsValueChangeListener<Float>>()
- every { listener.onNewAnimationValue(any()) } answers {}
- val mapboxAnimator = MapboxFloatAnimator(0f, 10f, listener, Int.MAX_VALUE)
-
- for (i in 0 until 5)
- mapboxAnimator.onAnimationUpdate(valueAnimator)
-
- verify(exactly = 5) { listener.onNewAnimationValue(5f) }
- }
-
- @Test
- fun fps_limited() {
- val valueAnimator = mockk<ValueAnimator>()
- every { valueAnimator.animatedValue } answers { 5f }
- val listener = mockk<MapboxAnimator.AnimationsValueChangeListener<Float>>()
- every { listener.onNewAnimationValue(any()) } answers {}
- val mapboxAnimator = MapboxFloatAnimator(0f, 10f, listener, 5)
-
- for (i in 0 until 5) {
- mapboxAnimator.onAnimationUpdate(valueAnimator)
- Thread.sleep(150)
- }
-
- verify(exactly = 3) { listener.onNewAnimationValue(5f) }
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/UtilsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/UtilsTest.java
deleted file mode 100644
index bf5ee40f4a..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/UtilsTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.mapbox.mapboxsdk.location;
-
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-
-public final class UtilsTest {
-
- @Test
- public void shortestRotation_doesReturnValueDistanceQuickestToZero() throws Exception {
- float value = Utils.shortestRotation(0, 181);
- assertEquals(360f, value);
- value = Utils.shortestRotation(0, 179);
- assertEquals(0f, value);
- value = Utils.shortestRotation(0, 180);
- assertEquals(0f, value);
- }
-
- @Test
- public void shortestRotation_doesReturnValueDistanceQuickestToFifty() throws Exception {
- float value = Utils.shortestRotation(50, 231);
- assertEquals(410f, value);
- value = Utils.shortestRotation(50, 229);
- assertEquals(50f, value);
- value = Utils.shortestRotation(50, 180);
- assertEquals(50f, value);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt
deleted file mode 100644
index 82e1c67f67..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/log/LoggerTest.kt
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.mapbox.mapboxsdk.log
-
-import io.mockk.mockk
-import io.mockk.verify
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class LoggerTest {
-
- private val logger: LoggerDefinition = mockk(relaxed = true)
-
- @Before
- fun setUp() {
- Logger.setLoggerDefinition(logger)
- }
-
- @Test
- fun verbosityLogLevel() {
- Logger.setVerbosity(Logger.VERBOSE)
- Logger.v(TAG, MESSAGE)
- verify { logger.v(TAG, MESSAGE) }
- }
-
- @Test
- fun verbosityLogLevelIgnore() {
- Logger.setVerbosity(Logger.DEBUG)
- Logger.v(TAG, MESSAGE)
- verify(exactly = 0) { logger.v(TAG, MESSAGE) }
- }
-
- @Test
- fun debugLogLevel() {
- Logger.setVerbosity(Logger.VERBOSE)
- Logger.d(TAG, MESSAGE)
- verify { logger.d(TAG, MESSAGE) }
- }
-
- @Test
- fun debugLogLevelIgnore() {
- Logger.setVerbosity(Logger.WARN)
- Logger.d(TAG, MESSAGE)
- verify(exactly = 0) { logger.d(TAG, MESSAGE) }
- }
-
- @Test
- fun warnLogLevel() {
- Logger.setVerbosity(Logger.WARN)
- Logger.w(TAG, MESSAGE)
- verify { logger.w(TAG, MESSAGE) }
- }
-
- @Test
- fun warnLogLevelIgnore() {
- Logger.setVerbosity(Logger.ERROR)
- Logger.w(TAG, MESSAGE)
- verify(exactly = 0) { logger.w(TAG, MESSAGE) }
- }
-
- @Test
- fun errorLogLevel() {
- Logger.setVerbosity(Logger.ERROR)
- Logger.e(TAG, MESSAGE)
- verify { logger.e(TAG, MESSAGE) }
- }
-
- @Test
- fun errorLogLevelIgnore() {
- Logger.setVerbosity(Logger.NONE)
- Logger.e(TAG, MESSAGE)
- verify(exactly = 0) { logger.e(TAG, MESSAGE) }
- }
-
- @Test
- fun noneLogLevelIgnore() {
- Logger.setVerbosity(Logger.NONE)
- Logger.v(TAG, MESSAGE)
- Logger.d(TAG, MESSAGE)
- Logger.w(TAG, MESSAGE)
- Logger.e(TAG, MESSAGE)
- verify(exactly = 0) { logger.v(TAG, MESSAGE) }
- verify(exactly = 0) { logger.d(TAG, MESSAGE) }
- verify(exactly = 0) { logger.w(TAG, MESSAGE) }
- verify(exactly = 0) { logger.e(TAG, MESSAGE) }
- }
-
- companion object {
- const val TAG: String = "TAG"
- const val MESSAGE: String = "message"
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java
deleted file mode 100644
index fd59f52a55..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AnnotationManagerTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.support.v4.util.LongSparseArray;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
-import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.annotations.MarkerOptions;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import org.junit.Test;
-import org.mockito.ArgumentMatchers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AnnotationManagerTest {
-
- @Test
- public void checksAddAMarker() throws Exception {
- NativeMap aNativeMapView = mock(NativeMapView.class);
- MapView aMapView = mock(MapView.class);
- LongSparseArray<Annotation> annotationsArray = new LongSparseArray<>();
- IconManager aIconManager = mock(IconManager.class);
- Annotations annotations = new AnnotationContainer(aNativeMapView, annotationsArray);
- Markers markers = new MarkerContainer(aNativeMapView, annotationsArray, aIconManager);
- Polygons polygons = new PolygonContainer(aNativeMapView, annotationsArray);
- Polylines polylines = new PolylineContainer(aNativeMapView, annotationsArray);
- ShapeAnnotations shapeAnnotations = new ShapeAnnotationContainer(aNativeMapView, annotationsArray);
- AnnotationManager annotationManager = new AnnotationManager(aMapView, annotationsArray,
- aIconManager, annotations, markers, polygons, polylines, shapeAnnotations);
- Marker aMarker = mock(Marker.class);
- long aId = 5L;
- when(aNativeMapView.addMarker(aMarker)).thenReturn(aId);
- BaseMarkerOptions aMarkerOptions = mock(BaseMarkerOptions.class);
- MapboxMap aMapboxMap = mock(MapboxMap.class);
- when(aMarkerOptions.getMarker()).thenReturn(aMarker);
-
- annotationManager.addMarker(aMarkerOptions, aMapboxMap);
-
- assertEquals(aMarker, annotationManager.getAnnotations().get(0));
- assertEquals(aMarker, annotationManager.getAnnotation(aId));
- }
-
- @Test
- public void checksAddMarkers() throws Exception {
- NativeMapView aNativeMapView = mock(NativeMapView.class);
- MapView aMapView = mock(MapView.class);
- LongSparseArray<Annotation> annotationsArray = new LongSparseArray<>();
- IconManager aIconManager = mock(IconManager.class);
- Annotations annotations = new AnnotationContainer(aNativeMapView, annotationsArray);
- Markers markers = new MarkerContainer(aNativeMapView, annotationsArray, aIconManager);
- Polygons polygons = new PolygonContainer(aNativeMapView, annotationsArray);
- Polylines polylines = new PolylineContainer(aNativeMapView, annotationsArray);
- ShapeAnnotations shapeAnnotations = new ShapeAnnotationContainer(aNativeMapView, annotationsArray);
- AnnotationManager annotationManager = new AnnotationManager(aMapView, annotationsArray,
- aIconManager, annotations, markers, polygons, polylines, shapeAnnotations);
-
- long firstId = 1L;
- long secondId = 2L;
- List<BaseMarkerOptions> markerList = new ArrayList<>();
- MarkerOptions firstMarkerOption = new MarkerOptions().position(new LatLng()).title("first");
- MarkerOptions secondMarkerOption = new MarkerOptions().position(new LatLng()).title("second");
-
- markerList.add(firstMarkerOption);
- markerList.add(secondMarkerOption);
- MapboxMap aMapboxMap = mock(MapboxMap.class);
- when(aNativeMapView.addMarker(any(Marker.class))).thenReturn(firstId, secondId);
-
- when(aNativeMapView.addMarkers(ArgumentMatchers.<Marker>anyList()))
- .thenReturn(new long[] {firstId, secondId});
-
- annotationManager.addMarkers(markerList, aMapboxMap);
-
- assertEquals(2, annotationManager.getAnnotations().size());
- assertEquals("first", ((Marker) annotationManager.getAnnotations().get(0)).getTitle());
- assertEquals("second", ((Marker) annotationManager.getAnnotations().get(1)).getTitle());
- assertEquals("first", ((Marker) annotationManager.getAnnotation(firstId)).getTitle());
- assertEquals("second", ((Marker) annotationManager.getAnnotation(secondId)).getTitle());
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AttributionDialogManagerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AttributionDialogManagerTest.java
deleted file mode 100644
index 9b4eeb27aa..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/AttributionDialogManagerTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.content.Context;
-
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.robolectric.RobolectricTestRunner;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(RobolectricTestRunner.class)
-public class AttributionDialogManagerTest {
- @InjectMocks
- Context context = mock(Context.class);
-
- @InjectMocks
- MapboxMap mapboxMap = mock(MapboxMap.class);
-
- @InjectMocks
- Style style = mock(Style.class);
-
- private AttributionDialogManager attributionDialogManager;
- private CameraPosition cameraPosition;
-
- private static final String ASSERT_MAPBOX_TOKEN = "TestAccessToken";
-
- private static final String ASSERT_MAPBOX_STYLE_URI = "mapbox://styles/mapbox/streets-v11";
- private static final String ASSERT_MAPBOX_LOCAL_STYLE_URI = "asset://style.json";
-
- private static final String ASSERT_MAPBOX_PACKAGE_NAME = "com.mapbox.attributionmanagertest";
-
- private static final String ASSERT_MAPBOX_FEEDBACK_FINAL_URL =
- "https://apps.mapbox.com/feedback?referrer=com.mapbox.attributionmanagertest&"
- + "access_token=TestAccessToken&owner=mapbox&id=streets-v11"
- + "#/22.200001/11.100000/12.000000/24.000000/5";
- private static final String ASSERT_MAPBOX_FEEDHACK_FINAL_URL_LOCAL_STYLE =
- "https://apps.mapbox.com/feedback?referrer=com.mapbox.attributionmanagertest&"
- + "access_token=TestAccessToken#/22.200001/11.100000/12.000000/24.000000/5";
- private static final String ASSERT_MAPBOX_FEEDBACL_FINAL_URL_NULL_CAMERA_POSITION =
- "https://apps.mapbox.com/feedback?referrer=com.mapbox.attributionmanagertest&access_token=TestAccessToken";
-
- @Before
- public void beforeTest() {
- attributionDialogManager = new AttributionDialogManager(context, mapboxMap);
- cameraPosition = new CameraPosition.Builder(CameraPosition.DEFAULT)
- .tilt(5.0f).zoom(12).bearing(24.0f).target(new LatLng(11.1f, 22.2f)).build();
- }
-
- @Test
- public void testSanity() {
- assertNotNull("AttributionDialogManager should not be null", attributionDialogManager);
- }
-
- @Test
- public void testBuildMapFeedbackMapUrl() {
- when(context.getApplicationContext()).thenReturn(context);
- when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME);
- when(style.getUri()).thenReturn(ASSERT_MAPBOX_STYLE_URI);
- when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
- when(mapboxMap.getStyle()).thenReturn(style);
-
- Assert.assertEquals(ASSERT_MAPBOX_FEEDBACK_FINAL_URL,
- attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN));
- }
-
- @Test
- public void testBuildMapFeedbackMapUrlWithLocalStyleJson() {
- when(context.getApplicationContext()).thenReturn(context);
- when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME);
- when(style.getUri()).thenReturn(ASSERT_MAPBOX_LOCAL_STYLE_URI);
- when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
- when(mapboxMap.getStyle()).thenReturn(style);
-
- Assert.assertEquals(ASSERT_MAPBOX_FEEDHACK_FINAL_URL_LOCAL_STYLE,
- attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN));
- }
-
- @Test
- public void testBuildMapFeedbackMapUrlWithNullCameraPosition() {
- when(context.getApplicationContext()).thenReturn(context);
- when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME);
- when(style.getUri()).thenReturn(ASSERT_MAPBOX_LOCAL_STYLE_URI);
- when(mapboxMap.getCameraPosition()).thenReturn(null);
- when(mapboxMap.getStyle()).thenReturn(style);
-
- Assert.assertEquals(ASSERT_MAPBOX_FEEDBACL_FINAL_URL_NULL_CAMERA_POSITION,
- attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN));
- }
-
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapChangeReceiverTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapChangeReceiverTest.java
deleted file mode 100644
index 025f06752c..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapChangeReceiverTest.java
+++ /dev/null
@@ -1,586 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import com.google.common.util.concurrent.ExecutionError;
-import com.mapbox.mapboxsdk.log.Logger;
-import com.mapbox.mapboxsdk.log.LoggerDefinition;
-
-import junit.framework.Assert;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.verify;
-
-/**
- * Tests integration of MapChangeDispatcher and see if events are correctly forwarded.
- */
-public class MapChangeReceiverTest {
-
- private static final String TEST_STRING = "mapChangeRandom";
-
- private MapChangeReceiver mapChangeEventManager;
-
- @Mock
- private MapView.OnCameraWillChangeListener onCameraWillChangeListener;
-
- @Mock
- private MapView.OnCameraDidChangeListener onCameraDidChangeListener;
-
- @Mock
- private MapView.OnCameraIsChangingListener onCameraIsChangingListener;
-
- @Mock
- private MapView.OnWillStartLoadingMapListener onWillStartLoadingMapListener;
-
- @Mock
- private MapView.OnDidFinishLoadingMapListener onDidFinishLoadingMapListener;
-
- @Mock
- private MapView.OnDidFailLoadingMapListener onDidFailLoadingMapListener;
-
- @Mock
- private MapView.OnWillStartRenderingFrameListener onWillStartRenderingFrameListener;
-
- @Mock
- private MapView.OnDidFinishRenderingFrameListener onDidFinishRenderingFrameListener;
-
- @Mock
- private MapView.OnWillStartRenderingMapListener onWillStartRenderingMapListener;
-
- @Mock
- private MapView.OnDidFinishRenderingMapListener onDidFinishRenderingMapListener;
-
- @Mock
- private MapView.OnDidBecomeIdleListener onDidBecomeIdleListener;
-
- @Mock
- private MapView.OnDidFinishLoadingStyleListener onDidFinishLoadingStyleListener;
-
- @Mock
- private MapView.OnSourceChangedListener onSourceChangedListener;
-
- @Mock
- private LoggerDefinition loggerDefinition;
-
- @Before
- public void beforeTest() {
- MockitoAnnotations.initMocks(this);
- mapChangeEventManager = new MapChangeReceiver();
- }
-
- @Test
- public void testOnCameraRegionWillChangeListener() {
- mapChangeEventManager.addOnCameraWillChangeListener(onCameraWillChangeListener);
- mapChangeEventManager.onCameraWillChange(false);
- verify(onCameraWillChangeListener).onCameraWillChange(false);
-
- mapChangeEventManager.removeOnCameraWillChangeListener(onCameraWillChangeListener);
- mapChangeEventManager.onCameraWillChange(false);
- verify(onCameraWillChangeListener).onCameraWillChange(false);
-
- mapChangeEventManager.addOnCameraWillChangeListener(onCameraWillChangeListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onCameraWillChangeListener).onCameraWillChange(false);
- try {
- mapChangeEventManager.onCameraWillChange(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onCameraWillChangeListener).onCameraWillChange(false);
- try {
- mapChangeEventManager.onCameraWillChange(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnCameraRegionWillChangeAnimatedListener() {
- mapChangeEventManager.addOnCameraWillChangeListener(onCameraWillChangeListener);
- mapChangeEventManager.onCameraWillChange(true);
- verify(onCameraWillChangeListener).onCameraWillChange(true);
- mapChangeEventManager.removeOnCameraWillChangeListener(onCameraWillChangeListener);
- mapChangeEventManager.onCameraWillChange(true);
- verify(onCameraWillChangeListener).onCameraWillChange(true);
-
- mapChangeEventManager.addOnCameraWillChangeListener(onCameraWillChangeListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onCameraWillChangeListener).onCameraWillChange(true);
- try {
- mapChangeEventManager.onCameraWillChange(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onCameraWillChangeListener).onCameraWillChange(true);
- try {
- mapChangeEventManager.onCameraWillChange(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnCameraIsChangingListener() {
- mapChangeEventManager.addOnCameraIsChangingListener(onCameraIsChangingListener);
- mapChangeEventManager.onCameraIsChanging();
- verify(onCameraIsChangingListener).onCameraIsChanging();
- mapChangeEventManager.removeOnCameraIsChangingListener(onCameraIsChangingListener);
- mapChangeEventManager.onCameraIsChanging();
- verify(onCameraIsChangingListener).onCameraIsChanging();
-
- mapChangeEventManager.addOnCameraIsChangingListener(onCameraIsChangingListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onCameraIsChangingListener).onCameraIsChanging();
- try {
- mapChangeEventManager.onCameraIsChanging();
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onCameraIsChangingListener).onCameraIsChanging();
- try {
- mapChangeEventManager.onCameraIsChanging();
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnCameraRegionDidChangeListener() {
- mapChangeEventManager.addOnCameraDidChangeListener(onCameraDidChangeListener);
- mapChangeEventManager.onCameraDidChange(false);
- verify(onCameraDidChangeListener).onCameraDidChange(false);
- mapChangeEventManager.removeOnCameraDidChangeListener(onCameraDidChangeListener);
- mapChangeEventManager.onCameraDidChange(false);
- verify(onCameraDidChangeListener).onCameraDidChange(false);
-
- mapChangeEventManager.addOnCameraDidChangeListener(onCameraDidChangeListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onCameraDidChangeListener).onCameraDidChange(false);
- try {
- mapChangeEventManager.onCameraDidChange(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onCameraDidChangeListener).onCameraDidChange(false);
- try {
- mapChangeEventManager.onCameraDidChange(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnCameraRegionDidChangeAnimatedListener() {
- mapChangeEventManager.addOnCameraDidChangeListener(onCameraDidChangeListener);
- mapChangeEventManager.onCameraDidChange(true);
- verify(onCameraDidChangeListener).onCameraDidChange(true);
- mapChangeEventManager.removeOnCameraDidChangeListener(onCameraDidChangeListener);
- mapChangeEventManager.onCameraDidChange(true);
- verify(onCameraDidChangeListener).onCameraDidChange(true);
-
- mapChangeEventManager.addOnCameraDidChangeListener(onCameraDidChangeListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onCameraDidChangeListener).onCameraDidChange(true);
- try {
- mapChangeEventManager.onCameraDidChange(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onCameraDidChangeListener).onCameraDidChange(true);
- try {
- mapChangeEventManager.onCameraDidChange(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnWillStartLoadingMapListener() {
- mapChangeEventManager.addOnWillStartLoadingMapListener(onWillStartLoadingMapListener);
- mapChangeEventManager.onWillStartLoadingMap();
- verify(onWillStartLoadingMapListener).onWillStartLoadingMap();
- mapChangeEventManager.removeOnWillStartLoadingMapListener(onWillStartLoadingMapListener);
- mapChangeEventManager.onWillStartLoadingMap();
- verify(onWillStartLoadingMapListener).onWillStartLoadingMap();
-
- mapChangeEventManager.addOnWillStartLoadingMapListener(onWillStartLoadingMapListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onWillStartLoadingMapListener).onWillStartLoadingMap();
- try {
- mapChangeEventManager.onWillStartLoadingMap();
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onWillStartLoadingMapListener).onWillStartLoadingMap();
- try {
- mapChangeEventManager.onWillStartLoadingMap();
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidFinishLoadingMapListener() {
- mapChangeEventManager.addOnDidFinishLoadingMapListener(onDidFinishLoadingMapListener);
- mapChangeEventManager.onDidFinishLoadingMap();
- verify(onDidFinishLoadingMapListener).onDidFinishLoadingMap();
- mapChangeEventManager.removeOnDidFinishLoadingMapListener(onDidFinishLoadingMapListener);
- mapChangeEventManager.onDidFinishLoadingMap();
- verify(onDidFinishLoadingMapListener).onDidFinishLoadingMap();
-
- mapChangeEventManager.addOnDidFinishLoadingMapListener(onDidFinishLoadingMapListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidFinishLoadingMapListener).onDidFinishLoadingMap();
- try {
- mapChangeEventManager.onDidFinishLoadingMap();
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidFinishLoadingMapListener).onDidFinishLoadingMap();
- try {
- mapChangeEventManager.onDidFinishLoadingMap();
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidFailLoadingMapListener() {
- mapChangeEventManager.addOnDidFailLoadingMapListener(onDidFailLoadingMapListener);
- mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
- verify(onDidFailLoadingMapListener).onDidFailLoadingMap(TEST_STRING);
- mapChangeEventManager.removeOnDidFailLoadingMapListener(onDidFailLoadingMapListener);
- mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
- verify(onDidFailLoadingMapListener).onDidFailLoadingMap(TEST_STRING);
-
- mapChangeEventManager.addOnDidFailLoadingMapListener(onDidFailLoadingMapListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidFailLoadingMapListener).onDidFailLoadingMap(TEST_STRING);
- try {
- mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidFailLoadingMapListener).onDidFailLoadingMap(TEST_STRING);
- try {
- mapChangeEventManager.onDidFailLoadingMap(TEST_STRING);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnWillStartRenderingFrameListener() {
- mapChangeEventManager.addOnWillStartRenderingFrameListener(onWillStartRenderingFrameListener);
- mapChangeEventManager.onWillStartRenderingFrame();
- verify(onWillStartRenderingFrameListener).onWillStartRenderingFrame();
- mapChangeEventManager.removeOnWillStartRenderingFrameListener(onWillStartRenderingFrameListener);
- mapChangeEventManager.onWillStartRenderingFrame();
- verify(onWillStartRenderingFrameListener).onWillStartRenderingFrame();
-
- mapChangeEventManager.addOnWillStartRenderingFrameListener(onWillStartRenderingFrameListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onWillStartRenderingFrameListener).onWillStartRenderingFrame();
- try {
- mapChangeEventManager.onWillStartRenderingFrame();
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onWillStartRenderingFrameListener).onWillStartRenderingFrame();
- try {
- mapChangeEventManager.onWillStartRenderingFrame();
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidFinishRenderingFrameListener() {
- mapChangeEventManager.addOnDidFinishRenderingFrameListener(onDidFinishRenderingFrameListener);
- mapChangeEventManager.onDidFinishRenderingFrame(true);
- verify(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(true);
- mapChangeEventManager.removeOnDidFinishRenderingFrameListener(onDidFinishRenderingFrameListener);
- mapChangeEventManager.onDidFinishRenderingFrame(true);
- verify(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(true);
-
- mapChangeEventManager.addOnDidFinishRenderingFrameListener(onDidFinishRenderingFrameListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(true);
- try {
- mapChangeEventManager.onDidFinishRenderingFrame(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(true);
- try {
- mapChangeEventManager.onDidFinishRenderingFrame(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidFinishRenderingFrameFullyRenderedListener() {
- mapChangeEventManager.addOnDidFinishRenderingFrameListener(onDidFinishRenderingFrameListener);
- mapChangeEventManager.onDidFinishRenderingFrame(false);
- verify(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(false);
- mapChangeEventManager.removeOnDidFinishRenderingFrameListener(onDidFinishRenderingFrameListener);
- mapChangeEventManager.onDidFinishRenderingFrame(false);
- verify(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(false);
-
- mapChangeEventManager.addOnDidFinishRenderingFrameListener(onDidFinishRenderingFrameListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(false);
- try {
- mapChangeEventManager.onDidFinishRenderingFrame(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidFinishRenderingFrameListener).onDidFinishRenderingFrame(false);
- try {
- mapChangeEventManager.onDidFinishRenderingFrame(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnWillStartRenderingMapListener() {
- mapChangeEventManager.addOnWillStartRenderingMapListener(onWillStartRenderingMapListener);
- mapChangeEventManager.onWillStartRenderingMap();
- verify(onWillStartRenderingMapListener).onWillStartRenderingMap();
- mapChangeEventManager.removeOnWillStartRenderingMapListener(onWillStartRenderingMapListener);
- mapChangeEventManager.onWillStartRenderingMap();
- verify(onWillStartRenderingMapListener).onWillStartRenderingMap();
-
- mapChangeEventManager.addOnWillStartRenderingMapListener(onWillStartRenderingMapListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onWillStartRenderingMapListener).onWillStartRenderingMap();
- try {
- mapChangeEventManager.onWillStartRenderingMap();
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onWillStartRenderingMapListener).onWillStartRenderingMap();
- try {
- mapChangeEventManager.onWillStartRenderingMap();
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidFinishRenderingMapListener() {
- mapChangeEventManager.addOnDidFinishRenderingMapListener(onDidFinishRenderingMapListener);
- mapChangeEventManager.onDidFinishRenderingMap(true);
- verify(onDidFinishRenderingMapListener).onDidFinishRenderingMap(true);
- mapChangeEventManager.removeOnDidFinishRenderingMapListener(onDidFinishRenderingMapListener);
- mapChangeEventManager.onDidFinishRenderingMap(true);
- verify(onDidFinishRenderingMapListener).onDidFinishRenderingMap(true);
-
- mapChangeEventManager.addOnDidFinishRenderingMapListener(onDidFinishRenderingMapListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidFinishRenderingMapListener).onDidFinishRenderingMap(true);
- try {
- mapChangeEventManager.onDidFinishRenderingMap(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidFinishRenderingMapListener).onDidFinishRenderingMap(true);
- try {
- mapChangeEventManager.onDidFinishRenderingMap(true);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidFinishRenderingMapFullyRenderedListener() {
- mapChangeEventManager.addOnDidFinishRenderingMapListener(onDidFinishRenderingMapListener);
- mapChangeEventManager.onDidFinishRenderingMap(false);
- verify(onDidFinishRenderingMapListener).onDidFinishRenderingMap(false);
- mapChangeEventManager.removeOnDidFinishRenderingMapListener(onDidFinishRenderingMapListener);
- mapChangeEventManager.onDidFinishRenderingMap(false);
- verify(onDidFinishRenderingMapListener).onDidFinishRenderingMap(false);
-
- mapChangeEventManager.addOnDidFinishRenderingMapListener(onDidFinishRenderingMapListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidFinishRenderingMapListener).onDidFinishRenderingMap(false);
- try {
- mapChangeEventManager.onDidFinishRenderingMap(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidFinishRenderingMapListener).onDidFinishRenderingMap(false);
- try {
- mapChangeEventManager.onDidFinishRenderingMap(false);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidBecomeIdleListener() {
- mapChangeEventManager.addOnDidBecomeIdleListener(onDidBecomeIdleListener);
- mapChangeEventManager.onDidBecomeIdle();
- verify(onDidBecomeIdleListener).onDidBecomeIdle();
- mapChangeEventManager.removeOnDidBecomeIdleListener(onDidBecomeIdleListener);
- mapChangeEventManager.onDidBecomeIdle();
- verify(onDidBecomeIdleListener).onDidBecomeIdle();
-
- mapChangeEventManager.addOnDidBecomeIdleListener(onDidBecomeIdleListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidBecomeIdleListener).onDidBecomeIdle();
- try {
- mapChangeEventManager.onDidBecomeIdle();
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidBecomeIdleListener).onDidBecomeIdle();
- try {
- mapChangeEventManager.onDidBecomeIdle();
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnDidFinishLoadingStyleListener() {
- mapChangeEventManager.addOnDidFinishLoadingStyleListener(onDidFinishLoadingStyleListener);
- mapChangeEventManager.onDidFinishLoadingStyle();
- verify(onDidFinishLoadingStyleListener).onDidFinishLoadingStyle();
- mapChangeEventManager.removeOnDidFinishLoadingStyleListener(onDidFinishLoadingStyleListener);
- mapChangeEventManager.onDidFinishLoadingStyle();
- verify(onDidFinishLoadingStyleListener).onDidFinishLoadingStyle();
-
- mapChangeEventManager.addOnDidFinishLoadingStyleListener(onDidFinishLoadingStyleListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onDidFinishLoadingStyleListener).onDidFinishLoadingStyle();
- try {
- mapChangeEventManager.onDidFinishLoadingStyle();
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onDidFinishLoadingStyleListener).onDidFinishLoadingStyle();
- try {
- mapChangeEventManager.onDidFinishLoadingStyle();
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-
- @Test
- public void testOnSourceChangedListener() {
- mapChangeEventManager.addOnSourceChangedListener(onSourceChangedListener);
- mapChangeEventManager.onSourceChanged(TEST_STRING);
- verify(onSourceChangedListener).onSourceChangedListener(TEST_STRING);
- mapChangeEventManager.removeOnSourceChangedListener(onSourceChangedListener);
- mapChangeEventManager.onSourceChanged(TEST_STRING);
- verify(onSourceChangedListener).onSourceChangedListener(TEST_STRING);
-
- mapChangeEventManager.addOnSourceChangedListener(onSourceChangedListener);
- Logger.setLoggerDefinition(loggerDefinition);
- Exception exc = new RuntimeException();
- doThrow(exc).when(onSourceChangedListener).onSourceChangedListener(TEST_STRING);
- try {
- mapChangeEventManager.onSourceChanged(TEST_STRING);
- Assert.fail("The exception should've been re-thrown.");
- } catch (RuntimeException throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(exc));
- }
-
- Error err = new ExecutionError("", new Error());
- doThrow(err).when(onSourceChangedListener).onSourceChangedListener(TEST_STRING);
- try {
- mapChangeEventManager.onSourceChanged(TEST_STRING);
- Assert.fail("The exception should've been re-thrown.");
- } catch (ExecutionError throwable) {
- verify(loggerDefinition).e(anyString(), anyString(), eq(err));
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
deleted file mode 100644
index cb097c283d..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.PointF;
-
-import android.support.annotation.Nullable;
-import com.mapbox.android.gestures.MoveGestureDetector;
-import com.mapbox.android.gestures.RotateGestureDetector;
-import com.mapbox.android.gestures.ShoveGestureDetector;
-import com.mapbox.android.gestures.StandardScaleGestureDetector;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class MapTouchListenersTest {
-
- @Nullable
- private MapGestureDetector mapGestureDetector;
- private LatLng latLng;
- private PointF pointF;
-
- @Before
- public void setUp() throws Exception {
- latLng = new LatLng();
- pointF = new PointF();
-
- Projection projection = mock(Projection.class);
- when(projection.fromScreenLocation(pointF)).thenReturn(latLng);
- mapGestureDetector = new MapGestureDetector(null,
- null, projection, null, null, null);
- }
-
- @Test
- public void onMapClickListenerTest() throws Exception {
- MapboxMap.OnMapClickListener listener = mock(MapboxMap.OnMapClickListener.class);
- mapGestureDetector.addOnMapClickListener(listener);
- mapGestureDetector.notifyOnMapClickListeners(pointF);
- verify(listener, times(1)).onMapClick(latLng);
-
- mapGestureDetector.removeOnMapClickListener(listener);
- mapGestureDetector.notifyOnMapClickListeners(pointF);
- verify(listener, times(1)).onMapClick(latLng);
- }
-
- @Test
- public void onMapLongClickListenerTest() throws Exception {
- MapboxMap.OnMapLongClickListener listener = mock(MapboxMap.OnMapLongClickListener.class);
- mapGestureDetector.addOnMapLongClickListener(listener);
- mapGestureDetector.notifyOnMapLongClickListeners(pointF);
- verify(listener, times(1)).onMapLongClick(latLng);
-
- mapGestureDetector.removeOnMapLongClickListener(listener);
- mapGestureDetector.notifyOnMapLongClickListeners(pointF);
- verify(listener, times(1)).onMapLongClick(latLng);
- }
-
- @Test
- public void onFlingListenerTest() throws Exception {
- MapboxMap.OnFlingListener listener = mock(MapboxMap.OnFlingListener.class);
- mapGestureDetector.addOnFlingListener(listener);
- mapGestureDetector.notifyOnFlingListeners();
- verify(listener, times(1)).onFling();
-
- mapGestureDetector.removeOnFlingListener(listener);
- mapGestureDetector.notifyOnFlingListeners();
- verify(listener, times(1)).onFling();
- }
-
- @Test
- public void onMoveListenerTest() throws Exception {
- MapboxMap.OnMoveListener listener = mock(MapboxMap.OnMoveListener.class);
- MoveGestureDetector detector = mock(MoveGestureDetector.class);
- mapGestureDetector.addOnMoveListener(listener);
- mapGestureDetector.notifyOnMoveBeginListeners(detector);
- mapGestureDetector.notifyOnMoveListeners(detector);
- mapGestureDetector.notifyOnMoveEndListeners(detector);
- verify(listener, times(1)).onMoveBegin(detector);
- verify(listener, times(1)).onMove(detector);
- verify(listener, times(1)).onMoveEnd(detector);
-
- mapGestureDetector.removeOnMoveListener(listener);
- mapGestureDetector.notifyOnMoveBeginListeners(detector);
- mapGestureDetector.notifyOnMoveListeners(detector);
- mapGestureDetector.notifyOnMoveEndListeners(detector);
- verify(listener, times(1)).onMoveBegin(detector);
- verify(listener, times(1)).onMove(detector);
- verify(listener, times(1)).onMoveEnd(detector);
- }
-
- @Test
- public void onRotateListenerTest() throws Exception {
- MapboxMap.OnRotateListener listener = mock(MapboxMap.OnRotateListener.class);
- RotateGestureDetector detector = mock(RotateGestureDetector.class);
- mapGestureDetector.addOnRotateListener(listener);
- mapGestureDetector.notifyOnRotateBeginListeners(detector);
- mapGestureDetector.notifyOnRotateListeners(detector);
- mapGestureDetector.notifyOnRotateEndListeners(detector);
- verify(listener, times(1)).onRotateBegin(detector);
- verify(listener, times(1)).onRotate(detector);
- verify(listener, times(1)).onRotateEnd(detector);
-
- mapGestureDetector.removeOnRotateListener(listener);
- mapGestureDetector.notifyOnRotateBeginListeners(detector);
- mapGestureDetector.notifyOnRotateListeners(detector);
- mapGestureDetector.notifyOnRotateEndListeners(detector);
- verify(listener, times(1)).onRotateBegin(detector);
- verify(listener, times(1)).onRotate(detector);
- verify(listener, times(1)).onRotateEnd(detector);
- }
-
- @Test
- public void onScaleListenerTest() throws Exception {
- MapboxMap.OnScaleListener listener = mock(MapboxMap.OnScaleListener.class);
- StandardScaleGestureDetector detector = mock(StandardScaleGestureDetector.class);
- mapGestureDetector.addOnScaleListener(listener);
- mapGestureDetector.notifyOnScaleBeginListeners(detector);
- mapGestureDetector.notifyOnScaleListeners(detector);
- mapGestureDetector.notifyOnScaleEndListeners(detector);
- verify(listener, times(1)).onScaleBegin(detector);
- verify(listener, times(1)).onScale(detector);
- verify(listener, times(1)).onScaleEnd(detector);
-
- mapGestureDetector.removeOnScaleListener(listener);
- mapGestureDetector.notifyOnScaleBeginListeners(detector);
- mapGestureDetector.notifyOnScaleListeners(detector);
- mapGestureDetector.notifyOnScaleEndListeners(detector);
- verify(listener, times(1)).onScaleBegin(detector);
- verify(listener, times(1)).onScale(detector);
- verify(listener, times(1)).onScaleEnd(detector);
- }
-
- @Test
- public void onShoveListenerTest() throws Exception {
- MapboxMap.OnShoveListener listener = mock(MapboxMap.OnShoveListener.class);
- ShoveGestureDetector detector = mock(ShoveGestureDetector.class);
- mapGestureDetector.addShoveListener(listener);
- mapGestureDetector.notifyOnShoveBeginListeners(detector);
- mapGestureDetector.notifyOnShoveListeners(detector);
- mapGestureDetector.notifyOnShoveEndListeners(detector);
- verify(listener, times(1)).onShoveBegin(detector);
- verify(listener, times(1)).onShove(detector);
- verify(listener, times(1)).onShoveEnd(detector);
-
- mapGestureDetector.removeShoveListener(listener);
- mapGestureDetector.notifyOnShoveBeginListeners(detector);
- mapGestureDetector.notifyOnShoveListeners(detector);
- mapGestureDetector.notifyOnShoveEndListeners(detector);
- verify(listener, times(1)).onShoveBegin(detector);
- verify(listener, times(1)).onShove(detector);
- verify(listener, times(1)).onShoveEnd(detector);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsAttrsTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsAttrsTest.kt
deleted file mode 100644
index ee8024257f..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsAttrsTest.kt
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.mapbox.mapboxsdk.maps
-
-import android.content.Context
-import android.content.res.Resources
-import android.content.res.TypedArray
-import com.mapbox.mapboxsdk.R
-import io.mockk.MockKAnnotations
-import io.mockk.every
-import io.mockk.impl.annotations.RelaxedMockK
-import io.mockk.verify
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class MapboxMapOptionsAttrsTest {
-
- @RelaxedMockK
- private lateinit var options: MapboxMapOptions
-
- @RelaxedMockK
- private lateinit var typedArray: TypedArray
-
- @RelaxedMockK
- private lateinit var context: Context
-
- @RelaxedMockK
- private lateinit var resources: Resources
-
- @Before
- fun setUp() {
- MockKAnnotations.init(this)
- every {
- context.resources
- }.returns(resources)
- }
-
- @Test
- fun enabledLocalIdeographFontFamily() {
- mockEnableLocalIdeograph(enabled = true)
-
- val options = MapboxMapOptions.createFromAttributes(options, context, typedArray)
-
- verify(exactly = 1) {
- options.localIdeographFontFamily(any())
- }
- }
-
- @Test
- fun localIdeographFontFamily() {
- mockEnableLocalIdeograph(enabled = true)
-
- val font = "foo"
- mockLocalIdeographString(font)
-
- val options = MapboxMapOptions.createFromAttributes(options, context, typedArray)
-
- verify(exactly = 1) {
- options.localIdeographFontFamily(font)
- }
- }
-
- @Test
- fun localIdeographFontFamilies() {
- mockEnableLocalIdeograph(enabled = true)
-
- val fonts = arrayOf("foo", "bar")
- mockLocalIdeographStringArray(fonts)
-
- val options = MapboxMapOptions.createFromAttributes(options, context, typedArray)
-
- verify(exactly = 1) {
- options.localIdeographFontFamily(*fonts)
- }
- }
-
- private fun mockEnableLocalIdeograph(enabled: Boolean) {
- every {
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_localIdeographEnabled, true)
- }.returns(enabled)
- }
-
- private fun mockLocalIdeographString(font: String) {
- every {
- typedArray.getString(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamily)
- }.returns(font)
- }
-
- private fun mockLocalIdeographStringArray(fonts: Array<String>) {
- val resId = 9000
-
- every {
- typedArray.getResourceId(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamilies, 0)
- }.returns(resId)
-
- every {
- resources.getStringArray(resId)
- }.returns(fonts)
- }
-} \ No newline at end of file
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
deleted file mode 100644
index c46e6e3190..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java
+++ /dev/null
@@ -1,196 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.Color;
-import android.view.Gravity;
-
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.Arrays;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNull;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-@RunWith(RobolectricTestRunner.class)
-public class MapboxMapOptionsTest {
-
- private static final double DELTA = 1e-15;
-
- @Test
- public void testSanity() {
- assertNotNull("should not be null", new MapboxMapOptions());
- }
-
- @Test
- public void testDebugEnabled() {
- assertFalse(new MapboxMapOptions().getDebugActive());
- assertTrue(new MapboxMapOptions().debugActive(true).getDebugActive());
- assertFalse(new MapboxMapOptions().debugActive(false).getDebugActive());
- }
-
- @Test
- public void testCompassEnabled() {
- assertTrue(new MapboxMapOptions().compassEnabled(true).getCompassEnabled());
- assertFalse(new MapboxMapOptions().compassEnabled(false).getCompassEnabled());
- }
-
- @Test
- public void testCompassGravity() {
- assertEquals(Gravity.TOP | Gravity.END, new MapboxMapOptions().getCompassGravity());
- assertEquals(Gravity.BOTTOM, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity());
- assertNotEquals(Gravity.START, new MapboxMapOptions().compassGravity(Gravity.BOTTOM).getCompassGravity());
- }
-
- @Test
- public void testCompassMargins() {
- assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().compassMargins(
- new int[] {0, 1, 2, 3}).getCompassMargins()));
- assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().compassMargins(
- new int[] {0, 0, 0, 0}).getCompassMargins()));
- }
-
- @Test
- public void testLogoEnabled() {
- assertTrue(new MapboxMapOptions().logoEnabled(true).getLogoEnabled());
- assertFalse(new MapboxMapOptions().logoEnabled(false).getLogoEnabled());
- }
-
- @Test
- public void testLogoGravity() {
- assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getLogoGravity());
- assertEquals(Gravity.BOTTOM, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
- assertNotEquals(Gravity.START, new MapboxMapOptions().logoGravity(Gravity.BOTTOM).getLogoGravity());
- }
-
- @Test
- public void testLogoMargins() {
- assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().logoMargins(
- new int[] {0, 1, 2, 3}).getLogoMargins()));
- assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().logoMargins(
- new int[] {0, 0, 0, 0}).getLogoMargins()));
- }
-
- @Test
- public void testAttributionTintColor() {
- assertEquals(-1, new MapboxMapOptions().getAttributionTintColor());
- assertEquals(Color.RED, new MapboxMapOptions().attributionTintColor(Color.RED).getAttributionTintColor());
- }
-
- @Test
- public void testAttributionEnabled() {
- assertTrue(new MapboxMapOptions().attributionEnabled(true).getAttributionEnabled());
- assertFalse(new MapboxMapOptions().attributionEnabled(false).getAttributionEnabled());
- }
-
- @Test
- public void testAttributionGravity() {
- assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getAttributionGravity());
- assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
- assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity());
- }
-
- @Test
- public void testAttributionMargins() {
- assertTrue(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(
- new int[] {0, 1, 2, 3}).getAttributionMargins()));
- assertFalse(Arrays.equals(new int[] {0, 1, 2, 3}, new MapboxMapOptions().attributionMargins(
- new int[] {0, 0, 0, 0}).getAttributionMargins()));
- }
-
- @Test
- public void testMinZoom() {
- assertEquals(MapboxConstants.MINIMUM_ZOOM, new MapboxMapOptions().getMinZoomPreference(), DELTA);
- assertEquals(5.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA);
- assertNotEquals(2.0f, new MapboxMapOptions().minZoomPreference(5.0f).getMinZoomPreference(), DELTA);
- }
-
- @Test
- public void testMaxZoom() {
- assertEquals(MapboxConstants.MAXIMUM_ZOOM, new MapboxMapOptions().getMaxZoomPreference(), DELTA);
- assertEquals(5.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA);
- assertNotEquals(2.0f, new MapboxMapOptions().maxZoomPreference(5.0f).getMaxZoomPreference(), DELTA);
- }
-
- @Test
- public void testTiltGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getTiltGesturesEnabled());
- assertTrue(new MapboxMapOptions().tiltGesturesEnabled(true).getTiltGesturesEnabled());
- assertFalse(new MapboxMapOptions().tiltGesturesEnabled(false).getTiltGesturesEnabled());
- }
-
- @Test
- public void testScrollGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getScrollGesturesEnabled());
- assertTrue(new MapboxMapOptions().scrollGesturesEnabled(true).getScrollGesturesEnabled());
- assertFalse(new MapboxMapOptions().scrollGesturesEnabled(false).getScrollGesturesEnabled());
- }
-
- @Test
- public void testZoomGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getZoomGesturesEnabled());
- assertTrue(new MapboxMapOptions().zoomGesturesEnabled(true).getZoomGesturesEnabled());
- assertFalse(new MapboxMapOptions().zoomGesturesEnabled(false).getZoomGesturesEnabled());
- }
-
- @Test
- public void testRotateGesturesEnabled() {
- assertTrue(new MapboxMapOptions().getRotateGesturesEnabled());
- assertTrue(new MapboxMapOptions().rotateGesturesEnabled(true).getRotateGesturesEnabled());
- assertFalse(new MapboxMapOptions().rotateGesturesEnabled(false).getRotateGesturesEnabled());
- }
-
- @Test
- public void testCamera() {
- CameraPosition position = new CameraPosition.Builder().build();
- assertEquals(new CameraPosition.Builder(position).build(), new MapboxMapOptions().camera(position).getCamera());
- assertNotEquals(new CameraPosition.Builder().target(new LatLng(1, 1)), new MapboxMapOptions().camera(position));
- assertNull(new MapboxMapOptions().getCamera());
- }
-
- @Test
- public void testPrefetchesTiles() {
- // Default value
- assertTrue(new MapboxMapOptions().getPrefetchesTiles());
-
- // Check mutations
- assertTrue(new MapboxMapOptions().setPrefetchesTiles(true).getPrefetchesTiles());
- assertFalse(new MapboxMapOptions().setPrefetchesTiles(false).getPrefetchesTiles());
- }
-
- @Test
- public void testPrefetchZoomDelta() {
- // Default value
- assertEquals(4, new MapboxMapOptions().getPrefetchZoomDelta());
-
- // Check mutations
- assertEquals(5, new MapboxMapOptions().setPrefetchZoomDelta(5).getPrefetchZoomDelta());
- }
-
-
- @Test
- public void testCrossSourceCollisions() {
- // Default value
- assertTrue(new MapboxMapOptions().getCrossSourceCollisions());
-
- // check mutations
- assertTrue(new MapboxMapOptions().crossSourceCollisions(true).getCrossSourceCollisions());
- assertFalse(new MapboxMapOptions().crossSourceCollisions(false).getCrossSourceCollisions());
- }
-
- @Test
- public void testLocalIdeographFontFamily_enabledByDefault() {
- MapboxMapOptions options = MapboxMapOptions.createFromAttributes(RuntimeEnvironment.application, null);
- assertEquals(MapboxConstants.DEFAULT_FONT, options.getLocalIdeographFontFamily());
- }
-}
-
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.kt
deleted file mode 100644
index 6647fe5595..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.kt
+++ /dev/null
@@ -1,214 +0,0 @@
-package com.mapbox.mapboxsdk.maps
-
-import com.mapbox.mapboxsdk.camera.CameraPosition
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
-import com.mapbox.mapboxsdk.constants.MapboxConstants
-import com.mapbox.mapboxsdk.geometry.LatLng
-import com.mapbox.mapboxsdk.geometry.LatLngBounds
-import com.mapbox.mapboxsdk.style.layers.TransitionOptions
-import io.mockk.*
-import junit.framework.Assert.assertEquals
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class MapboxMapTest {
-
- private lateinit var mapboxMap: MapboxMap
-
- private lateinit var nativeMapView: NativeMap
-
- private lateinit var transform: Transform
-
- private lateinit var cameraChangeDispatcher: CameraChangeDispatcher
-
- private lateinit var developerAnimationListener: MapboxMap.OnDeveloperAnimationListener
-
- @Before
- fun setup() {
- cameraChangeDispatcher = spyk()
- developerAnimationListener = mockk(relaxed = true)
- nativeMapView = mockk(relaxed = true)
- transform = mockk(relaxed = true)
- mapboxMap = MapboxMap(nativeMapView, transform, mockk(relaxed = true), null, null, cameraChangeDispatcher, listOf(developerAnimationListener))
- every { nativeMapView.isDestroyed } returns false
- every { nativeMapView.nativePtr } returns 5
- mapboxMap.injectLocationComponent(spyk())
- mapboxMap.setStyle(Style.MAPBOX_STREETS)
- mapboxMap.onFinishLoadingStyle()
- }
-
- @Test
- fun testTransitionOptions() {
- val expected = TransitionOptions(100, 200)
- mapboxMap.style?.transition = expected
- verify { nativeMapView.transitionOptions = expected }
- }
-
- @Test
- fun testMoveCamera() {
- val callback = mockk<MapboxMap.CancelableCallback>()
- val target = LatLng(1.0, 2.0)
- val expected = CameraPosition.Builder().target(target).build()
- val update = CameraUpdateFactory.newCameraPosition(expected)
- mapboxMap.moveCamera(update, callback)
- verify { transform.moveCamera(mapboxMap, update, callback) }
- verify { developerAnimationListener.onDeveloperAnimationStarted() }
- }
-
- @Test
- fun testEaseCamera() {
- val callback = mockk<MapboxMap.CancelableCallback>()
- val target = LatLng(1.0, 2.0)
- val expected = CameraPosition.Builder().target(target).build()
- val update = CameraUpdateFactory.newCameraPosition(expected)
- mapboxMap.easeCamera(update, callback)
- verify { transform.easeCamera(mapboxMap, update, MapboxConstants.ANIMATION_DURATION, true, callback) }
- verify { developerAnimationListener.onDeveloperAnimationStarted() }
- }
-
- @Test
- fun testAnimateCamera() {
- val callback = mockk<MapboxMap.CancelableCallback>()
- val target = LatLng(1.0, 2.0)
- val expected = CameraPosition.Builder().target(target).build()
- val update = CameraUpdateFactory.newCameraPosition(expected)
- mapboxMap.animateCamera(update, callback)
- verify { transform.animateCamera(mapboxMap, update, MapboxConstants.ANIMATION_DURATION, callback) }
- verify { developerAnimationListener.onDeveloperAnimationStarted() }
- }
-
- @Test
- fun testScrollBy() {
- mapboxMap.scrollBy(100f, 200f)
- verify { nativeMapView.moveBy(100.0, 200.0, 0) }
- verify { developerAnimationListener.onDeveloperAnimationStarted() }
- }
-
- @Test
- fun testResetNorth() {
- mapboxMap.resetNorth()
- verify { transform.resetNorth() }
- verify { developerAnimationListener.onDeveloperAnimationStarted() }
- }
-
- @Test
- fun testFocalBearing() {
- mapboxMap.setFocalBearing(35.0, 100f, 200f, 1000)
- verify { transform.setBearing(35.0, 100f, 200f, 1000) }
- verify { developerAnimationListener.onDeveloperAnimationStarted() }
- }
-
- @Test
- fun testMinZoom() {
- mapboxMap.setMinZoomPreference(10.0)
- verify { transform.minZoom = 10.0 }
- }
-
- @Test
- fun testMaxZoom() {
- mapboxMap.setMaxZoomPreference(10.0)
- verify { transform.maxZoom = 10.0 }
- }
-
- @Test
- fun testFpsListener() {
- val fpsChangedListener = mockk<MapboxMap.OnFpsChangedListener>()
- mapboxMap.onFpsChangedListener = fpsChangedListener
- assertEquals("Listener should match", fpsChangedListener, mapboxMap.onFpsChangedListener)
- }
-
- @Test
- fun testTilePrefetch() {
- mapboxMap.prefetchesTiles = true
- verify { nativeMapView.prefetchTiles = true }
- }
-
- @Test
- fun testGetPrefetchZoomDelta() {
- every { nativeMapView.prefetchZoomDelta } answers { 3 }
- assertEquals(3, mapboxMap.prefetchZoomDelta)
- }
-
- @Test
- fun testSetPrefetchZoomDelta() {
- mapboxMap.prefetchZoomDelta = 2
- verify { nativeMapView.prefetchZoomDelta = 2 }
- }
-
- @Test
- fun testCameraForLatLngBounds() {
- val bounds = LatLngBounds.Builder().include(LatLng()).include(LatLng(1.0, 1.0)).build()
- mapboxMap.setLatLngBoundsForCameraTarget(bounds)
- verify { nativeMapView.setLatLngBounds(bounds) }
- }
-
- @Test(expected = IllegalArgumentException::class)
- fun testAnimateCameraChecksDurationPositive() {
- mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(LatLng(30.0, 30.0)), 0, null)
- }
-
- @Test(expected = IllegalArgumentException::class)
- fun testEaseCameraChecksDurationPositive() {
- mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(LatLng(30.0, 30.0)), 0, null)
- }
-
- @Test
- fun testGetNativeMapPtr() {
- assertEquals(5, mapboxMap.nativeMapPtr)
- }
-
- @Test
- fun testNativeMapIsNotCalledOnStateSave() {
- clearMocks(nativeMapView)
- mapboxMap.onSaveInstanceState(mockk(relaxed = true))
- verify { nativeMapView wasNot Called }
- }
-
- @Test
- fun testCameraChangeDispatcherCleared() {
- mapboxMap.onDestroy()
- verify { cameraChangeDispatcher.onDestroy() }
- }
-
- @Test
- fun testStyleClearedOnDestroy() {
- val style = mockk<Style>(relaxed = true)
- val builder = mockk<Style.Builder>(relaxed = true)
- every { builder.build(nativeMapView) } returns style
- mapboxMap.setStyle(builder)
-
- mapboxMap.onDestroy()
- verify(exactly = 1) { style.clear() }
- }
-
- @Test
- fun testStyleCallbackNotCalledWhenPreviousFailed() {
- val style = mockk<Style>(relaxed = true)
- val builder = mockk<Style.Builder>(relaxed = true)
- every { builder.build(nativeMapView) } returns style
- val onStyleLoadedListener = mockk<Style.OnStyleLoaded>(relaxed = true)
-
- mapboxMap.setStyle(builder, onStyleLoadedListener)
- mapboxMap.onFailLoadingStyle()
- mapboxMap.setStyle(builder, onStyleLoadedListener)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { onStyleLoadedListener.onStyleLoaded(style) }
- }
-
- @Test
- fun testStyleCallbackNotCalledWhenPreviousNotFinished() {
- // regression test for #14337
- val style = mockk<Style>(relaxed = true)
- val builder = mockk<Style.Builder>(relaxed = true)
- every { builder.build(nativeMapView) } returns style
- val onStyleLoadedListener = mockk<Style.OnStyleLoaded>(relaxed = true)
-
- mapboxMap.setStyle(builder, onStyleLoadedListener)
- mapboxMap.setStyle(builder, onStyleLoadedListener)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { onStyleLoadedListener.onStyleLoaded(style) }
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleBuilderTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleBuilderTest.kt
deleted file mode 100644
index 4c153414de..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleBuilderTest.kt
+++ /dev/null
@@ -1,237 +0,0 @@
-package com.mapbox.mapboxsdk.maps
-
-import android.graphics.Bitmap
-import android.graphics.drawable.Drawable
-import android.graphics.drawable.ShapeDrawable
-import android.util.Pair
-import com.mapbox.mapboxsdk.style.layers.SymbolLayer
-import com.mapbox.mapboxsdk.style.layers.TransitionOptions
-import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
-import com.mapbox.mapboxsdk.utils.BitmapUtils
-import io.mockk.mockk
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertTrue
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class StyleBuilderTest {
-
- @Test
- fun testFromUrl() {
- val expected = Style.MAPBOX_STREETS
- val builder = Style.Builder()
- builder.fromUrl(expected)
- assertEquals(expected, builder.uri)
- }
-
- @Test
- fun testFromJson() {
- val expected = "{}"
- val builder = Style.Builder()
- builder.fromJson(expected)
- assertEquals(expected, builder.json)
- }
-
- @Test
- fun testWithLayer() {
- val layer = mockk<SymbolLayer>()
- val builder = Style.Builder()
- builder.withLayer(layer)
- assertEquals(layer, builder.layers[0].layer)
- }
-
- @Test
- fun testWithLayers() {
- val layer1 = mockk<SymbolLayer>()
- val layer2 = mockk<SymbolLayer>()
- val builder = Style.Builder()
- builder.withLayers(layer1, layer2)
- assertEquals(layer1, builder.layers[0].layer)
- assertEquals(layer2, builder.layers[1].layer)
- }
-
- @Test
- fun testWithLayerAt() {
- val expectedIndex = 5
- val layer = mockk<SymbolLayer>()
- val builder = Style.Builder()
- builder.withLayerAt(layer, expectedIndex)
- assertEquals(layer, builder.layers[0].layer)
- assertEquals(expectedIndex, (builder.layers[0] as Style.Builder.LayerAtWrapper).index)
- }
-
- @Test
- fun testWithLayerAbove() {
- val expectedAbove = "above"
- val layer = mockk<SymbolLayer>()
- val builder = Style.Builder()
- builder.withLayerAbove(layer, expectedAbove)
- assertEquals(layer, builder.layers[0].layer)
- assertEquals(expectedAbove, (builder.layers[0] as Style.Builder.LayerAboveWrapper).aboveLayer)
- }
-
- @Test
- fun testWithLayerBelow() {
- val expectedBelow = "above"
- val layer = mockk<SymbolLayer>()
- val builder = Style.Builder()
- builder.withLayerBelow(layer, expectedBelow)
- assertEquals(layer, builder.layers[0].layer)
- assertEquals(expectedBelow, (builder.layers[0] as Style.Builder.LayerBelowWrapper).belowLayer)
- }
-
- @Test
- fun testWithSource() {
- val source = mockk<GeoJsonSource>()
- val builder = Style.Builder()
- builder.withSource(source)
- assertEquals(source, builder.sources[0])
- }
-
- @Test
- fun testWithSources() {
- val source1 = mockk<GeoJsonSource>()
- val source2 = mockk<GeoJsonSource>()
- val builder = Style.Builder()
- builder.withSources(source1, source2)
- assertEquals(source1, builder.sources[0])
- assertEquals(source2, builder.sources[1])
- }
-
- @Test
- fun testWithImage() {
- val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8)
- val builder = Style.Builder()
- builder.withImage("id", bitmap)
- assertEquals(bitmap, builder.images[0].bitmap)
- assertEquals("id", builder.images[0].id)
- assertEquals(false, builder.images[0].sdf)
- }
-
- @Test
- fun testWithImages() {
- val bitmap1 = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8)
- val bitmap2 = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8)
- val builder = Style.Builder()
- builder.withBitmapImages(Pair("id1", bitmap1), Pair("id2", bitmap2))
- assertEquals(bitmap1, builder.images[0].bitmap)
- assertEquals("id1", builder.images[0].id)
- assertEquals(false, builder.images[0].sdf)
- assertEquals(bitmap2, builder.images[1].bitmap)
- assertEquals("id2", builder.images[1].id)
- assertEquals(false, builder.images[1].sdf)
- }
-
- @Test
- fun testWithImageSdf() {
- val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8)
- val builder = Style.Builder()
- builder.withImage("id", bitmap, true)
- assertEquals(bitmap, builder.images[0].bitmap)
- assertEquals("id", builder.images[0].id)
- assertEquals(true, builder.images[0].sdf)
- }
-
- @Test
- fun testWithImageSdfs() {
- val bitmap1 = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8)
- val bitmap2 = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8)
- val builder = Style.Builder()
- builder.withBitmapImages(true, Pair("id1", bitmap1), Pair("id2", bitmap2))
- assertEquals(bitmap1, builder.images[0].bitmap)
- assertEquals("id1", builder.images[0].id)
- assertEquals(true, builder.images[0].sdf)
- assertEquals(bitmap2, builder.images[1].bitmap)
- assertEquals("id2", builder.images[1].id)
- assertEquals(true, builder.images[1].sdf)
- }
-
- @Test
- fun testWithImageDrawable() {
- val drawable = ShapeDrawable()
- drawable.intrinsicWidth = 1
- drawable.intrinsicHeight = 1
- val builder = Style.Builder()
- builder.withImage("id", drawable)
- assertTrue(BitmapUtils.equals(
- BitmapUtils.getBitmapFromDrawable(drawable)!!,
- builder.images[0].bitmap)
- )
- assertEquals("id", builder.images[0].id)
- assertEquals(false, builder.images[0].sdf)
- }
-
- @Test
- fun testWithImageDrawableSdf() {
- val drawable = ShapeDrawable()
- drawable.intrinsicWidth = 1
- drawable.intrinsicHeight = 1
- val builder = Style.Builder()
- builder.withImage("id", drawable, true)
- assertTrue(BitmapUtils.equals(
- BitmapUtils.getBitmapFromDrawable(drawable)!!,
- builder.images[0].bitmap)
- )
- assertEquals("id", builder.images[0].id)
- assertEquals(true, builder.images[0].sdf)
- }
-
- @Test
- fun testWithImageDrawables() {
- val drawable1 = ShapeDrawable()
- drawable1.intrinsicWidth = 1
- drawable1.intrinsicHeight = 1
- val drawable2 = ShapeDrawable()
- drawable2.intrinsicWidth = 1
- drawable2.intrinsicHeight = 1
- val builder = Style.Builder()
- builder.withDrawableImages(Pair<String, Drawable>("id1", drawable1), Pair<String, Drawable>("id2", drawable2))
- assertTrue(BitmapUtils.equals(
- BitmapUtils.getBitmapFromDrawable(drawable1)!!,
- builder.images[0].bitmap)
- )
- assertEquals("id1", builder.images[0].id)
- assertEquals(false, builder.images[0].sdf)
- assertTrue(BitmapUtils.equals(
- BitmapUtils.getBitmapFromDrawable(drawable2)!!,
- builder.images[1].bitmap)
- )
- assertEquals("id2", builder.images[1].id)
- assertEquals(false, builder.images[1].sdf)
- }
-
- @Test
- fun testWithImageSdfDrawables() {
- val drawable1 = ShapeDrawable()
- drawable1.intrinsicWidth = 1
- drawable1.intrinsicHeight = 1
- val drawable2 = ShapeDrawable()
- drawable2.intrinsicWidth = 1
- drawable2.intrinsicHeight = 1
- val builder = Style.Builder()
- builder.withDrawableImages(true, Pair<String, Drawable>("id1", drawable1), Pair<String, Drawable>("id2", drawable2))
- assertTrue(BitmapUtils.equals(
- BitmapUtils.getBitmapFromDrawable(drawable1)!!,
- builder.images[0].bitmap)
- )
- assertEquals("id1", builder.images[0].id)
- assertEquals(true, builder.images[0].sdf)
- assertTrue(BitmapUtils.equals(
- BitmapUtils.getBitmapFromDrawable(drawable2)!!,
- builder.images[1].bitmap)
- )
- assertEquals("id2", builder.images[1].id)
- assertEquals(true, builder.images[1].sdf)
- }
-
- @Test
- fun testWithTransitionOptions() {
- val transitionOptions = TransitionOptions(100, 200)
- val builder = Style.Builder()
- builder.withTransition(transitionOptions)
- assertEquals(100, builder.transitionOptions.duration)
- assertEquals(200, builder.transitionOptions.delay)
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
deleted file mode 100644
index a5070ae5c0..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
+++ /dev/null
@@ -1,408 +0,0 @@
-package com.mapbox.mapboxsdk.maps
-
-import android.graphics.Bitmap
-import android.graphics.drawable.ShapeDrawable
-import com.mapbox.mapboxsdk.constants.MapboxConstants
-import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException
-import com.mapbox.mapboxsdk.style.layers.SymbolLayer
-import com.mapbox.mapboxsdk.style.layers.TransitionOptions
-import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException
-import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
-import io.mockk.*
-import org.junit.Assert
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class StyleTest {
-
- private lateinit var mapboxMap: MapboxMap
-
- private lateinit var nativeMapView: NativeMap
-
- @Before
- fun setup() {
- nativeMapView = mockk(relaxed = true)
- mapboxMap = MapboxMap(nativeMapView, null, null, null, null, null, null)
- every { nativeMapView.isDestroyed } returns false
- mapboxMap.injectLocationComponent(spyk())
- }
-
- @Test
- fun testFromUrl() {
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- }
-
- @Test
- fun testFromJson() {
- val builder = Style.Builder().fromJson("{}")
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleJson = "{}" }
- }
-
- @Test
- fun testEmptyBuilder() {
- val builder = Style.Builder()
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleJson = Style.EMPTY_JSON }
- }
-
- @Test
- fun testWithLayer() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().withLayer(layer)
- mapboxMap.setStyle(builder)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.addLayerBelow(layer, MapboxConstants.LAYER_ID_ANNOTATIONS) }
- }
-
- @Test
- fun testWithLayerAbove() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().withLayerAbove(layer, "id")
- mapboxMap.setStyle(builder)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.addLayerAbove(layer, "id") }
- }
-
- @Test
- fun testWithLayerBelow() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().withLayerBelow(layer, "id")
- mapboxMap.setStyle(builder)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.addLayerBelow(layer, "id") }
- }
-
- @Test
- fun testWithLayerAt() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().withLayerAt(layer, 1)
- mapboxMap.setStyle(builder)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.addLayerAt(layer, 1) }
- }
-
- @Test
- fun testWithSource() {
- val source = mockk<GeoJsonSource>()
- every { source.id } returns "1"
- val builder = Style.Builder().withSource(source)
- mapboxMap.setStyle(builder)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.addSource(source) }
- }
-
- @Test
- fun testWithTransitionOptions() {
- val transitionOptions = TransitionOptions(100, 200)
- val builder = Style.Builder().withTransition(transitionOptions)
- mapboxMap.setStyle(builder)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.transitionOptions = transitionOptions }
- }
-
- @Test
- fun testWithFromLoadingSource() {
- val source = mockk<GeoJsonSource>()
- every { source.id } returns "1"
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withSource(source)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addSource(source) }
- }
-
- @Test
- fun testWithFromLoadingLayer() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withLayer(layer)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addLayerBelow(layer, MapboxConstants.LAYER_ID_ANNOTATIONS) }
- }
-
- @Test
- fun testWithFromLoadingLayerAt() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withLayerAt(layer, 1)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addLayerAt(layer, 1) }
- }
-
- @Test
- fun testWithFromLoadingLayerBelow() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withLayerBelow(layer, "below")
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addLayerBelow(layer, "below") }
- }
-
- @Test
- fun testWithFromLoadingLayerAbove() {
- val layer = mockk<SymbolLayer>()
- every { layer.id } returns "1"
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withLayerBelow(layer, "below")
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addLayerBelow(layer, "below") }
- }
-
- @Test
- fun testWithFromLoadingTransitionOptions() {
- val transitionOptions = TransitionOptions(100, 200)
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withTransition(transitionOptions)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.transitionOptions = transitionOptions }
- }
-
- @Test
- fun testFromCallback() {
- val callback = mockk<Style.OnStyleLoaded>()
- every { callback.onStyleLoaded(any()) } answers {}
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS)
- mapboxMap.setStyle(builder, callback)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { callback.onStyleLoaded(any()) }
- }
-
- @Test
- fun testWithCallback() {
- val callback = mockk<Style.OnStyleLoaded>()
- every { callback.onStyleLoaded(any()) } answers {}
- val source = mockk<GeoJsonSource>()
- every { source.id } returns "1"
- val builder = Style.Builder().withSource(source)
- mapboxMap.setStyle(builder, callback)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.addSource(source) }
- verify(exactly = 1) { callback.onStyleLoaded(any()) }
- }
-
- @Test
- fun testGetAsyncWith() {
- val callback = mockk<Style.OnStyleLoaded>()
- every { callback.onStyleLoaded(any()) } answers {}
- mapboxMap.getStyle(callback)
- val source = mockk<GeoJsonSource>()
- every { source.id } returns "1"
- val builder = Style.Builder().withSource(source)
- mapboxMap.setStyle(builder)
- mapboxMap.onFinishLoadingStyle()
- verify(exactly = 1) { nativeMapView.addSource(source) }
- verify(exactly = 1) { callback.onStyleLoaded(any()) }
- }
-
- @Test
- fun testGetAsyncFrom() {
- val callback = mockk<Style.OnStyleLoaded>()
- every { callback.onStyleLoaded(any()) } answers {}
- mapboxMap.getStyle(callback)
- val source = mockk<GeoJsonSource>()
- every { source.id } returns "1"
- val builder = Style.Builder().fromJson("{}")
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleJson = "{}" }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { callback.onStyleLoaded(any()) }
- }
-
- @Test
- fun testGetAsyncWithFrom() {
- val callback = mockk<Style.OnStyleLoaded>()
- every { callback.onStyleLoaded(any()) } answers {}
- mapboxMap.getStyle(callback)
- val source = mockk<GeoJsonSource>()
- every { source.id } returns "1"
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withSource(source)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.MAPBOX_STREETS }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addSource(source) }
- verify(exactly = 1) { callback.onStyleLoaded(any()) }
- }
-
- @Test
- fun testGetNullStyle() {
- Assert.assertNull(mapboxMap.style)
- }
-
- @Test
- fun testGetNullWhileLoading() {
- val transitionOptions = TransitionOptions(100, 200)
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withTransition(transitionOptions)
- mapboxMap.setStyle(builder)
- Assert.assertNull(mapboxMap.style)
- mapboxMap.notifyStyleLoaded()
- Assert.assertNotNull(mapboxMap.style)
- }
-
- @Test
- fun testNotReinvokeSameListener() {
- val callback = mockk<Style.OnStyleLoaded>()
- every { callback.onStyleLoaded(any()) } answers {}
- mapboxMap.getStyle(callback)
- val source = mockk<GeoJsonSource>()
- every { source.id } returns "1"
- val builder = Style.Builder().fromJson("{}")
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleJson = "{}" }
- mapboxMap.notifyStyleLoaded()
- mapboxMap.setStyle(Style.MAPBOX_STREETS)
- verify(exactly = 1) { callback.onStyleLoaded(any()) }
- }
-
- @Test(expected = IllegalStateException::class)
- fun testIllegalStateExceptionWithStyleReload() {
- val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS)
- mapboxMap.setStyle(builder)
- mapboxMap.notifyStyleLoaded()
- val style = mapboxMap.style
- mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
- style!!.addLayer(mockk<SymbolLayer>())
- }
-
- @Test
- fun testAddImage() {
- val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
- val builder = Style.Builder().fromUrl(Style.SATELLITE).withImage("id", bitmap)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.SATELLITE }
- verify(exactly = 0) { nativeMapView.addImages(any()) }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addImages(any()) }
- }
-
- @Test
- fun testAddDrawable() {
- val drawable = ShapeDrawable()
- drawable.intrinsicHeight = 10
- drawable.intrinsicWidth = 10
- val builder = Style.Builder().fromUrl(Style.SATELLITE).withImage("id", drawable)
- mapboxMap.setStyle(builder)
- verify(exactly = 1) { nativeMapView.styleUri = Style.SATELLITE }
- verify(exactly = 0) { nativeMapView.addImages(any()) }
- mapboxMap.notifyStyleLoaded()
- verify(exactly = 1) { nativeMapView.addImages(any()) }
- }
-
- @Test
- fun testSourceSkippedIfAdditionFails() {
- val source1 = mockk<GeoJsonSource>(relaxed = true)
- every { source1.id } returns "source1"
- val source2 = mockk<GeoJsonSource>(relaxed = true)
- every { source2.id } returns "source1" // same ID
-
- val builder = Style.Builder().withSource(source1)
- mapboxMap.setStyle(builder)
- mapboxMap.notifyStyleLoaded()
-
- every { nativeMapView.addSource(any()) } throws CannotAddSourceException("Duplicate ID")
-
- try {
- mapboxMap.style!!.addSource(source2)
- } catch (ex: Exception) {
- Assert.assertEquals("Source that failed to be added shouldn't be cached", source1, mapboxMap.style!!.getSource("source1"))
- }
- }
-
- @Test
- fun testLayerSkippedIfAdditionFails() {
- val layer1 = mockk<SymbolLayer>(relaxed = true)
- every { layer1.id } returns "layer1"
- val layer2 = mockk<SymbolLayer>(relaxed = true)
- every { layer2.id } returns "layer1" // same ID
-
- val builder = Style.Builder().withLayer(layer1)
- mapboxMap.setStyle(builder)
- mapboxMap.notifyStyleLoaded()
-
- every { nativeMapView.addLayer(any()) } throws CannotAddLayerException("Duplicate ID")
-
- try {
- mapboxMap.style!!.addLayer(layer2)
- } catch (ex: Exception) {
- Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
- }
- }
-
- @Test
- fun testLayerSkippedIfAdditionBelowFails() {
- val layer1 = mockk<SymbolLayer>(relaxed = true)
- every { layer1.id } returns "layer1"
- val layer2 = mockk<SymbolLayer>(relaxed = true)
- every { layer2.id } returns "layer1" // same ID
-
- val builder = Style.Builder().withLayer(layer1)
- mapboxMap.setStyle(builder)
- mapboxMap.notifyStyleLoaded()
-
- every { nativeMapView.addLayerBelow(any(), "") } throws CannotAddLayerException("Duplicate ID")
-
- try {
- mapboxMap.style!!.addLayerBelow(layer2, "")
- } catch (ex: Exception) {
- Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
- }
- }
-
- @Test
- fun testLayerSkippedIfAdditionAboveFails() {
- val layer1 = mockk<SymbolLayer>(relaxed = true)
- every { layer1.id } returns "layer1"
- val layer2 = mockk<SymbolLayer>(relaxed = true)
- every { layer2.id } returns "layer1" // same ID
-
- val builder = Style.Builder().withLayer(layer1)
- mapboxMap.setStyle(builder)
- mapboxMap.notifyStyleLoaded()
-
- every { nativeMapView.addLayerAbove(any(), "") } throws CannotAddLayerException("Duplicate ID")
-
- try {
- mapboxMap.style!!.addLayerAbove(layer2, "")
- } catch (ex: Exception) {
- Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
- }
- }
-
- @Test
- fun testLayerSkippedIfAdditionAtFails() {
- val layer1 = mockk<SymbolLayer>(relaxed = true)
- every { layer1.id } returns "layer1"
- val layer2 = mockk<SymbolLayer>(relaxed = true)
- every { layer2.id } returns "layer1" // same ID
-
- val builder = Style.Builder().withLayer(layer1)
- mapboxMap.setStyle(builder)
- mapboxMap.notifyStyleLoaded()
-
- every { nativeMapView.addLayerAt(any(), 5) } throws CannotAddLayerException("Duplicate ID")
-
- try {
- mapboxMap.style!!.addLayerAt(layer2, 5)
- } catch (ex: Exception) {
- Assert.assertEquals("Layer that failed to be added shouldn't be cached", layer1, mapboxMap.style!!.getLayer("layer1"))
- }
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TransformTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
deleted file mode 100644
index fddf7eeaff..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/TransformTest.kt
+++ /dev/null
@@ -1,183 +0,0 @@
-package com.mapbox.mapboxsdk.maps
-
-import com.mapbox.mapboxsdk.camera.CameraPosition
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
-import com.mapbox.mapboxsdk.geometry.LatLng
-import io.mockk.*
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class TransformTest {
-
- private lateinit var mapView: MapView
- private lateinit var nativeMapView: NativeMap
- private lateinit var transform: Transform
-
- @Before
- fun setup() {
- val cameraChangeDispatcher = spyk<CameraChangeDispatcher>()
- mapView = mockk()
- nativeMapView = mockk()
- transform = Transform(mapView, nativeMapView, cameraChangeDispatcher)
- every { nativeMapView.isDestroyed } returns false
- every { nativeMapView.cameraPosition } returns CameraPosition.DEFAULT
- every { nativeMapView.cancelTransitions() } answers {}
- every { nativeMapView.jumpTo(any(), any(), any(), any(), any()) } answers {}
- every { nativeMapView.easeTo(any(), any(), any(), any(), any(), any(), any()) } answers {}
- every { nativeMapView.flyTo(any(), any(), any(), any(), any(), any()) } answers {}
- every { nativeMapView.minZoom = any() } answers {}
- every { nativeMapView.maxZoom = any() } answers {}
- }
-
- @Test
- fun testMoveCamera() {
- val mapboxMap = mockk<MapboxMap>()
- every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
-
- val callback = mockk<MapboxMap.CancelableCallback>()
- every { callback.onFinish() } answers {}
-
- val target = LatLng(1.0, 2.0)
- val expected = CameraPosition.Builder().target(target).build()
- val update = CameraUpdateFactory.newCameraPosition(expected)
- transform.moveCamera(mapboxMap, update, callback)
-
- verify { nativeMapView.jumpTo(target, -1.0, -1.0, -1.0, null) }
- verify { callback.onFinish() }
- }
-
- @Test
- fun testMoveCameraToSamePosition() {
- val mapboxMap = mockk<MapboxMap>()
- every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
-
- val callback = mockk<MapboxMap.CancelableCallback>()
- every { callback.onFinish() } answers {}
-
- val expected = CameraPosition.DEFAULT
- val update = CameraUpdateFactory.newCameraPosition(expected)
-
- transform.moveCamera(mapboxMap, update, null) // Initialize camera position
- transform.moveCamera(mapboxMap, update, callback)
-
- verify(exactly = 1, verifyBlock = { nativeMapView.jumpTo(any(), any(), any(), any(), any()) })
- verify { callback.onFinish() }
- }
-
- @Test
- fun testEaseCamera() {
- val mapboxMap = mockk<MapboxMap>()
- every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
-
- every { mapView.addOnCameraDidChangeListener(any()) } answers { transform.onCameraDidChange(true) }
- every { mapView.removeOnCameraDidChangeListener(any()) } answers {}
-
- val callback = mockk<MapboxMap.CancelableCallback>()
- every { callback.onFinish() } answers {}
-
- val target = LatLng(1.0, 2.0)
- val expected = CameraPosition.Builder().target(target).build()
- val update = CameraUpdateFactory.newCameraPosition(expected)
-
- transform.easeCamera(mapboxMap, update, 100, false, callback)
-
- verify { nativeMapView.easeTo(target, -1.0, -1.0, -1.0, null, 100, false) }
- verify { callback.onFinish() }
- }
-
- @Test
- fun testEaseCameraToSamePosition() {
- val mapboxMap = mockk<MapboxMap>()
- every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
-
- val callback = mockk<MapboxMap.CancelableCallback>()
- every { callback.onFinish() } answers {}
-
- val expected = CameraPosition.DEFAULT
- val update = CameraUpdateFactory.newCameraPosition(expected)
- transform.moveCamera(mapboxMap, update, null)
-
- transform.easeCamera(mapboxMap, update, 100, false, callback)
-
- verify(exactly = 0, verifyBlock = { nativeMapView.easeTo(any(), any(), any(), any(), any(), any(), any()) })
- verify { callback.onFinish() }
- }
-
- @Test
- fun testAnimateCamera() {
- val mapboxMap = mockk<MapboxMap>()
- every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
-
- every { mapView.addOnCameraDidChangeListener(any()) } answers { transform.onCameraDidChange(true) }
- every { mapView.removeOnCameraDidChangeListener(any()) } answers {}
-
- val callback = mockk<MapboxMap.CancelableCallback>()
- every { callback.onFinish() } answers {}
-
- val target = LatLng(1.0, 2.0)
- val expected = CameraPosition.Builder().target(target).build()
- val update = CameraUpdateFactory.newCameraPosition(expected)
-
- transform.animateCamera(mapboxMap, update, 100, callback)
-
- verify { nativeMapView.flyTo(target, -1.0, -1.0, -1.0, null, 100) }
- verify { callback.onFinish() }
- }
-
- @Test
- fun testAnimateCameraToSamePosition() {
- val mapboxMap = mockk<MapboxMap>()
- every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
-
- val callback = mockk<MapboxMap.CancelableCallback>()
- every { callback.onFinish() } answers {}
-
- val expected = CameraPosition.DEFAULT
- val update = CameraUpdateFactory.newCameraPosition(expected)
- transform.moveCamera(mapboxMap, update, null)
-
- transform.animateCamera(mapboxMap, update, 100, callback)
-
- verify(exactly = 0, verifyBlock = { nativeMapView.flyTo(any(), any(), any(), any(), any(), any()) })
- verify { callback.onFinish() }
- }
-
- @Test
- fun testMinZoom() {
- transform.minZoom = 10.0
- verify { nativeMapView.minZoom = 10.0 }
- }
-
- @Test
- fun testMaxZoom() {
- transform.maxZoom = 10.0
- verify { nativeMapView.maxZoom = 10.0 }
- }
-
- @Test
- fun testCancelNotInvokedFromOnFinish() {
- val slot = slot<MapView.OnCameraDidChangeListener>()
- every { mapView.addOnCameraDidChangeListener(capture(slot)) } answers { slot.captured.onCameraDidChange(true) }
- every { mapView.removeOnCameraDidChangeListener(any()) } answers {}
- // regression test for https://github.com/mapbox/mapbox-gl-native/issues/13735
- val mapboxMap = mockk<MapboxMap>()
- every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
-
- val target = LatLng(1.0, 2.0)
- val expected = CameraPosition.Builder().target(target).build()
-
- val callback = object : MapboxMap.CancelableCallback {
- override fun onCancel() {
- throw IllegalStateException("onCancel shouldn't be called from onFinish")
- }
-
- override fun onFinish() {
- transform.animateCamera(mapboxMap, CameraUpdateFactory.newCameraPosition(expected), 500, null)
- }
- }
- transform.animateCamera(mapboxMap, CameraUpdateFactory.newCameraPosition(expected), 500, callback)
- }
-} \ No newline at end of file
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
deleted file mode 100644
index a84e93cd75..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java
+++ /dev/null
@@ -1,433 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.view.Gravity;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.maps.widgets.CompassView;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.InjectMocks;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
-
-public class UiSettingsTest {
-
- @InjectMocks
- Projection projection = mock(Projection.class);
-
- @InjectMocks
- FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class);
-
- @InjectMocks
- CompassView compassView = mock(CompassView.class);
-
- @InjectMocks
- ImageView imageView = mock(ImageView.class);
-
- @InjectMocks
- ImageView logoView = mock(ImageView.class);
-
- @InjectMocks
- FrameLayout.LayoutParams layoutParams = mock(FrameLayout.LayoutParams.class);
-
- private UiSettings uiSettings;
-
- @Before
- public void beforeTest() {
- uiSettings = new UiSettings(projection, focalPointChangeListener, compassView, imageView, logoView, 1);
- }
-
- @Test
- public void testSanity() {
- assertNotNull("uiSettings should not be null", uiSettings);
- }
-
- @Test
- public void testCompassEnabled() {
- when(compassView.isEnabled()).thenReturn(true);
- uiSettings.setCompassEnabled(true);
- assertEquals("Compass should be enabled", true, uiSettings.isCompassEnabled());
- }
-
- @Test
- public void testCompassDisabled() {
- uiSettings.setCompassEnabled(false);
- assertEquals("Compass should be disabled", false, uiSettings.isCompassEnabled());
- }
-
- @Test
- public void testCompassGravity() {
- when(compassView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.gravity = Gravity.START;
- uiSettings.setCompassGravity(Gravity.START);
- assertEquals("Compass gravity should be same", Gravity.START, uiSettings.getCompassGravity());
- }
-
- @Test
- public void testCompassMargins() {
- when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0});
- when(compassView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.leftMargin = 1;
- layoutParams.topMargin = 2;
- layoutParams.rightMargin = 3;
- layoutParams.bottomMargin = 4;
- uiSettings.setCompassMargins(1, 2, 3, 4);
- assertTrue("Compass margin left should be same", uiSettings.getCompassMarginLeft() == 1);
- assertTrue("Compass margin top should be same", uiSettings.getCompassMarginTop() == 2);
- assertTrue("Compass margin right should be same", uiSettings.getCompassMarginRight() == 3);
- assertTrue("Compass margin bottom should be same", uiSettings.getCompassMarginBottom() == 4);
- }
-
- @Test
- public void testCompassFadeWhenFacingNorth() {
- when(compassView.isFadeCompassViewFacingNorth()).thenReturn(true);
- assertTrue("Compass should fade when facing north by default.", uiSettings.isCompassFadeWhenFacingNorth());
- uiSettings.setCompassFadeFacingNorth(false);
- when(compassView.isFadeCompassViewFacingNorth()).thenReturn(false);
- assertFalse("Compass fading should be disabled", uiSettings.isCompassFadeWhenFacingNorth());
- }
-
- @Test
- public void testLogoEnabled() {
- uiSettings.setLogoEnabled(true);
- assertEquals("Logo should be enabled", true, uiSettings.isLogoEnabled());
- }
-
- @Test
- public void testLogoDisabled() {
- when(logoView.getVisibility()).thenReturn(View.GONE);
- uiSettings.setLogoEnabled(false);
- assertEquals("Logo should be disabled", false, uiSettings.isLogoEnabled());
- }
-
- @Test
- public void testLogoGravity() {
- layoutParams.gravity = Gravity.END;
- when(logoView.getLayoutParams()).thenReturn(layoutParams);
- uiSettings.setLogoGravity(Gravity.END);
- assertEquals("Logo gravity should be same", Gravity.END, uiSettings.getLogoGravity());
- }
-
- @Test
- public void testLogoMargins() {
- when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0});
- when(logoView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.leftMargin = 1;
- layoutParams.topMargin = 2;
- layoutParams.rightMargin = 3;
- layoutParams.bottomMargin = 4;
- uiSettings.setLogoMargins(1, 2, 3, 4);
- assertTrue("Compass margin left should be same", uiSettings.getLogoMarginLeft() == 1);
- assertTrue("Compass margin top should be same", uiSettings.getLogoMarginTop() == 2);
- assertTrue("Compass margin right should be same", uiSettings.getLogoMarginRight() == 3);
- assertTrue("Compass margin bottom should be same", uiSettings.getLogoMarginBottom() == 4);
- }
-
- @Test
- public void testAttributionEnabled() {
- when(imageView.getVisibility()).thenReturn(View.VISIBLE);
- uiSettings.setAttributionEnabled(true);
- assertEquals("Attribution should be enabled", true, uiSettings.isAttributionEnabled());
- }
-
- @Test
- public void testAttributionDisabled() {
- when(imageView.getVisibility()).thenReturn(View.GONE);
- uiSettings.setAttributionEnabled(false);
- assertEquals("Attribution should be disabled", false, uiSettings.isAttributionEnabled());
- }
-
- @Test
- public void testAttributionGravity() {
- when(imageView.getLayoutParams()).thenReturn(layoutParams);
- layoutParams.gravity = Gravity.END;
- uiSettings.setAttributionGravity(Gravity.END);
- assertEquals("Attribution gravity should be same", Gravity.END, uiSettings.getAttributionGravity());
- }
-
- @Test
- public void testAttributionMargins() {
- when(imageView.getLayoutParams()).thenReturn(layoutParams);
- when(projection.getContentPadding()).thenReturn(new int[] {0, 0, 0, 0});
- layoutParams.leftMargin = 1;
- layoutParams.topMargin = 2;
- layoutParams.rightMargin = 3;
- layoutParams.bottomMargin = 4;
- uiSettings.setAttributionMargins(1, 2, 3, 4);
- assertTrue("Attribution margin left should be same", uiSettings.getAttributionMarginLeft() == 1);
- assertTrue("Attribution margin top should be same", uiSettings.getAttributionMarginTop() == 2);
- assertTrue("Attribution margin right should be same", uiSettings.getAttributionMarginRight() == 3);
- assertTrue("Attribution margin bottom should be same", uiSettings.getAttributionMarginBottom() == 4);
- }
-
- @Test
- public void testRotateGesturesEnabled() {
- uiSettings.setRotateGesturesEnabled(true);
- assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
- }
-
- @Test
- public void testRotateGesturesDisabled() {
- uiSettings.setRotateGesturesEnabled(false);
- assertEquals("Rotate gesture should be disabled", false, uiSettings.isRotateGesturesEnabled());
- }
-
- @Test
- public void testRotateGestureChangeAllowed() {
- uiSettings.setRotateGesturesEnabled(false);
- assertEquals("Rotate gesture should be false", false, uiSettings.isRotateGesturesEnabled());
- uiSettings.setRotateGesturesEnabled(true);
- assertEquals("Rotate gesture should be true", true, uiSettings.isRotateGesturesEnabled());
- }
-
- @Test
- public void testTiltGesturesEnabled() {
- uiSettings.setTiltGesturesEnabled(true);
- assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
- }
-
- @Test
- public void testTiltGesturesDisabled() {
- uiSettings.setTiltGesturesEnabled(false);
- assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
- }
-
- @Test
- public void testTiltGestureChangeAllowed() {
- uiSettings.setTiltGesturesEnabled(false);
- assertEquals("Tilt gesture should be false", false, uiSettings.isTiltGesturesEnabled());
- uiSettings.setTiltGesturesEnabled(true);
- assertEquals("Tilt gesture should be true", true, uiSettings.isTiltGesturesEnabled());
- }
-
- @Test
- public void testZoomGesturesEnabled() {
- uiSettings.setZoomGesturesEnabled(true);
- assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
- }
-
- @Test
- public void testZoomGesturesDisabled() {
- uiSettings.setZoomGesturesEnabled(false);
- assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
- }
-
- @Test
- public void testZoomGestureChangeAllowed() {
- uiSettings.setZoomGesturesEnabled(false);
- assertEquals("Zoom gesture should be false", false, uiSettings.isZoomGesturesEnabled());
- uiSettings.setZoomGesturesEnabled(true);
- assertEquals("Zoom gesture should be true", true, uiSettings.isZoomGesturesEnabled());
- }
-
- @Test
- public void testDoubleTapGesturesEnabled() {
- uiSettings.setDoubleTapGesturesEnabled(true);
- assertEquals("DoubleTap gesture should be enabled", true, uiSettings.isDoubleTapGesturesEnabled());
- }
-
- @Test
- public void testDoubleTapGesturesDisabled() {
- uiSettings.setDoubleTapGesturesEnabled(false);
- assertEquals("DoubleTap gesture should be disabled", false, uiSettings.isDoubleTapGesturesEnabled());
- }
-
- @Test
- public void testDoubleTapGestureChangeAllowed() {
- uiSettings.setDoubleTapGesturesEnabled(false);
- assertEquals("DoubleTap gesture should be false", false, uiSettings.isDoubleTapGesturesEnabled());
- uiSettings.setDoubleTapGesturesEnabled(true);
- assertEquals("DoubleTap gesture should be true", true, uiSettings.isDoubleTapGesturesEnabled());
- }
-
- @Test
- public void testQuickZoomGesturesEnabled() {
- uiSettings.setQuickZoomGesturesEnabled(true);
- assertEquals("QuickZoom gesture should be enabled", true, uiSettings.isQuickZoomGesturesEnabled());
- }
-
- @Test
- public void testQuickZoomGesturesDisabled() {
- uiSettings.setQuickZoomGesturesEnabled(false);
- assertEquals("QuickZoom gesture should be disabled", false, uiSettings.isQuickZoomGesturesEnabled());
- }
-
- @Test
- public void testQuickZoomGestureChangeAllowed() {
- uiSettings.setQuickZoomGesturesEnabled(false);
- assertEquals("QuickZoom gesture should be false", false, uiSettings.isQuickZoomGesturesEnabled());
- uiSettings.setQuickZoomGesturesEnabled(true);
- assertEquals("QuickZoom gesture should be true", true, uiSettings.isQuickZoomGesturesEnabled());
- }
-
- @Test
- public void testScrollGesturesEnabled() {
- uiSettings.setScrollGesturesEnabled(true);
- assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testScrollGesturesDisabled() {
- uiSettings.setScrollGesturesEnabled(false);
- assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testScrollGestureChangeAllowed() {
- uiSettings.setScrollGesturesEnabled(false);
- assertEquals("Scroll gesture should be false", false, uiSettings.isScrollGesturesEnabled());
- uiSettings.setScrollGesturesEnabled(true);
- assertEquals("Scroll gesture should be true", true, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- 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 testDisableRotateWhenScalingEnabled() {
- uiSettings.setDisableRotateWhenScaling(true);
- assertEquals("Rotate disabling should be enabled", true,
- uiSettings.isDisableRotateWhenScaling());
- }
-
- @Test
- public void testDisableRotateWhenScalingDisabled() {
- uiSettings.setDisableRotateWhenScaling(false);
- assertEquals("Rotate disabling should be disabled", false,
- uiSettings.isDisableRotateWhenScaling());
- }
-
- @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
- public void testAllGesturesEnabled() {
- uiSettings.setAllGesturesEnabled(true);
- assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
- assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
- assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
- assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testAllGesturesDisabled() {
- uiSettings.setAllGesturesEnabled(false);
- assertEquals("Rotate gesture should be enabled", false, uiSettings.isRotateGesturesEnabled());
- assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
- assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
- assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
- }
-
- @Test
- public void testAreAllGesturesEnabled() {
- uiSettings.setAllGesturesEnabled(true);
- assertEquals("All gestures check should return true", true,
- uiSettings.areAllGesturesEnabled());
- }
-
- @Test
- public void testAreAllGesturesEnabledWithOneGestureDisabled() {
- uiSettings.setAllGesturesEnabled(true);
- uiSettings.setScrollGesturesEnabled(false);
- assertEquals("All gestures check should return false", false,
- uiSettings.areAllGesturesEnabled());
- }
-
- @Test
- public void testZoomRateDefaultValue() {
- assertEquals("Default zoom rate should be 1.0f", 1.0f,
- uiSettings.getZoomRate(), 0);
- }
-
- @Test
- public void testZoomRate() {
- uiSettings.setZoomRate(0.83f);
- assertEquals("Zoom rate should be 0.83f", 0.83f,
- uiSettings.getZoomRate(), 0);
- }
-
- @Test
- public void testUpdateWhenCompassViewNotHidden() {
- CameraPosition cameraPosition = new CameraPosition.Builder(CameraPosition.DEFAULT).bearing(24.0f).build();
- when(compassView.isHidden()).thenReturn(false);
- uiSettings.update(cameraPosition);
- verify(compassView).update(-24.0f);
- }
-
- @Test
- public void testUpdateWhenCompassViewHidden() {
- CameraPosition cameraPosition = new CameraPosition.Builder(CameraPosition.DEFAULT).bearing(24.0f).build();
- when(compassView.isHidden()).thenReturn(true);
- uiSettings.update(cameraPosition);
- verify(compassView).update(-24.0f);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUrlTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUrlTest.kt
deleted file mode 100644
index 5db7b0b0f9..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUrlTest.kt
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.mapbox.mapboxsdk.module.http
-
-import com.mapbox.mapboxsdk.MapboxInjector
-import com.mapbox.mapboxsdk.http.HttpRequestUrl
-import io.mockk.mockk
-import junit.framework.Assert.assertEquals
-import org.junit.After
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class HttpRequestUrlTest {
-
- @Before
- fun setUp() {
- MapboxInjector.inject(mockk(relaxed = true), "pk.foobar", "foobar")
- }
-
- @Test
- fun testOfflineFlagMapboxCom() {
- val expected = "http://mapbox.com/path/of/no/return.pbf?offline=true"
- val actual = HttpRequestUrl.buildResourceUrl("mapbox.com", "http://mapbox.com/path/of/no/return.pbf", 0, true)
- assertEquals(expected, actual)
- }
-
- @Test
- fun testOfflineFlagMapboxCn() {
- val expected = "http://mapbox.cn/path/of/no/return.pbf?offline=true"
- val actual = HttpRequestUrl.buildResourceUrl("mapbox.cn", "http://mapbox.cn/path/of/no/return.pbf", 0, true)
- assertEquals(expected, actual)
- }
-
- @Test
- fun testOfflineFlagInvalidHost() {
- val expected = "http://foobar.com/path/of/no/return.pbf"
- val actual = HttpRequestUrl.buildResourceUrl("foobar.com", "http://foobar.com/path/of/no/return.pbf", 0, true)
- assertEquals(expected, actual)
- }
-
- @Test
- fun testOnlineMapboxCom() {
- val expected = "http://mapbox.com/path/of/no/return.pbf?sku=foobar"
- val actual = HttpRequestUrl.buildResourceUrl("mapbox.com", "http://mapbox.com/path/of/no/return.pbf", 0, false)
- assertEquals(expected, actual)
- }
-
- @Test
- fun testOnlineMapboxCn() {
- val expected = "http://mapbox.cn/path/of/no/return.pbf?sku=foobar"
- val actual = HttpRequestUrl.buildResourceUrl("mapbox.cn", "http://mapbox.cn/path/of/no/return.pbf", 0, false)
- assertEquals(expected, actual)
- }
-
- @Test
- fun testOnlineInvalidHost() {
- val expected = "http://foobar.com/path/of/no/return.pbf"
- val actual = HttpRequestUrl.buildResourceUrl("foobar.com", "http://foobar.com/path/of/no/return.pbf", 0, false)
- assertEquals(expected, actual)
- }
-
- @After
- fun tearDown() {
- MapboxInjector.clear()
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtilTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtilTest.kt
deleted file mode 100644
index 973f242a46..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/http/HttpRequestUtilTest.kt
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.mapbox.mapboxsdk.module.http
-
-import com.mapbox.mapboxsdk.MapboxInjector
-import io.mockk.mockk
-import junit.framework.Assert.assertEquals
-import okhttp3.OkHttpClient
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.RobolectricTestRunner
-
-@RunWith(RobolectricTestRunner::class)
-class HttpRequestUtilTest {
-
- @Test
- fun replaceHttpClient() {
- MapboxInjector.inject(mockk(relaxed = true), "")
-
- assertEquals(HttpRequestImpl.DEFAULT_CLIENT, HttpRequestImpl.client)
-
- val httpMock = mockk<OkHttpClient>()
- HttpRequestUtil.setOkHttpClient(httpMock)
- assertEquals("Http client should have set to the mocked client",
- httpMock,
- HttpRequestImpl.client
- )
-
- HttpRequestUtil.setOkHttpClient(null)
- assertEquals("Http client should have been reset to the default client",
- HttpRequestImpl.DEFAULT_CLIENT,
- HttpRequestImpl.client
- )
-
- MapboxInjector.clear()
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/MapEventFactoryTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/MapEventFactoryTest.java
deleted file mode 100644
index 7e97f7466c..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/MapEventFactoryTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package com.mapbox.mapboxsdk.module.telemetry;
-
-import android.os.Build;
-import android.os.Bundle;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import com.mapbox.mapboxsdk.BuildConfig;
-import com.mapbox.mapboxsdk.offline.OfflineRegion;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import static com.mapbox.mapboxsdk.module.telemetry.PerformanceEvent.PerformanceAttribute;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MapEventFactoryTest {
- private static final float FONT_SCALE = 1.f;
- private static final int BATTERY_LEVEL = 50;
- private static final String CARRIER = "carrier";
- private static final String NETWORK_TYPE = "network";
- private static final String CREATED = "2019-04-09";
- private static final boolean PLUGIN = true;
- private static final float RESOLUTION = 1024.f;
- private static final boolean WIFI = true;
- private static final String SHAPE = "shape";
- private static final Double MIN_ZOOM = 1.0;
- private static final Double MAX_ZOOM = 10.0;
- private static final String STYLE_URL = "style url";
- private static final long SIZE_OF_RESOURCES_COMPLETED = 100;
- private static final long NUMBER_OF_TILE_COMPLETED = 1000;
- private static final int STATE = OfflineRegion.STATE_ACTIVE;
- private static final String SESSION_ID = "001";
-
- private PhoneState phoneState;
- private Gson gson = new Gson();
-
- @Before
- public void setUp() {
- phoneState = new PhoneState();
- phoneState.setAccessibilityFontScale(FONT_SCALE);
- phoneState.setBatteryLevel(BATTERY_LEVEL);
- phoneState.setCarrier(CARRIER);
- phoneState.setCellularNetworkType(NETWORK_TYPE);
- phoneState.setCreated(CREATED);
- phoneState.setOrientation(PhoneState.Orientation.ORIENTATION_LANDSCAPE);
- phoneState.setPluggedIn(PLUGIN);
- phoneState.setResolution(RESOLUTION);
- phoneState.setWifi(WIFI);
- }
-
- @Test
- public void testMapLoadEvent() {
- MapLoadEvent mapLoadEvent = MapEventFactory.buildMapLoadEvent(phoneState);
- assertEquals("Android - " + Build.VERSION.RELEASE, mapLoadEvent.getOperatingSystem());
- assertEquals(Build.MODEL, mapLoadEvent.getModel());
- assertNotNull(mapLoadEvent.getUserId());
- assertEquals(BATTERY_LEVEL, mapLoadEvent.getBatteryLevel());
- assertEquals(CARRIER, mapLoadEvent.getCarrier());
- assertEquals(NETWORK_TYPE, mapLoadEvent.getCellularNetworkType());
- assertEquals(CREATED, mapLoadEvent.getCreated());
- assertEquals("Landscape", mapLoadEvent.getOrientation());
- assertEquals(BuildConfig.MAPBOX_SDK_IDENTIFIER, mapLoadEvent.getSdkIdentifier());
- assertEquals(BuildConfig.MAPBOX_SDK_VERSION, mapLoadEvent.getSdkVersion());
- assertEquals(PLUGIN, mapLoadEvent.isPluggedIn());
- assertEquals(WIFI, mapLoadEvent.isWifi());
- assertEquals(FONT_SCALE, mapLoadEvent.getAccessibilityFontScale(), 0);
- String json = gson.toJson(mapLoadEvent);
- MapLoadEvent event = gson.fromJson(json, MapLoadEvent.class);
- assertEquals(mapLoadEvent, event);
- }
-
- @Test
- public void testOfflineDownloadEndEvent() {
- OfflineDownloadEndEvent offlineDownloadEndEvent = MapEventFactory.buildOfflineDownloadCompleteEvent(phoneState,
- SHAPE, MIN_ZOOM, MAX_ZOOM, STYLE_URL, SIZE_OF_RESOURCES_COMPLETED, NUMBER_OF_TILE_COMPLETED, STATE);
- assertEquals(SHAPE, offlineDownloadEndEvent.getShapeForOfflineRegion());
- assertEquals(MIN_ZOOM, offlineDownloadEndEvent.getMinZoom());
- assertEquals(MAX_ZOOM, offlineDownloadEndEvent.getMaxZoom());
- assertEquals(STYLE_URL, offlineDownloadEndEvent.getStyleURL());
- assertEquals(SIZE_OF_RESOURCES_COMPLETED, offlineDownloadEndEvent.getSizeOfResourcesCompleted());
- assertEquals(NUMBER_OF_TILE_COMPLETED, offlineDownloadEndEvent.getNumberOfTilesCompleted());
- assertEquals(String.valueOf(STATE), offlineDownloadEndEvent.getState());
- assertEquals(CREATED, offlineDownloadEndEvent.getCreated());
- String json = gson.toJson(offlineDownloadEndEvent);
- OfflineDownloadEndEvent event = gson.fromJson(json, OfflineDownloadEndEvent.class);
- assertEquals(offlineDownloadEndEvent, event);
- }
-
- @Test
- public void testOfflineDownloadStartEvent() {
- OfflineDownloadStartEvent offlineDownloadStartEvent = MapEventFactory.buildOfflineDownloadStartEvent(phoneState,
- SHAPE, MIN_ZOOM, MAX_ZOOM, STYLE_URL);
- assertEquals(SHAPE, offlineDownloadStartEvent.getShapeForOfflineRegion());
- assertEquals(MIN_ZOOM, offlineDownloadStartEvent.getMinZoom());
- assertEquals(MAX_ZOOM, offlineDownloadStartEvent.getMaxZoom());
- assertEquals(STYLE_URL, offlineDownloadStartEvent.getStyleURL());
- assertEquals(CREATED, offlineDownloadStartEvent.getCreated());
- String json = gson.toJson(offlineDownloadStartEvent);
- OfflineDownloadStartEvent event = gson.fromJson(json, OfflineDownloadStartEvent.class);
- assertEquals(offlineDownloadStartEvent, event);
- }
-
- @Test
- public void testPerformanceEvent() {
- String nameAttribute = "nameAttribute";
- String valueAttribute = "100";
- String nameCounters = "nameCounters";
- Double valuesCounters = 1000.0;
- JsonObject metaData = new JsonObject();
- metaData.addProperty("os", "android");
- metaData.addProperty("manufacturer", Build.MANUFACTURER);
- metaData.addProperty("brand", Build.BRAND);
- metaData.addProperty("device", Build.MODEL);
- metaData.addProperty("version", Build.VERSION.RELEASE);
- metaData.addProperty("abi", Build.CPU_ABI);
- metaData.addProperty("country", Locale.getDefault().getISO3Country());
- metaData.addProperty("ram", "ram");
- metaData.addProperty("screenSize", "1000");
-
- Bundle data = mock(Bundle.class);
- ArrayList<PerformanceEvent.PerformanceAttribute<String>> attribtueList = new ArrayList<>();
- PerformanceAttribute<String> attribute = new PerformanceAttribute<>(nameAttribute, valueAttribute);
- attribtueList.add(attribute);
- ArrayList<PerformanceEvent.PerformanceAttribute<Double>> countersList = new ArrayList<>();
- PerformanceAttribute<Double> counter = new PerformanceAttribute<>(nameCounters, valuesCounters);
- countersList.add(counter);
- when(data.getString("attributes")).thenReturn(gson.toJson(attribtueList));
- when(data.getString("counters")).thenReturn(gson.toJson(countersList));
- when(data.getString("metadata")).thenReturn(metaData.toString());
- PerformanceEvent performanceEvent = MapEventFactory.buildPerformanceEvent(phoneState,
- SESSION_ID, data);
- assertEquals(CREATED, performanceEvent.getCreated());
- assertEquals(metaData.toString(), performanceEvent.getMetadata().toString());
- assertEquals(SESSION_ID, performanceEvent.getSessionId());
- List<PerformanceEvent.PerformanceAttribute<String>> attributeList = performanceEvent.getAttributes();
- assertEquals(1, attribtueList.size());
- assertEquals(attribute, attribtueList.get(0));
- List<PerformanceEvent.PerformanceAttribute<Double>> counterList = performanceEvent.getCounters();
- assertEquals(1, counterList.size());
- assertEquals(counter, counterList.get(0));
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/SchemaTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/SchemaTest.java
deleted file mode 100644
index ed0b954bff..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/module/telemetry/SchemaTest.java
+++ /dev/null
@@ -1,270 +0,0 @@
-package com.mapbox.mapboxsdk.module.telemetry;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.annotations.SerializedName;
-
-import org.apache.commons.io.IOUtils;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.GZIPInputStream;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-@Ignore("mapbox-gl-native#14691")
-public class SchemaTest {
- private static final String MAP_LOAD = "map.load";
- private static final String MAP_PERFORMANCE = "mobile.performance_trace";
- private static final String OFFLINE_DOWNLOAD_END = "map.offlineDownload.end";
- private static final String OFFLINE_DOWNLOAD_START = "map.offlineDownload.start";
- private static ArrayList<JsonObject> schemaArray;
-
- @BeforeClass
- public static void downloadSchema() throws Exception {
- unpackSchemas();
- }
-
- private static ByteArrayInputStream getFileBytes() throws IOException {
- InputStream inputStream = SchemaTest.class.getClassLoader().getResourceAsStream("mobile-event-schemas.jsonl.gz");
- byte[] byteOut = IOUtils.toByteArray(inputStream);
-
- return new ByteArrayInputStream(byteOut);
- }
-
- private static void unpackSchemas() throws IOException {
- ByteArrayInputStream bais = getFileBytes();
- GZIPInputStream gzis = new GZIPInputStream(bais);
- InputStreamReader reader = new InputStreamReader(gzis);
- BufferedReader in = new BufferedReader(reader);
-
- schemaArray = new ArrayList<>();
-
- Gson gson = new Gson();
- String readed;
- while ((readed = in.readLine()) != null) {
- JsonObject schema = gson.fromJson(readed, JsonObject.class);
- schemaArray.add(schema);
- }
- }
-
- @Test
- public void checkOfflineDownloadEndEventSize() {
- JsonObject schema = grabSchema(OFFLINE_DOWNLOAD_END);
- List<Field> fields = grabClassFields(OfflineDownloadEndEvent.class);
-
- assertEquals(schema.size(), fields.size());
- }
-
- @Test
- public void checkOfflineDownloadEndEventFields() {
- JsonObject schema = grabSchema(OFFLINE_DOWNLOAD_END);
- List<Field> fields = grabClassFields(OfflineDownloadEndEvent.class);
-
- schemaContainsFields(schema, fields);
- }
-
- @Test
- public void checkOfflineDownloadStartEventSize() {
- JsonObject schema = grabSchema(OFFLINE_DOWNLOAD_START);
- List<Field> fields = grabClassFields(OfflineDownloadStartEvent.class);
-
- assertEquals(schema.size(), fields.size());
- }
-
- @Test
- public void checkOfflineDownloadStartEventFields() {
- JsonObject schema = grabSchema(OFFLINE_DOWNLOAD_START);
- List<Field> fields = grabClassFields(OfflineDownloadStartEvent.class);
-
- schemaContainsFields(schema, fields);
- }
-
- @Test
- public void checkMapLoadEventSize() {
- JsonObject schema = grabSchema(MAP_LOAD);
- List<Field> fields = grabClassFields(MapLoadEvent.class);
-
- assertEquals(schema.size(), fields.size());
- }
-
- @Test
- public void checkMapLoadEventFields() {
- JsonObject schema = grabSchema(MAP_LOAD);
- List<Field> fields = grabClassFields(MapLoadEvent.class);
-
- schemaContainsFields(schema, fields);
- }
-
- @Test
- public void checkPerformanceEventSize() {
- JsonObject schema = grabSchema(MAP_PERFORMANCE);
- List<Field> fields = grabClassFields(PerformanceEvent.class);
-
- assertEquals(schema.size(), fields.size());
- }
-
- @Test
- public void checkPerformanceEventFields() {
- JsonObject schema = grabSchema(MAP_PERFORMANCE);
- List<Field> fields = grabClassFields(PerformanceEvent.class);
-
- schemaContainsFields(schema, fields);
- }
-
- private void schemaContainsFields(JsonObject schema, List<Field> fields) {
- int distanceRemainingCount = 0;
- int durationRemainingCount = 0;
-
- for (int i = 0; i < fields.size(); i++) {
- String thisField = String.valueOf(fields.get(i));
- String[] fieldArray = thisField.split(" ");
- String[] typeArray = fieldArray[fieldArray.length - 2].split("\\.");
- String type = typeArray[typeArray.length - 1];
-
- String[] nameArray = fieldArray[fieldArray.length - 1].split("\\.");
- String field = nameArray[nameArray.length - 1];
-
- SerializedName serializedName = fields.get(i).getAnnotation(SerializedName.class);
-
- if (serializedName != null) {
- field = serializedName.value();
- }
-
- if (field.equalsIgnoreCase("durationRemaining")) {
- durationRemainingCount++;
-
- if (durationRemainingCount > 1) {
- field = "step" + field;
- }
- }
-
- if (field.equalsIgnoreCase("distanceRemaining")) {
- distanceRemainingCount++;
-
- if (distanceRemainingCount > 1) {
- field = "step" + field;
- }
- }
-
- JsonObject thisSchema = findSchema(schema, field);
- assertNotNull(thisSchema);
-
- if (thisSchema.has("type")) {
- typesMatch(thisSchema, type);
- }
- }
- }
-
- private JsonObject findSchema(JsonObject schema, String field) {
- JsonObject thisSchema = schema.getAsJsonObject(field);
-
- return thisSchema;
- }
-
- private void typesMatch(JsonObject schema, String type) {
- if (type.equalsIgnoreCase("int") || type.equalsIgnoreCase("integer")
- || type.equalsIgnoreCase("double") || type.equalsIgnoreCase("float")
- || type.equalsIgnoreCase("long")) {
- type = "number";
- }
-
- if (type.contains("[]") || type.equalsIgnoreCase("list")) {
- type = "array";
- }
- if (type.equalsIgnoreCase("jsonobject")) {
- type = "object";
- }
- Class<? extends JsonElement> typeClass = schema.get("type").getClass();
- JsonElement jsonElement = new JsonParser().parse(type.toLowerCase());
-
- if (typeClass == JsonPrimitive.class) {
- JsonElement typePrimitive = schema.get("type");
- assertTrue(typePrimitive.equals(jsonElement));
- } else {
- JsonArray arrayOfTypes = schema.getAsJsonArray("type");
- assertTrue(arrayOfTypes.contains(jsonElement));
- }
- }
-
- private JsonObject grabSchema(String eventName) {
- for (JsonObject thisSchema : schemaArray) {
- String name = thisSchema.get("name").getAsString();
-
- if (name.equalsIgnoreCase(eventName)) {
- Gson gson = new Gson();
- String schemaString = gson.toJson(thisSchema.get("properties"));
- JsonObject schema = gson.fromJson(thisSchema.get("properties"), JsonObject.class);
-
- if (schema.has("step")) {
- JsonObject stepJson = schema.get("step").getAsJsonObject();
- JsonObject stepProperties = stepJson.get("properties").getAsJsonObject();
-
- String stepPropertiesJson = gson.toJson(stepProperties);
- schemaString = generateStepSchemaString(stepPropertiesJson, schemaString);
-
- schema = gson.fromJson(schemaString, JsonObject.class);
- schema.remove("step");
- }
-
- schema.remove("userAgent");
- schema.remove("received");
- schema.remove("token");
- schema.remove("authorization");
- schema.remove("owner");
- schema.remove("locationAuthorization");
- schema.remove("locationEnabled");
- schema.remove("skuId");
- //temporary need to work out a solution to include this data
- schema.remove("platform");
-
- return schema;
- }
- }
-
- return null;
- }
-
- private List<Field> grabClassFields(Class aClass) {
- List<Field> fields = new ArrayList<>();
- Field[] allFields = aClass.getDeclaredFields();
- for (Field field : allFields) {
- if (Modifier.isPrivate(field.getModifiers()) && !Modifier.isStatic(field.getModifiers())) {
- fields.add(field);
- }
- }
- Field[] superFields = aClass.getSuperclass().getDeclaredFields();
- for (Field field : superFields) {
- if (Modifier.isPrivate(field.getModifiers()) && !Modifier.isStatic(field.getModifiers())) {
- fields.add(field);
- }
- }
- return fields;
- }
-
- private String generateStepSchemaString(String stepJson, String schemaString) {
- stepJson = stepJson.replace("\"distanceRemaining\"", "\"stepdistanceRemaining\"");
- stepJson = stepJson.replace("durationRemaining", "stepdurationRemaining");
- stepJson = stepJson.replaceFirst("\\{", ",");
- schemaString = schemaString.replaceAll("}$", "");
- schemaString = schemaString + stepJson;
-
- return schemaString;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
deleted file mode 100644
index fe91da8d58..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
+++ /dev/null
@@ -1,1537 +0,0 @@
-package com.mapbox.mapboxsdk.style.expressions;
-
-import android.graphics.Color;
-
-import com.mapbox.mapboxsdk.style.layers.PropertyValue;
-import com.mapbox.mapboxsdk.utils.ColorUtils;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextColor;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextFont;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.abs;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.acos;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.any;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.array;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.asin;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.at;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.atan;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.bool;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.ceil;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.coalesce;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.collator;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.concat;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.cos;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.cubicBezier;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.division;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.downcase;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.e;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.floor;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.format;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.formatEntry;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.geometryType;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.gt;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.gte;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.has;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.heatmapDensity;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.id;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.isSupportedScript;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.length;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.let;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.linear;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.ln;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.ln2;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.log10;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.log2;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.lte;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.max;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.min;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.mod;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.neq;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.not;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.object;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.pi;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.pow;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.product;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.properties;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.raw;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.resolvedLocale;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.rgba;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.round;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.sin;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.sqrt;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.step;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.subtract;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.sum;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.switchCase;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.tan;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.toBool;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.toRgba;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.typeOf;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.upcase;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.var;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
-import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
-import static junit.framework.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Expression unit tests that validate the expression output with the expected Object[]array representation.
- */
-@RunWith(RobolectricTestRunner.class)
-public class ExpressionTest {
-
- @Test
- public void testPropertyValueIsExpression() {
- PropertyValue<?> property = lineWidth(Expression.get("width"));
- assertTrue(property.isExpression());
- }
-
- @Test
- public void testPropertyValueEqualsExpression() {
- PropertyValue<?> property = lineWidth(Expression.get("width"));
- assertEquals(Expression.get("width"), property.getExpression());
- }
-
- @Test
- public void testRgb() throws Exception {
- Object[] expected = new Object[] {"rgb", 0f, 0f, 0f};
- Object[] actual = rgb(literal(0), literal(0), literal(0)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testRgbLiteral() throws Exception {
- Object[] expected = new Object[] {"rgb", 0f, 0f, 0f};
- Object[] actual = rgb(0, 0, 0).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testRgba() throws Exception {
- Object[] expected = new Object[] {"rgba", 0f, 0f, 0f, 1f};
- Object[] actual = rgba(literal(0), literal(0), literal(0), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testRgbaLiteral() throws Exception {
- Object[] expected = new Object[] {"rgba", 0f, 0f, 0f, 1f};
- Object[] actual = rgba(0, 0, 0, 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testToRgba() throws Exception {
- Object[] expected = new Object[] {"to-rgba", new Object[] {"to-color", "rgba(255, 0, 0, 1)"}};
- Object[] actual = toRgba(toColor(literal(ColorUtils.colorToRgbaString(Color.RED)))).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testEq() throws Exception {
- Object[] expected = new Object[] {"==", 1f, 1f};
- Object[] actual = eq(literal(1), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testEqLiteral() throws Exception {
- Object[] expected = new Object[] {"==", 1f, 1f};
- Object[] actual = eq(literal(1), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testEqExpression() throws Exception {
- Object[] expected = new Object[] {"==", new Object[] {"get", "hello"}, 1f};
- Object[] actual = eq(get("hello"), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testNeq() throws Exception {
- Object[] expected = new Object[] {"!=", 0f, 1f};
- Object[] actual = neq(literal(0), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testNeqLiteral() throws Exception {
- Object[] expected = new Object[] {"!=", 0f, 1f};
- Object[] actual = neq(literal(0), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testNeqExpression() throws Exception {
- Object[] expected = new Object[] {"!=", new Object[] {"get", "hello"}, 1f};
- Object[] actual = neq(get("hello"), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGt() throws Exception {
- Object[] expected = new Object[] {">", 0f, 1f};
- Object[] actual = gt(literal(0), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGtLiteral() throws Exception {
- Object[] expected = new Object[] {">", 0f, 1f};
- Object[] actual = gt(literal(0), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGtExpression() throws Exception {
- Object[] expected = new Object[] {">", new Object[] {"get", "hello"}, 1f};
- Object[] actual = gt(get("hello"), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLt() throws Exception {
- Object[] expected = new Object[] {"<", 1f, 0f};
- Object[] actual = lt(literal(1), literal(0)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLtLiteral() throws Exception {
- Object[] expected = new Object[] {"<", 1f, 0f};
- Object[] actual = lt(literal(1), 0).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLtExpression() throws Exception {
- Object[] expected = new Object[] {"<", new Object[] {"get", "hello"}, 1f};
- Object[] actual = lt(get("hello"), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGte() throws Exception {
- Object[] expected = new Object[] {">=", 1f, 1f};
- Object[] actual = gte(literal(1), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGteLiteral() throws Exception {
- Object[] expected = new Object[] {">=", 1f, 1f};
- Object[] actual = gte(literal(1), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGteExpression() throws Exception {
- Object[] expected = new Object[] {">=", new Object[] {"get", "hello"}, 1f};
- Object[] actual = gte(get("hello"), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLte() throws Exception {
- Object[] expected = new Object[] {"<=", 1f, 1f};
- Object[] actual = lte(literal(1), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLteExpression() throws Exception {
- Object[] expected = new Object[] {"<=", new Object[] {"get", "hello"}, 1f};
- Object[] actual = lte(get("hello"), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLteLiteral() throws Exception {
- Object[] expected = new Object[] {"<=", 1f, 1f};
- Object[] actual = lte(literal(1), 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAll() throws Exception {
- Object[] expected = new Object[] {"all", true, true, true};
- Object[] actual = all(literal(true), literal(true), literal(true)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAny() throws Exception {
- Object[] expected = new Object[] {"any", true, false, false};
- Object[] actual = any(literal(true), literal(false), literal(false)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testNot() throws Exception {
- Object[] expected = new Object[] {"!", false};
- Object[] actual = not(literal(false)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testNotLiteral() throws Exception {
- Object[] expected = new Object[] {"!", false};
- Object[] actual = not(false).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSwitchCase() throws Exception {
- Object[] expectedCaseOneGet = new Object[] {"get", "key1"};
- Object[] expectedCaseOne = new Object[] {"==", expectedCaseOneGet, "value1"};
- Object[] expectedCaseTwoGet = new Object[] {"get", "key2"};
- Object[] expectedCaseTwo = new Object[] {"!=", expectedCaseTwoGet, "value2"};
- Object[] expected = new Object[] {"case", expectedCaseOne, expectedCaseTwo};
-
- Object[] actual = switchCase(
- eq(get(literal("key1")), literal("value1")),
- neq(get(literal("key2")), literal("value2"))
- ).toArray();
-
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSwitchCaseLiteral() throws Exception {
- Object[] expectedCaseOneGet = new Object[] {"get", "key1"};
- Object[] expectedCaseOne = new Object[] {"==", expectedCaseOneGet, "value1"};
- Object[] expectedCaseTwoGet = new Object[] {"get", "key2"};
- Object[] expectedCaseTwo = new Object[] {"!=", expectedCaseTwoGet, "value2"};
- Object[] expected = new Object[] {"case", expectedCaseOne, expectedCaseTwo};
-
- Object[] actual = switchCase(
- eq(get("key1"), literal("value1")),
- neq(get("key2"), literal("value2"))
- ).toArray();
-
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testMatch() throws Exception {
- String input = "input";
- String[] labels = new String[] {"a", "b", "c"};
- String[] outputs = new String[] {"1", "2", "3"};
- String defaultOutput = "0";
-
- Object[] expected = new Object[] {"match", input,
- labels[0], outputs[0],
- labels[1], outputs[1],
- labels[2], outputs[2],
- defaultOutput};
-
- Object[] actual = match(literal(input),
- literal(labels[0]), literal(outputs[0]),
- literal(labels[1]), literal(outputs[1]),
- literal(labels[2]), literal(outputs[2]),
- literal(defaultOutput)
- ).toArray();
-
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testMatchWithStops() throws Exception {
- String input = "input";
- String[] labels = new String[] {"a", "b", "c"};
- String[] outputs = new String[] {"1", "2", "3"};
- String defaultOutput = "0";
-
- Object[] expected = new Object[] {"match", input,
- labels[0], outputs[0],
- labels[1], outputs[1],
- labels[2], outputs[2],
- defaultOutput};
-
- Object[] actual = match(literal(input), literal(defaultOutput),
- stop(labels[0], outputs[0]),
- stop(labels[1], outputs[1]),
- stop(labels[2], outputs[2]))
- .toArray();
-
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCoalesce() throws Exception {
- Object[] expectedGetOne = new Object[] {"get", "invalidKey"};
- Object[] expectedGetTwo = new Object[] {"get", "validKey"};
- Object[] expected = new Object[] {"coalesce", expectedGetOne, expectedGetTwo};
-
- Object[] actual = coalesce(
- get(literal("invalidKey")),
- get(literal("validKey"))
- ).toArray();
-
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCoalesceLiteral() throws Exception {
- Object[] expectedGetOne = new Object[] {"get", "invalidKey"};
- Object[] expectedGetTwo = new Object[] {"get", "validKey"};
- Object[] expected = new Object[] {"coalesce", expectedGetOne, expectedGetTwo};
-
- Object[] actual = coalesce(
- get("invalidKey"),
- get("validKey")
- ).toArray();
-
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testProperties() throws Exception {
- Object[] expected = new Object[] {"properties"};
- Object[] actual = properties().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGeometryType() throws Exception {
- Object[] expected = new Object[] {"geometry-type"};
- Object[] actual = geometryType().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testId() throws Exception {
- Object[] expected = new Object[] {"id"};
- Object[] actual = id().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testHeatmapDensity() throws Exception {
- Object[] expected = new Object[] {"heatmap-density"};
- Object[] actual = heatmapDensity().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAt() throws Exception {
- Object[] expected = new Object[] {"at", 3f, new Object[] {"literal", new Object[] {"one", "two"}}};
- Object[] actual = at(literal(3), literal(new Object[] {"one", "two"})).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAtLiteral() throws Exception {
- Object[] expected = new Object[] {"at", 3f, new Object[] {"literal", new Object[] {"one", "two"}}};
- Object[] actual = at(3, literal(new Object[] {"one", "two"})).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAtExpression() throws Exception {
- Object[] expected = new Object[] {"at", 3f, new Object[] {"properties"}};
- Object[] actual = at(literal(3), properties()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGet() throws Exception {
- Object[] expected = new Object[] {"get", "key"};
- Object[] actual = get(literal("key")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGetLiteral() throws Exception {
- Object[] expected = new Object[] {"get", "key"};
- Object[] actual = get("key").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGetObject() throws Exception {
- Object[] expected = new Object[] {"get", "key", new Object[] {"properties"}};
- Object[] actual = get(literal("key"), properties()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testGetObjectLiteral() throws Exception {
- Object[] expected = new Object[] {"get", "key", new Object[] {"properties"}};
- Object[] actual = get("key", properties()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testHas() throws Exception {
- Object[] expected = new Object[] {"has", "key"};
- Object[] actual = has(literal("key")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testHasLiteral() throws Exception {
- Object[] expected = new Object[] {"has", "key"};
- Object[] actual = has("key").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testHasObject() throws Exception {
- Object[] expected = new Object[] {"has", "key", new Object[] {"properties"}};
- Object[] actual = has(literal("key"), properties()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testHasObjectLiteral() throws Exception {
- Object[] expected = new Object[] {"has", "key", new Object[] {"properties"}};
- Object[] actual = has("key", properties()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testHasExpression() throws Exception {
- Object[] expected = new Object[] {"has", new Object[] {"get", "key"}, new Object[] {"properties"}};
- Object[] actual = has(get(literal("key")), properties()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testHasExpressionLiteral() throws Exception {
- Object[] expected = new Object[] {"has", new Object[] {"get", "key"}, new Object[] {"properties"}};
- Object[] actual = has(get("key"), properties()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLength() throws Exception {
- Object[] expected = new Object[] {"length", "key"};
- Object[] actual = length(literal("key")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLengthLiteral() throws Exception {
- Object[] expected = new Object[] {"length", "key"};
- Object[] actual = length("key").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLengthExpression() throws Exception {
- Object[] expected = new Object[] {"length", new Object[] {"get", "key"}};
- Object[] actual = length(get(literal("key"))).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLn2() throws Exception {
- Object[] expected = new Object[] {"ln2"};
- Object[] actual = ln2().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testPi() throws Exception {
- Object[] expected = new Object[] {"pi"};
- Object[] actual = pi().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testE() throws Exception {
- Object[] expected = new Object[] {"e"};
- Object[] actual = e().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSum() throws Exception {
- Object[] expected = new Object[] {"+", 1f, 2f};
- Object[] actual = sum(literal(1), literal(2)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSumLiteral() throws Exception {
- Object[] expected = new Object[] {"+", 1f, 2f};
- Object[] actual = sum(1, 2).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testProduct() throws Exception {
- Object[] expected = new Object[] {"*", 1f, 2f};
- Object[] actual = product(literal(1), literal(2)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testProductLiteral() throws Exception {
- Object[] expected = new Object[] {"*", 1f, 2f};
- Object[] actual = product(1, 2).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSubtract() throws Exception {
- Object[] expected = new Object[] {"-", 2f, 1f};
- Object[] actual = subtract(literal(2), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSubtractLiteral() throws Exception {
- Object[] expected = new Object[] {"-", 2f, 1f};
- Object[] actual = subtract(2, 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testDivision() throws Exception {
- Object[] expected = new Object[] {"/", 2f, 1f};
- Object[] actual = division(literal(2), literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testDivisionLiteral() throws Exception {
- Object[] expected = new Object[] {"/", 2f, 1f};
- Object[] actual = division(2, 1).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testDivisionWithNestedGet() throws Exception {
- Object nestedGet = new Object[] {"get", "key"};
- Object[] expected = new Object[] {"/", 2f, nestedGet};
- Object[] actual = division(literal(2), get(literal("key"))).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testMod() throws Exception {
- Object[] expected = new Object[] {"%", 1f, 3f};
- Object[] actual = mod(literal(1), literal(3)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testModLiteral() throws Exception {
- Object[] expected = new Object[] {"%", 1f, 3f};
- Object[] actual = mod(1, 3).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testPow() throws Exception {
- Object[] expected = new Object[] {"^", 2f, 3f};
- Object[] actual = pow(literal(2), literal(3)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testPowLiteral() throws Exception {
- Object[] expected = new Object[] {"^", 2f, 3f};
- Object[] actual = pow(2, 3).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSqrt() throws Exception {
- Object[] expected = new Object[] {"sqrt", 4f};
- Object[] actual = sqrt(literal(4)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSqrtLiteral() throws Exception {
- Object[] expected = new Object[] {"sqrt", 4f};
- Object[] actual = sqrt(4).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLog10() throws Exception {
- Object[] expected = new Object[] {"log10", 10f};
- Object[] actual = log10(literal(10f)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLog10Literal() throws Exception {
- Object[] expected = new Object[] {"log10", 10f};
- Object[] actual = log10(10).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLn() throws Exception {
- Object[] expected = new Object[] {"ln", 2f};
- Object[] actual = ln(literal(2)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLnLiteral() throws Exception {
- Object[] expected = new Object[] {"ln", 2f};
- Object[] actual = ln(2).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLog2() throws Exception {
- Object[] expected = new Object[] {"log2", 16f};
- Object[] actual = log2(literal(16)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLog2Literal() throws Exception {
- Object[] expected = new Object[] {"log2", 16f};
- Object[] actual = log2(16).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSin() throws Exception {
- Object[] expected = new Object[] {"sin", 45f};
- Object[] actual = sin(literal(45)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testSinLiteral() throws Exception {
- Object[] expected = new Object[] {"sin", 45f};
- Object[] actual = sin(45).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCos() throws Exception {
- Object[] expected = new Object[] {"cos", 45f};
- Object[] actual = cos(literal(45)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCosLiteral() throws Exception {
- Object[] expected = new Object[] {"cos", 45f};
- Object[] actual = cos(45).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testTan() throws Exception {
- Object[] expected = new Object[] {"tan", 45f};
- Object[] actual = tan(literal(45)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testTanLiteral() throws Exception {
- Object[] expected = new Object[] {"tan", 45f};
- Object[] actual = tan(45).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAsin() throws Exception {
- Object[] expected = new Object[] {"asin", 45f};
- Object[] actual = asin(literal(45)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAsinLiteral() throws Exception {
- Object[] expected = new Object[] {"asin", 45f};
- Object[] actual = asin(45).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAcos() throws Exception {
- Object[] expected = new Object[] {"acos", 45f};
- Object[] actual = acos(literal(45)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAcosLiteral() throws Exception {
- Object[] expected = new Object[] {"acos", 45f};
- Object[] actual = acos(45).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAtan() throws Exception {
- Object[] expected = new Object[] {"atan", 45f};
- Object[] actual = atan(literal(45)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAtanLiteral() throws Exception {
- Object[] expected = new Object[] {"atan", 45f};
- Object[] actual = atan(45).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testMin() throws Exception {
- Object[] expected = new Object[] {"min", 0f, 1f, 2f, 3f};
- Object[] actual = min(literal(0), literal(1), literal(2), literal(3)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testMinLiteral() throws Exception {
- Object[] expected = new Object[] {"min", 0f, 1f, 2f, 3f};
- Object[] actual = min(0, 1, 2, 3).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testMax() throws Exception {
- Object[] expected = new Object[] {"max", 0f, 1f, 2f, 3f};
- Object[] actual = max(literal(0), literal(1), literal(2), literal(3)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testMaxLiteral() throws Exception {
- Object[] expected = new Object[] {"max", 0f, 1f, 2f, 3f};
- Object[] actual = max(0, 1, 2, 3).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testUpcase() throws Exception {
- Object[] expected = new Object[] {"upcase", "string"};
- Object[] actual = upcase(literal("string")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testUpcaseLiteral() throws Exception {
- Object[] expected = new Object[] {"upcase", "string"};
- Object[] actual = upcase("string").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testDowncase() throws Exception {
- Object[] expected = new Object[] {"downcase", "string"};
- Object[] actual = downcase(literal("string")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testDowncaseLiteral() throws Exception {
- Object[] expected = new Object[] {"downcase", "string"};
- Object[] actual = downcase("string").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testConcat() throws Exception {
- Object[] expected = new Object[] {"concat", "foo", "bar"};
- Object[] actual = concat(literal("foo"), literal("bar")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testConcatLiteral() throws Exception {
- Object[] expected = new Object[] {"concat", "foo", "bar"};
- Object[] actual = concat("foo", "bar").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testArray() throws Exception {
- Object[] get = new Object[] {"get", "keyToArray"};
- Object[] expected = new Object[] {"array", get};
- Object[] actual = array(get(literal("keyToArray"))).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testArrayLiteral() throws Exception {
- Object[] get = new Object[] {"get", "keyToArray"};
- Object[] expected = new Object[] {"array", get};
- Object[] actual = array(get("keyToArray")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testTypeOf() throws Exception {
- Object[] expected = new Object[] {"typeof", "value"};
- Object[] actual = typeOf(literal("value")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testString() throws Exception {
- Object[] expected = new Object[] {"string", "value"};
- Object[] actual = string(literal("value")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testNumber() throws Exception {
- Object[] expected = new Object[] {"number", 1f};
- Object[] actual = number(literal(1)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testBool() throws Exception {
- Object[] expected = new Object[] {"boolean", true};
- Object[] actual = bool(literal(true)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testObject() throws Exception {
- Object object = new Object();
- Object[] expected = new Object[] {"object", object};
- Object[] actual = object(literal(object)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testToString() throws Exception {
- Object[] expected = new Object[] {"to-string", 3f};
- Object[] actual = Expression.toString(literal(3)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testToNumber() throws Exception {
- Object[] expected = new Object[] {"to-number", "3"};
- Object[] actual = toNumber(literal("3")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testToBool() throws Exception {
- Object[] expected = new Object[] {"to-boolean", "true"};
- Object[] actual = toBool(literal("true")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testToColor() throws Exception {
- Object[] expected = new Object[] {"to-color", "value"};
- Object[] actual = toColor(literal("value")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLet() throws Exception {
- Object[] expected = new Object[] {"let", "letName", "value"};
- Object[] actual = let(literal("letName"), literal("value")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testVar() throws Exception {
- Object[] expected = new Object[] {"var", "letName"};
- Object[] actual = var(literal("letName")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testVarLiteral() throws Exception {
- Object[] expected = new Object[] {"var", "letName"};
- Object[] actual = var("letName").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testVarExpression() throws Exception {
- Object[] expected = new Object[] {"var", new Object[] {"get", "letName"}};
- Object[] actual = var(get(literal("letName"))).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testVarExpressionLiteral() throws Exception {
- Object[] expected = new Object[] {"var", new Object[] {"get", "letName"}};
- Object[] actual = var(get("letName")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testZoom() throws Exception {
- Object[] expected = new Object[] {"zoom"};
- Object[] actual = zoom().toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testStepBasic() throws Exception {
- Object[] expected = new Object[] {"step", 12f, 11f, 0f, 111f, 1f, 1111f};
- Object[] actual = step(literal(12), literal(11), literal(0), literal(111), literal(1), literal(1111)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testStepBasicLiteral() throws Exception {
- Object[] expected = new Object[] {"step", new Object[] {"get", "line-width"}, 11f, 0f, 111f, 1f, 1111f};
- Object[] actual = step(get("line-width"), literal(11), stop(0, 111), stop(1, 1111)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testStepExpression() throws Exception {
- Object[] input = new Object[] {"get", "key"};
- Object[] number = new Object[] {"to-number", input};
- Object[] expected = new Object[] {"step", number, 11f, 0f, 111f, 1f, 1111f};
- Object[] actual = step(toNumber(get(literal("key"))),
- literal(11), literal(0), literal(111), literal(1), literal(1111)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testStepExpressionLiteral() throws Exception {
- Object[] input = new Object[] {"get", "key"};
- Object[] number = new Object[] {"to-number", input};
- Object[] expected = new Object[] {"step", number, 11f, 0f, 111f, 1f, 1111f};
- Object[] actual = step(toNumber(get("key")), literal(11), stop(0, 111), stop(1, 1111)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLinear() throws Exception {
- Object[] expected = new Object[] {"interpolate", new Object[] {"linear"}, 12f, 0f, 1f, 1f, 2f, 2f, 3f};
- Object[] actual = interpolate(
- linear(), literal(12),
- literal(0), literal(1),
- literal(1), literal(2),
- literal(2), literal(3))
- .toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLinearStops() throws Exception {
- Object[] expected = new Object[] {"interpolate", new Object[] {"linear"}, 12f, 0f, 1f, 1f, 2f, 2f, 3f};
- Object[] actual = interpolate(linear(), literal(12), stop(0, 1), stop(1, 2), stop(2, 3)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testExponential() throws Exception {
- Object[] exponential = new Object[] {"exponential", 12f};
- Object[] get = new Object[] {"get", "x"};
- Object[] expected = new Object[] {"interpolate", exponential, get, 0f, 100f, 200f};
- Object[] actual = interpolate(exponential(literal(12)),
- get(literal("x")), literal(0), literal(100), literal(200)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testExponentialLiteral() throws Exception {
- Object[] exponential = new Object[] {"exponential", 12f};
- Object[] get = new Object[] {"get", "x"};
- Object[] expected = new Object[] {"interpolate", exponential, get, 0f, 100f, 100f, 200f};
- Object[] actual = interpolate(exponential(12), get("x"), stop(0, 100), stop(100, 200)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testExponentialExpressionLiteral() throws Exception {
- Object[] getX = new Object[] {"get", "x"};
- Object[] exponential = new Object[] {"exponential", getX};
- Object[] getY = new Object[] {"get", "y"};
- Object[] expected = new Object[] {"interpolate", exponential, getY, 0f, 100f, 100f, 200f};
- Object[] actual = interpolate(exponential(get("x")), get("y"), stop(0, 100), stop(100, 200)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCubicBezier() throws Exception {
- Object[] cubicBezier = new Object[] {"cubic-bezier", 1f, 1f, 1f, 1f};
- Object[] get = new Object[] {"get", "x"};
- Object[] expected = new Object[] {"interpolate", cubicBezier, get, 0f, 100f, 100f, 200f};
- Object[] actual = interpolate(cubicBezier(literal(1), literal(1), literal(1), literal(1)),
- get(literal("x")), literal(0), literal(100), literal(100), literal(200)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCubicBezierLiteral() throws Exception {
- Object[] cubicBezier = new Object[] {"cubic-bezier", 1f, 1f, 1f, 1f};
- Object[] get = new Object[] {"get", "x"};
- Object[] expected = new Object[] {"interpolate", cubicBezier, get, 0f, 100f, 100f, 200f};
- Object[] actual = interpolate(cubicBezier(1, 1, 1, 1), get("x"), stop(0, 100), stop(100, 200)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCubicBezierExpression() throws Exception {
- Object[] getX = new Object[] {"get", "x"};
- Object[] getY = new Object[] {"get", "y"};
- Object[] getZ = new Object[] {"get", "z"};
- Object[] cubicBezier = new Object[] {"cubic-bezier", getZ, 1f, getY, 1f};
- Object[] expected = new Object[] {"interpolate", cubicBezier, getX, 0f, 100f, 200f};
- Object[] actual = interpolate(cubicBezier(get(literal("z")), literal(1),
- get(literal("y")), literal(1)), get(literal("x")), literal(0), literal(100), literal(200)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCubicBezierExpressionLiteral() throws Exception {
- Object[] getX = new Object[] {"get", "x"};
- Object[] getY = new Object[] {"get", "y"};
- Object[] getZ = new Object[] {"get", "z"};
- Object[] cubicBezier = new Object[] {"cubic-bezier", getZ, 1f, getY, 1f};
- Object[] expected = new Object[] {"interpolate", cubicBezier, getX, 0f, 100f, 100f, 200f};
- Object[] actual = interpolate(cubicBezier(get("z"), literal(1), get("y"),
- literal(1)), get("x"), stop(0, 100), stop(100, 200)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testExpressionConcatToString() throws Exception {
- String expected = "[\"concat\", \"foo\", \"bar\"]";
- String actual = concat(literal("foo"), literal("bar")).toString();
- assertEquals("toString should match", expected, actual);
- }
-
- @Test
- public void testExpressionMinToString() throws Exception {
- String expected = "[\"min\", 0.0, 1.0, 2.0, 3.0]";
- String actual = min(0, 1, 2, 3).toString();
- assertEquals("toString should match", expected, actual);
- }
-
- @Test
- public void testExpressionExponentialToString() throws Exception {
- String expected = "[\"interpolate\", [\"cubic-bezier\", 1.0, 1.0, 1.0, 1.0],"
- + " [\"get\", \"x\"], 0.0, 100.0, 100.0, 200.0]";
- String actual = interpolate(cubicBezier(literal(1), literal(1), literal(1), literal(1)),
- get(literal("x")), literal(0), literal(100), literal(100), literal(200)).toString();
- assertEquals("toString should match", expected, actual);
- }
-
- @Test
- public void testLiteralArray() throws Exception {
- Object[] array = new Object[] {1, "text"};
- Object[] expected = new Object[] {"literal", array};
- Object[] actual = literal(array).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testLiteralArrayString() throws Exception {
- Object[] array = new Object[] {1, "text"};
- String expected = "[\"literal\", [1, \"text\"]]";
- String actual = literal(array).toString();
- assertEquals("literal array should match", expected, actual);
- }
-
- @Test
- public void testLiteralPrimitiveArrayConversion() throws Exception {
- float[] array = new float[] {0.2f, 0.5f};
- Object[] expected = new Object[] {"literal", new Object[] {0.2f, 0.5f}};
- Object[] actual = literal(array).toArray();
- assertEquals("primitive array should be converted", expected, actual);
- }
-
- @Test
- public void testColorConversion() {
- Expression greenColor = color(0xFF00FF00);
- Object[] expected = new Object[] {"rgba", 0f, 255f, 0f, 1f};
- assertTrue("expression should match", Arrays.deepEquals(expected, greenColor.toArray()));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testThrowIllegalArgumentExceptionForPropertyValueLiteral() {
- Expression expression = interpolate(exponential(1f), zoom(),
- stop(17f, lineOpacity(1f)),
- stop(16.5f, lineOpacity(0.5f)),
- stop(16f, lineOpacity(0f))
- );
- expression.toArray();
- }
-
- @Test
- public void testRound() {
- Object[] expected = new Object[] {"round", 2.2f};
- Object[] actual = round(2.2f).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testRoundLiteral() {
- Object[] expected = new Object[] {"round", 2.2f};
- Object[] actual = round(literal(2.2f)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAbs() {
- Object[] expected = new Object[] {"abs", -2.2f};
- Object[] actual = abs(-2.2f).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testAbsLiteral() {
- Object[] expected = new Object[] {"abs", -2.2f};
- Object[] actual = abs(literal(-2.2f)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCeil() {
- Object[] expected = new Object[] {"ceil", 2.2f};
- Object[] actual = ceil(2.2f).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testCeilLiteral() {
- Object[] expected = new Object[] {"ceil", 2.2f};
- Object[] actual = ceil(literal(2.2f)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testFloor() {
- Object[] expected = new Object[] {"floor", 2.2f};
- Object[] actual = floor(2.2f).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testFloorLiteral() {
- Object[] expected = new Object[] {"floor", 2.2f};
- Object[] actual = floor(literal(2.2f)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testRawEmpty() {
- String raw = "[\"get\", ]";
- Expression expected = get("");
- assertEquals("expressions should match", raw(raw), expected);
-
- raw = "[\"get\", key]";
- expected = get("key");
- assertEquals("expressions should match", raw(raw), expected);
- }
-
- @Test
- public void testRawAndroidColors() {
- Expression expected = interpolate(linear(), zoom(),
- stop(12, step(get("stroke-width"),
- color(Color.BLACK),
- stop(1f, color(Color.RED)),
- stop(2f, color(Color.WHITE)),
- stop(3f, color(Color.BLUE))
- )),
- stop(15, step(get("stroke-width"),
- color(Color.BLACK),
- stop(1f, color(Color.YELLOW)),
- stop(2f, color(Color.LTGRAY)),
- stop(3f, color(Color.CYAN))
- )),
- stop(18, step(get("stroke-width"),
- color(Color.BLACK),
- stop(1f, color(Color.WHITE)),
- stop(2f, color(Color.GRAY)),
- stop(3f, color(Color.GREEN))
- ))
- );
- assertEquals("expressions should match", expected, raw(expected.toString()));
- }
-
- @Test
- public void testRawRgbaColor() {
- Expression expected = interpolate(
- exponential(2f), zoom(),
- literal(5f), literal("rgba(0, 0, 0, 1)"),
- literal(10.5f), literal("rgb(255, 0, 0)"),
- literal(15), color(Color.GREEN),
- literal(20), literal(ColorUtils.colorToRgbaString(Color.BLUE)));
- assertEquals("expressions should match", expected, raw(expected.toString()));
- }
-
- @Test
- public void testRawMatchStrings() {
- Expression expected = match(get("property"), literal(""),
- stop("layer1", "image1"),
- stop("layer2", "image2"));
- assertEquals("expressions should match", expected, raw(expected.toString()));
- }
-
- @Test
- public void testRawMatchNumbers() {
- Expression expected = match(get("property"), literal(""),
- stop("layer1", 2),
- stop("layer2", 2.7));
- assertEquals("expressions should match", expected, raw(expected.toString()));
- }
-
- @Test
- public void testAlphaValueInColorConversion() {
- // regression test for #12198
- Expression colorExpression = color(Color.parseColor("#41FF0000")); // 25.4% alpha red
- Object[] result = colorExpression.toArray();
- assertEquals("alpha value should match", 0.254f, (Float) result[4], 0.001f);
- }
-
- @Test
- public void testAlphaValueInStringConversion() {
- String color = ColorUtils.colorToRgbaString(Color.parseColor("#41FF0000")).split(" ")[3];
- String alpha = color.substring(0, color.length() - 1);
- assertEquals("alpha value should match", 0.254f, Float.valueOf(alpha), 0.001f);
- }
-
- @Test
- public void testCollator() {
- Object[] expected = new Object[] {"collator",
- new HashMap<String, Object>() {
- {
- put("case-sensitive", true);
- put("diacritic-sensitive", true);
- put("locale", "it-IT");
- }
- }
- };
- Object[] actual = collator(true, true, Locale.ITALY).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testStringCollator() {
- String expected = "[\"collator\", {\"diacritic-sensitive\": true, \"case-sensitive\": true, \"locale\": "
- + "\"it\"}]";
- String actual = collator(true, true, Locale.ITALIAN).toString();
- assertEquals("expression should match", expected, actual);
- }
-
- @Test
- public void testResolvedLocale() {
- Object[] expected = new Object[] {"resolved-locale",
- new Object[] {"collator",
- new HashMap<String, Object>() {
- {
- put("case-sensitive", false);
- put("diacritic-sensitive", false);
- put("locale", "it");
- }
- }
- }
- };
- Object[] actual = resolvedLocale(collator(false, false, Locale.ITALIAN)).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testRawCollator() {
- Object[] expected = new Object[] {"collator",
- new HashMap<String, Object>() {
- {
- put("case-sensitive", true);
- put("diacritic-sensitive", true);
- put("locale", "it-IT");
- }
- }
- };
- Object[] actual = raw("[\"collator\", {\"diacritic-sensitive\": true, \"case-sensitive\": true, \"locale\": "
- + "\"it-IT\"}]").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testRawCollatorDoubleConversion() {
- Expression expected = collator(false, false, Locale.ITALIAN);
- Object[] actual = raw(expected.toString()).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected.toArray(), actual));
- }
-
- @Test
- public void testStringNestedCollator() {
- String expected = "[\"collator\", {\"diacritic-sensitive\": [\"==\", 2.0, 1.0], \"case-sensitive\": false,"
- + " \"locale\": \"it\"}]";
- String actual = collator(literal(false), eq(literal(2), literal(1)), literal("it")).toString();
- assertEquals("expression should match", expected, actual);
- }
-
- @Test
- public void testStringReverseConversion() {
- String expected = "[\"to-string\", [\"get\", \"name_en\"]]";
- String actual = Expression.toString(get("name_en")).toString();
- assertEquals("Reverse string conversion should match", expected, actual);
- }
-
- @Test
- public void testIsSupportedScriptLiteral() {
- Object[] expected = new Object[] {"is-supported-script", "ಗೌರವಾರ್ಥವಾಗಿ"};
- Object[] actual = isSupportedScript("ಗೌರವಾರ್ಥವಾಗಿ").toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testIsSupportedScriptExpressions() {
- Object[] expected = new Object[] {"is-supported-script", new Object[] {"get", "property_name"}};
- Object[] actual = isSupportedScript(get("property_name")).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testFormatSingleArgument() {
- Object[] expected = new Object[] {"format", "test",
- new TestableExpressionHashMap() {
- {
- put("font-scale", 1.5f);
- put("text-font", new Object[] {"literal", new String[] {"awesome"}});
- put("text-color", new Object[] {"rgb", 255f, 0f, 0f});
- }
- }
- };
- Object[] actual = format(
- formatEntry(
- literal("test"),
- formatFontScale(literal(1.5)),
- formatTextFont(literal(new String[] {"awesome"})),
- formatTextColor(rgb(255, 0, 0))
- )
- ).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- @Test
- public void testFormatMultipleArgument() {
- Object[] expected = new Object[] {
- "format",
- "test",
- new TestableExpressionHashMap() {
- {
- put("text-font", new Object[] {"literal", new String[] {"awesome"}});
- }
- },
- "test2",
- new TestableExpressionHashMap() {
- {
- put("font-scale", 1.5f);
- }
- },
- "test3",
- new TestableExpressionHashMap() {
- {
- }
- },
- "test4",
- new TestableExpressionHashMap() {
- {
- put("text-color", new Object[] {"rgb", 255f, 0f, 0f});
- }
- },
- "test5",
- new TestableExpressionHashMap() {
- {
- put("font-scale", 1.5f);
- put("text-font", new Object[] {"literal", new String[] {"awesome"}});
- put("text-color", new Object[] {"rgb", 255f, 0f, 0f});
- }
- }
- };
- Object[] actual = format(
- formatEntry(literal("test"), formatTextFont(new String[] {"awesome"})),
- formatEntry("test2", formatFontScale(1.5)),
- formatEntry(literal("test3")),
- formatEntry(literal("test4"), formatTextColor(rgb(255, 0, 0))),
- formatEntry(
- literal("test5"),
- formatFontScale(literal(1.5)),
- formatTextFont(new String[] {"awesome"}),
- formatTextColor(rgb(255, 0, 0))
- )
- ).toArray();
- assertTrue("expression should match", Arrays.deepEquals(expected, actual));
- }
-
- /**
- * This class overrides {@link java.util.AbstractMap#equals(Object)}
- * in order to correctly compare nodes values if they are arrays,
- * which is the case for {@link Expression#format(Expression.FormatEntry...)}'s "text-format" argument.
- */
- private class TestableExpressionHashMap extends HashMap<String, Object> {
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
-
- if (!(o instanceof Map)) {
- return false;
- }
- Map<?, ?> m = (Map<?, ?>) o;
- if (m.size() != size()) {
- return false;
- }
-
- try {
- for (Entry<String, Object> e : entrySet()) {
- String key = e.getKey();
- Object value = e.getValue();
- if (value == null) {
- if (!(m.get(key) == null && m.containsKey(key))) {
- return false;
- }
- } else {
- if (value instanceof Object[]) {
- // Use Arrays.deepEquals() if values are Object arrays.
- if (!Arrays.deepEquals((Object[]) value, (Object[]) m.get(key))) {
- return false;
- }
- } else {
- if (!value.equals(m.get(key))) {
- return false;
- }
- }
- }
- }
- } catch (ClassCastException unused) {
- return false;
- } catch (NullPointerException unused) {
- return false;
- }
-
- return true;
- }
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java
deleted file mode 100644
index 519124e1eb..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/telemetry/HttpTransportTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.mapbox.mapboxsdk.telemetry;
-
-import com.mapbox.android.telemetry.TelemetryUtils;
-
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-
-public class HttpTransportTest {
-
- @Test
- public void testNonAsciiUserAgent() {
-
- final String swedishUserAgent = "Sveriges Fjäll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT";
- final String asciiVersion = "Sveriges Fj?ll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT";
-
- assertEquals("asciiVersion and swedishUserAgent should match", asciiVersion,
- TelemetryUtils.toHumanReadableAscii(swedishUserAgent));
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/ColorUtilsTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/ColorUtilsTest.kt
deleted file mode 100644
index 530a08a4e5..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/ColorUtilsTest.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.mapbox.mapboxsdk.utils
-
-import android.graphics.Color
-import junit.framework.Assert
-import org.junit.Test
-
-class ColorUtilsTest {
-
- @Test
- fun rgbaToColor_decimalComponent() {
- val input = "rgba(255,128.0000952303,0,0.7)"
- val result = ColorUtils.rgbaToColor(input)
- Assert.assertEquals(Color.argb(255, 128, 0, (0.7 * 255).toInt()), result)
- }
-
- @Test
- fun rgbaToColor_decimalComponent_floor() {
- val input = "rgba(255,128.70123,0,0.7)"
- val result = ColorUtils.rgbaToColor(input)
- Assert.assertEquals(Color.argb(255, 128, 0, (0.7 * 255).toInt()), result)
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java
deleted file mode 100644
index fac69826a1..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/utils/MockParcel.java
+++ /dev/null
@@ -1,267 +0,0 @@
-package com.mapbox.mapboxsdk.utils;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.annotation.NonNull;
-
-import android.support.annotation.Nullable;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.assertArrayEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyByte;
-import static org.mockito.Matchers.anyDouble;
-import static org.mockito.Matchers.anyFloat;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class MockParcel {
-
- @Nullable
- public static Parcelable obtain(@NonNull Parcelable object) {
- return obtain(object, 0);
- }
-
- @Nullable
- public static Parcelable obtain(@NonNull Parcelable object, int describeContentsValue) {
- testDescribeContents(object, describeContentsValue);
- testParcelableArray(object);
- return testParcelable(object);
- }
-
- public static Parcelable testParcelable(@NonNull Parcelable object) {
- Parcel parcel = ParcelMocker.obtain(object);
- object.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
-
- try {
- Field field = object.getClass().getDeclaredField("CREATOR");
- field.setAccessible(true);
- Class<?> creatorClass = field.getType();
- Object fieldValue = field.get(object);
- Method myMethod = creatorClass.getDeclaredMethod("createFromParcel", Parcel.class);
- return (Parcelable) myMethod.invoke(fieldValue, parcel);
- } catch (Exception exception) {
- return null;
- }
- }
-
- public static void testParcelableArray(@NonNull Parcelable object) {
- Parcelable[] objects = new Parcelable[] {object};
- Parcel parcel = ParcelMocker.obtain(objects);
- parcel.writeParcelableArray(objects, 0);
- parcel.setDataPosition(0);
- Parcelable[] parcelableArray = parcel.readParcelableArray(object.getClass().getClassLoader());
- assertArrayEquals("parcel should match initial object", objects, parcelableArray);
- }
-
- public static void testDescribeContents(@NonNull Parcelable object, int describeContentsValue) {
- if (describeContentsValue == 0) {
- assertEquals("\nExpecting a describeContents() value of 0 for a " + object.getClass().getSimpleName()
- + " instance." + "\nYou can provide a different value for describeContentValue through the obtain method.",
- 0,
- object.describeContents());
- } else {
- assertEquals("Expecting a describeContents() value of " + describeContentsValue,
- describeContentsValue,
- object.describeContents());
- }
- }
-
- private static class ParcelMocker {
-
- public static Parcel obtain(@NonNull Parcelable target) {
- Parcel parcel = new ParcelMocker(target).getMockedParcel();
- target.writeToParcel(parcel, 0);
- parcel.setDataPosition(0);
- return parcel;
- }
-
- public static Parcel obtain(@NonNull Parcelable[] targets) {
- if (targets.length == 0) {
- throw new IllegalArgumentException("The passed argument may not be empty");
- }
- Parcel parcel = new ParcelMocker(targets[0]).getMockedParcel();
- parcel.writeParcelableArray(targets, 0);
- parcel.setDataPosition(0);
- return parcel;
- }
-
- private List<Object> objects;
- private Object object;
- private Parcel mockedParcel;
- private int position;
-
- private ParcelMocker(Object o) {
- this.object = o;
- mockedParcel = mock(Parcel.class);
- objects = new ArrayList<>();
- setupMock();
- }
-
- private Parcel getMockedParcel() {
- return mockedParcel;
- }
-
- private void setupMock() {
- setupWrites();
- setupReads();
- setupOthers();
- }
-
- private void setupWrites() {
- Answer<Void> writeValueAnswer = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object parameter = invocation.getArguments()[0];
- objects.add(parameter);
- return null;
- }
- };
- Answer<Void> writeArrayAnswer = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] parameters = (Object[]) invocation.getArguments()[0];
- objects.add(parameters.length);
- for (Object o : parameters) {
- objects.add(o);
- }
- return null;
- }
- };
- Answer<Void> writeIntArrayAnswer = new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- int[] parameters = (int[]) invocation.getArguments()[0];
- if (parameters != null) {
- objects.add(parameters.length);
- for (Object o : parameters) {
- objects.add(o);
- }
- } else {
- objects.add(-1);
- }
- return null;
- }
- };
- doAnswer(writeValueAnswer).when(mockedParcel).writeByte(anyByte());
- doAnswer(writeValueAnswer).when(mockedParcel).writeLong(anyLong());
- doAnswer(writeValueAnswer).when(mockedParcel).writeString(anyString());
- doAnswer(writeValueAnswer).when(mockedParcel).writeInt(anyInt());
- doAnswer(writeIntArrayAnswer).when(mockedParcel).writeIntArray(any(int[].class));
- doAnswer(writeValueAnswer).when(mockedParcel).writeDouble(anyDouble());
- doAnswer(writeValueAnswer).when(mockedParcel).writeFloat(anyFloat());
- doAnswer(writeValueAnswer).when(mockedParcel).writeParcelable(any(Parcelable.class), eq(0));
- doAnswer(writeArrayAnswer).when(mockedParcel).writeParcelableArray(any(Parcelable[].class), eq(0));
- }
-
- private void setupReads() {
- when(mockedParcel.readInt()).then(new Answer<Integer>() {
- @NonNull
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- return (Integer) objects.get(position++);
- }
- });
- when(mockedParcel.readByte()).thenAnswer(new Answer<Byte>() {
- @NonNull
- @Override
- public Byte answer(InvocationOnMock invocation) throws Throwable {
- return (Byte) objects.get(position++);
- }
- });
- when(mockedParcel.readLong()).thenAnswer(new Answer<Long>() {
- @NonNull
- @Override
- public Long answer(InvocationOnMock invocation) throws Throwable {
- return (Long) objects.get(position++);
- }
- });
- when(mockedParcel.readString()).thenAnswer(new Answer<String>() {
- @NonNull
- @Override
- public String answer(InvocationOnMock invocation) throws Throwable {
- return (String) objects.get(position++);
- }
- });
- when(mockedParcel.readDouble()).thenAnswer(new Answer<Double>() {
- @NonNull
- @Override
- public Double answer(InvocationOnMock invocation) throws Throwable {
- return (Double) objects.get(position++);
- }
- });
- when(mockedParcel.readFloat()).thenAnswer(new Answer<Float>() {
- @NonNull
- @Override
- public Float answer(InvocationOnMock invocation) throws Throwable {
- return (Float) objects.get(position++);
- }
- });
- when(mockedParcel.readParcelable(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Parcelable>() {
- @NonNull
- @Override
- public Parcelable answer(InvocationOnMock invocation) throws Throwable {
- return (Parcelable) objects.get(position++);
- }
- });
- when(mockedParcel.readParcelableArray(Parcelable.class.getClassLoader())).thenAnswer(new Answer<Object[]>() {
- @NonNull
- @Override
- public Object[] answer(InvocationOnMock invocation) throws Throwable {
- int size = (Integer) objects.get(position++);
- Field field = object.getClass().getDeclaredField("CREATOR");
- field.setAccessible(true);
- Class<?> creatorClass = field.getType();
- Object fieldValue = field.get(object);
- Method myMethod = creatorClass.getDeclaredMethod("newArray", int.class);
- Object[] array = (Object[]) myMethod.invoke(fieldValue, size);
- for (int i = 0; i < size; i++) {
- array[i] = objects.get(position++);
- }
- return array;
- }
- });
- when(mockedParcel.createIntArray()).then(new Answer<int[]>() {
- @Nullable
- @Override
- public int[] answer(InvocationOnMock invocation) throws Throwable {
- int size = (Integer) objects.get(position++);
- if (size == -1) {
- return null;
- }
-
- int[] array = new int[size];
- for (int i = 0; i < size; i++) {
- array[i] = (Integer) objects.get(position++);
- }
-
- return array;
- }
- });
- }
-
- private void setupOthers() {
- doAnswer(new Answer<Void>() {
- @Nullable
- @Override
- public Void answer(@NonNull InvocationOnMock invocation) throws Throwable {
- position = ((Integer) invocation.getArguments()[0]);
- return null;
- }
- }).when(mockedParcel).setDataPosition(anyInt());
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/platform/android/MapboxGLAndroidSDK/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
deleted file mode 100644
index ca6ee9cea8..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
+++ /dev/null
@@ -1 +0,0 @@
-mock-maker-inline \ No newline at end of file