Change Android package and class names away from mapbox (#1201)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart@emeel.net>
This commit is contained in:
@@ -1,321 +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.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import java.util.*
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class MapboxMapOptionsTest {
|
||||
@Test
|
||||
fun testSanity() {
|
||||
Assert.assertNotNull("should not be null", MapboxMapOptions())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDebugEnabled() {
|
||||
Assert.assertFalse(MapboxMapOptions().debugActive)
|
||||
Assert.assertTrue(MapboxMapOptions().debugActive(true).debugActive)
|
||||
Assert.assertFalse(MapboxMapOptions().debugActive(false).debugActive)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompassEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().compassEnabled(true).compassEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().compassEnabled(false).compassEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompassGravity() {
|
||||
Assert.assertEquals(
|
||||
Gravity.TOP or Gravity.END,
|
||||
MapboxMapOptions().compassGravity
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM,
|
||||
MapboxMapOptions().compassGravity(Gravity.BOTTOM).compassGravity
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
Gravity.START.toLong(),
|
||||
MapboxMapOptions().compassGravity(Gravity.BOTTOM).compassGravity.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompassMargins() {
|
||||
Assert.assertTrue(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapboxMapOptions().compassMargins(intArrayOf(0, 1, 2, 3)).compassMargins
|
||||
)
|
||||
)
|
||||
Assert.assertFalse(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapboxMapOptions().compassMargins(intArrayOf(0, 0, 0, 0)).compassMargins
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLogoEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().logoEnabled(true).logoEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().logoEnabled(false).logoEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLogoGravity() {
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM or Gravity.START,
|
||||
MapboxMapOptions().logoGravity
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM,
|
||||
MapboxMapOptions().logoGravity(Gravity.BOTTOM).logoGravity
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
Gravity.START.toLong(),
|
||||
MapboxMapOptions().logoGravity(Gravity.BOTTOM).logoGravity.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLogoMargins() {
|
||||
Assert.assertTrue(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapboxMapOptions().logoMargins(intArrayOf(0, 1, 2, 3)).logoMargins
|
||||
)
|
||||
)
|
||||
Assert.assertFalse(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapboxMapOptions().logoMargins(intArrayOf(0, 0, 0, 0)).logoMargins
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionTintColor() {
|
||||
Assert.assertEquals(-1, MapboxMapOptions().attributionTintColor)
|
||||
Assert.assertEquals(
|
||||
Color.RED,
|
||||
MapboxMapOptions().attributionTintColor(Color.RED).attributionTintColor
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().attributionEnabled(true).attributionEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().attributionEnabled(false).attributionEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionGravity() {
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM or Gravity.START,
|
||||
MapboxMapOptions().attributionGravity
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM,
|
||||
MapboxMapOptions().attributionGravity(Gravity.BOTTOM).attributionGravity
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
Gravity.START.toLong(),
|
||||
MapboxMapOptions().attributionGravity(Gravity.BOTTOM).attributionGravity.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionMargins() {
|
||||
Assert.assertTrue(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapboxMapOptions().attributionMargins(intArrayOf(0, 1, 2, 3)).attributionMargins
|
||||
)
|
||||
)
|
||||
Assert.assertFalse(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapboxMapOptions().attributionMargins(intArrayOf(0, 0, 0, 0)).attributionMargins
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMinZoom() {
|
||||
Assert.assertEquals(
|
||||
MapboxConstants.MINIMUM_ZOOM.toDouble(),
|
||||
MapboxMapOptions().minZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapboxMapOptions().minZoomPreference(5.0).minZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapboxMapOptions().minZoomPreference(5.0).minZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMaxZoom() {
|
||||
Assert.assertEquals(
|
||||
MapboxConstants.MAXIMUM_ZOOM.toDouble(),
|
||||
MapboxMapOptions().maxZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapboxMapOptions().maxZoomPreference(5.0).maxZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapboxMapOptions().maxZoomPreference(5.0).maxZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMinPitch() {
|
||||
Assert.assertEquals(
|
||||
MapboxConstants.MINIMUM_PITCH.toDouble(),
|
||||
MapboxMapOptions().minPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapboxMapOptions().minPitchPreference(5.0).minPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapboxMapOptions().minPitchPreference(5.0).minPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMaxPitch() {
|
||||
Assert.assertEquals(
|
||||
MapboxConstants.MAXIMUM_PITCH.toDouble(),
|
||||
MapboxMapOptions().maxPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapboxMapOptions().maxPitchPreference(5.0).maxPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapboxMapOptions().maxPitchPreference(5.0).maxPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTiltGesturesEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().tiltGesturesEnabled)
|
||||
Assert.assertTrue(MapboxMapOptions().tiltGesturesEnabled(true).tiltGesturesEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().tiltGesturesEnabled(false).tiltGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScrollGesturesEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().scrollGesturesEnabled)
|
||||
Assert.assertTrue(MapboxMapOptions().scrollGesturesEnabled(true).scrollGesturesEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().scrollGesturesEnabled(false).scrollGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHorizontalScrollGesturesEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().horizontalScrollGesturesEnabled)
|
||||
Assert.assertTrue(MapboxMapOptions().horizontalScrollGesturesEnabled(true).horizontalScrollGesturesEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().horizontalScrollGesturesEnabled(false).horizontalScrollGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testZoomGesturesEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().zoomGesturesEnabled)
|
||||
Assert.assertTrue(MapboxMapOptions().zoomGesturesEnabled(true).zoomGesturesEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().zoomGesturesEnabled(false).zoomGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateGesturesEnabled() {
|
||||
Assert.assertTrue(MapboxMapOptions().rotateGesturesEnabled)
|
||||
Assert.assertTrue(MapboxMapOptions().rotateGesturesEnabled(true).rotateGesturesEnabled)
|
||||
Assert.assertFalse(MapboxMapOptions().rotateGesturesEnabled(false).rotateGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCamera() {
|
||||
val position = CameraPosition.Builder().build()
|
||||
Assert.assertEquals(
|
||||
CameraPosition.Builder(position).build(),
|
||||
MapboxMapOptions().camera(position).camera
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
CameraPosition.Builder().target(LatLng(1.0, 1.0)),
|
||||
MapboxMapOptions().camera(position)
|
||||
)
|
||||
Assert.assertNull(MapboxMapOptions().camera)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPrefetchesTiles() {
|
||||
// Default value
|
||||
Assert.assertTrue(MapboxMapOptions().prefetchesTiles)
|
||||
|
||||
// Check mutations
|
||||
Assert.assertTrue(MapboxMapOptions().setPrefetchesTiles(true).prefetchesTiles)
|
||||
Assert.assertFalse(MapboxMapOptions().setPrefetchesTiles(false).prefetchesTiles)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPrefetchZoomDelta() {
|
||||
// Default value
|
||||
Assert.assertEquals(4, MapboxMapOptions().prefetchZoomDelta)
|
||||
|
||||
// Check mutations
|
||||
Assert.assertEquals(
|
||||
5,
|
||||
MapboxMapOptions().setPrefetchZoomDelta(5).prefetchZoomDelta
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCrossSourceCollisions() {
|
||||
// Default value
|
||||
Assert.assertTrue(MapboxMapOptions().crossSourceCollisions)
|
||||
|
||||
// check mutations
|
||||
Assert.assertTrue(MapboxMapOptions().crossSourceCollisions(true).crossSourceCollisions)
|
||||
Assert.assertFalse(MapboxMapOptions().crossSourceCollisions(false).crossSourceCollisions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLocalIdeographFontFamily_enabledByDefault() {
|
||||
val options = MapboxMapOptions.createFromAttributes(RuntimeEnvironment.application, null)
|
||||
Assert.assertEquals(
|
||||
MapboxConstants.DEFAULT_FONT,
|
||||
options.localIdeographFontFamily
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DELTA = 1e-15
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
package com.mapbox.mapboxsdk;
|
||||
package org.maplibre.android;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mapbox.mapboxsdk.util.TileServerOptions;
|
||||
import org.maplibre.android.util.TileServerOptions;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class MapboxInjector {
|
||||
public class MapLibreInjector {
|
||||
|
||||
private static final String FIELD_INSTANCE = "INSTANCE";
|
||||
|
||||
public static void inject(@NonNull Context context, @NonNull String apiKey,
|
||||
@NonNull TileServerOptions options) {
|
||||
Mapbox mapbox = new Mapbox(context, apiKey, options);
|
||||
MapLibre maplibre = new MapLibre(context, apiKey, options);
|
||||
try {
|
||||
Field instance = Mapbox.class.getDeclaredField(FIELD_INSTANCE);
|
||||
Field instance = MapLibre.class.getDeclaredField(FIELD_INSTANCE);
|
||||
instance.setAccessible(true);
|
||||
instance.set(mapbox, mapbox);
|
||||
instance.set(maplibre, maplibre);
|
||||
} catch (Exception exception) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class MapboxInjector {
|
||||
|
||||
public static void clear() {
|
||||
try {
|
||||
Field field = Mapbox.class.getDeclaredField(FIELD_INSTANCE);
|
||||
Field field = MapLibre.class.getDeclaredField(FIELD_INSTANCE);
|
||||
field.setAccessible(true);
|
||||
field.set(field, null);
|
||||
} catch (Exception exception) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk;
|
||||
package org.maplibre.android;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -6,9 +6,9 @@ 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 com.mapbox.mapboxsdk.utils.ConfigUtils;
|
||||
import org.maplibre.android.exceptions.MapLibreConfigurationException;
|
||||
import org.maplibre.android.maps.MapView;
|
||||
import org.maplibre.android.utils.ConfigUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -28,7 +28,7 @@ import static org.mockito.ArgumentMatchers.nullable;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class MapboxTest {
|
||||
public class MapLibreTest {
|
||||
|
||||
private Context context;
|
||||
private Context appContext;
|
||||
@@ -46,31 +46,31 @@ public class MapboxTest {
|
||||
@Test
|
||||
public void testGetApiKey() {
|
||||
final String apiKey = "pk.0000000001";
|
||||
MapboxInjector.inject(context, apiKey, ConfigUtils.getMockedOptions());
|
||||
assertSame(apiKey, Mapbox.getApiKey());
|
||||
MapLibreInjector.inject(context, apiKey, ConfigUtils.getMockedOptions());
|
||||
assertSame(apiKey, MapLibre.getApiKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplicationContext() {
|
||||
MapboxInjector.inject(context, "pk.0000000001", ConfigUtils.getMockedOptions());
|
||||
assertNotNull(Mapbox.getApplicationContext());
|
||||
MapLibreInjector.inject(context, "pk.0000000001", ConfigUtils.getMockedOptions());
|
||||
assertNotNull(MapLibre.getApplicationContext());
|
||||
assertNotEquals(context, appContext);
|
||||
assertEquals(appContext, appContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlainTokenValid() {
|
||||
assertTrue(Mapbox.isApiKeyValid("apiKey"));
|
||||
assertTrue(MapLibre.isApiKeyValid("apiKey"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyToken() {
|
||||
assertFalse(Mapbox.isApiKeyValid(""));
|
||||
assertFalse(MapLibre.isApiKeyValid(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullToken() {
|
||||
assertFalse(Mapbox.isApiKeyValid(null));
|
||||
assertFalse(MapLibre.isApiKeyValid(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,9 +83,9 @@ public class MapboxTest {
|
||||
when(context.obtainStyledAttributes(nullable(AttributeSet.class), any(int[].class), anyInt(), anyInt()))
|
||||
.thenReturn(typedArray);
|
||||
|
||||
expectedException.expect(MapboxConfigurationException.class);
|
||||
expectedException.expect(MapLibreConfigurationException.class);
|
||||
expectedException.expectMessage(
|
||||
"\nUsing MapView requires calling Mapbox.getInstance(Context context, String apiKey,"
|
||||
"\nUsing MapView requires calling MapLibre.getInstance(Context context, String apiKey,"
|
||||
+ " WellKnownTileServer wellKnownTileServer) before inflating or creating the view."
|
||||
);
|
||||
new MapView(context);
|
||||
@@ -93,6 +93,6 @@ public class MapboxTest {
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
MapboxInjector.clear();
|
||||
MapLibreInjector.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.annotations
|
||||
package org.maplibre.android.annotations
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import org.maplibre.android.maps.MapLibreMap
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -9,7 +9,7 @@ import org.mockito.Mockito
|
||||
|
||||
class AnnotationTest {
|
||||
@InjectMocks
|
||||
private val mapboxMap = Mockito.mock(MapboxMap::class.java)
|
||||
private val maplibreMap = Mockito.mock(MapLibreMap::class.java)
|
||||
private var annotation: Annotation? = null
|
||||
private val compare: Annotation = object : Annotation() {
|
||||
override fun getId(): Long {
|
||||
@@ -31,9 +31,9 @@ class AnnotationTest {
|
||||
@Test
|
||||
fun testRemove() {
|
||||
annotation!!.id = 1
|
||||
annotation!!.setMapboxMap(mapboxMap)
|
||||
annotation!!.setMapboxMap(maplibreMap)
|
||||
annotation!!.remove()
|
||||
Mockito.verify(mapboxMap, Mockito.times(1)).removeAnnotation(
|
||||
Mockito.verify(maplibreMap, Mockito.times(1)).removeAnnotation(
|
||||
annotation!!
|
||||
)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class AnnotationTest {
|
||||
fun testRemoveUnboundMapboxMap() {
|
||||
annotation!!.id = 1
|
||||
annotation!!.remove()
|
||||
Mockito.verify(mapboxMap, Mockito.times(0)).removeAnnotation(
|
||||
Mockito.verify(maplibreMap, Mockito.times(0)).removeAnnotation(
|
||||
annotation!!
|
||||
)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.annotations
|
||||
package org.maplibre.android.annotations
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import org.junit.Assert
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.mapbox.mapboxsdk.annotations
|
||||
package org.maplibre.android.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.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.maps.MapView
|
||||
import org.maplibre.android.maps.MapLibreMap
|
||||
import org.maplibre.android.maps.Projection
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.mockito.InjectMocks
|
||||
@@ -15,11 +15,11 @@ class InfoWindowTest {
|
||||
var mMapView = Mockito.mock(MapView::class.java)
|
||||
|
||||
@InjectMocks
|
||||
var mMapboxMap = Mockito.mock(MapboxMap::class.java)
|
||||
var mMapLibreMap = Mockito.mock(MapLibreMap::class.java)
|
||||
|
||||
@Test
|
||||
fun testSanity() {
|
||||
val infoWindow = InfoWindow(mMapView, mMapboxMap)
|
||||
val infoWindow = InfoWindow(mMapView, mMapLibreMap)
|
||||
Assert.assertNotNull("infoWindow should exist", infoWindow)
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ class InfoWindowTest {
|
||||
fun testBoundMarker() {
|
||||
val markerOptions = MarkerOptions()
|
||||
val marker = markerOptions.position(LatLng()).marker
|
||||
val infoWindow = InfoWindow(mMapView, mMapboxMap).setBoundMarker(marker)
|
||||
val infoWindow = InfoWindow(mMapView, mMapLibreMap).setBoundMarker(marker)
|
||||
Assert.assertEquals("marker should match", marker, infoWindow.boundMarker)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClose() {
|
||||
val infoWindow = InfoWindow(mMapView, mMapboxMap)
|
||||
val infoWindow = InfoWindow(mMapView, mMapLibreMap)
|
||||
infoWindow.close()
|
||||
Assert.assertEquals("infowindow should not be visible", false, infoWindow.isVisible)
|
||||
}
|
||||
@@ -44,9 +44,9 @@ class InfoWindowTest {
|
||||
val projection = Mockito.mock(
|
||||
Projection::class.java
|
||||
)
|
||||
Mockito.`when`(mMapboxMap.projection).thenReturn(projection)
|
||||
Mockito.`when`(mMapLibreMap.projection).thenReturn(projection)
|
||||
Mockito.`when`(projection.toScreenLocation(latLng)).thenReturn(PointF(0f, 0f))
|
||||
val infoWindow = InfoWindow(mMapView, mMapboxMap)
|
||||
val infoWindow = InfoWindow(mMapView, mMapLibreMap)
|
||||
infoWindow.open(mMapView, MarkerOptions().position(LatLng()).marker, latLng, 0, 0)
|
||||
Assert.assertEquals("infowindow should not be visible", true, infoWindow.isVisible)
|
||||
}
|
||||
@@ -57,9 +57,9 @@ class InfoWindowTest {
|
||||
val projection = Mockito.mock(
|
||||
Projection::class.java
|
||||
)
|
||||
Mockito.`when`(mMapboxMap.projection).thenReturn(projection)
|
||||
Mockito.`when`(mMapLibreMap.projection).thenReturn(projection)
|
||||
Mockito.`when`(projection.toScreenLocation(latLng)).thenReturn(PointF(0f, 0f))
|
||||
val infoWindow = InfoWindow(mMapView, mMapboxMap)
|
||||
val infoWindow = InfoWindow(mMapView, mMapLibreMap)
|
||||
infoWindow.open(mMapView, MarkerOptions().position(LatLng()).marker, latLng, 0, 0)
|
||||
infoWindow.close()
|
||||
Assert.assertEquals("infowindow should not be visible", false, infoWindow.isVisible)
|
||||
@@ -71,9 +71,9 @@ class InfoWindowTest {
|
||||
val projection = Mockito.mock(
|
||||
Projection::class.java
|
||||
)
|
||||
Mockito.`when`(mMapboxMap.projection).thenReturn(projection)
|
||||
Mockito.`when`(mMapLibreMap.projection).thenReturn(projection)
|
||||
Mockito.`when`(projection.toScreenLocation(latLng)).thenReturn(PointF(0f, 0f))
|
||||
val infoWindow = InfoWindow(mMapView, mMapboxMap)
|
||||
val infoWindow = InfoWindow(mMapView, mMapLibreMap)
|
||||
infoWindow.open(mMapView, MarkerOptions().position(latLng).marker, latLng, 0, 0)
|
||||
infoWindow.update()
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mapbox.mapboxsdk.annotations
|
||||
package org.maplibre.android.annotations
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.mapbox.mapboxsdk.exceptions.InvalidMarkerPositionException
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.utils.MockParcel
|
||||
import org.maplibre.android.exceptions.InvalidMarkerPositionException
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.utils.MockParcel
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito
|
||||
@@ -36,17 +36,17 @@ class MarkerTest {
|
||||
|
||||
@Test
|
||||
fun testTitle() {
|
||||
val markerOptions = MarkerOptions().title("Mapbox").position(LatLng())
|
||||
val markerOptions = MarkerOptions().title("MapLibre").position(LatLng())
|
||||
val marker = markerOptions.marker
|
||||
Assert.assertEquals(marker.title, "Mapbox")
|
||||
Assert.assertEquals(markerOptions.getTitle(), "Mapbox")
|
||||
Assert.assertEquals(marker.title, "MapLibre")
|
||||
Assert.assertEquals(markerOptions.getTitle(), "MapLibre")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSnippet() {
|
||||
val markerOptions = MarkerOptions().snippet("Mapbox").position(LatLng())
|
||||
val markerOptions = MarkerOptions().snippet("MapLibre").position(LatLng())
|
||||
val marker = markerOptions.marker
|
||||
Assert.assertEquals(marker.snippet, "Mapbox")
|
||||
Assert.assertEquals(marker.snippet, "MapLibre")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.annotations
|
||||
package org.maplibre.android.annotations
|
||||
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.annotations
|
||||
package org.maplibre.android.annotations
|
||||
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.attribution
|
||||
package org.maplibre.android.attribution
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
@@ -24,7 +24,7 @@ class AttributionParseTest {
|
||||
"https://www.mapbox.com/about/maps/",
|
||||
attribution.url
|
||||
)
|
||||
Assert.assertEquals("Title mapbox should match", "© Mapbox", attribution.title)
|
||||
Assert.assertEquals("Title mapbox should match", "© MapLibre", attribution.title)
|
||||
}
|
||||
1 -> {
|
||||
Assert.assertEquals(
|
||||
@@ -70,7 +70,7 @@ class AttributionParseTest {
|
||||
"https://www.mapbox.com/about/maps/",
|
||||
attribution.url
|
||||
)
|
||||
Assert.assertEquals("Title mapbox should match", "© Mapbox", attribution.title)
|
||||
Assert.assertEquals("Title mapbox should match", "© MapLibre", attribution.title)
|
||||
}
|
||||
1 -> {
|
||||
Assert.assertEquals(
|
||||
@@ -131,7 +131,7 @@ class AttributionParseTest {
|
||||
"https://www.mapbox.com/about/maps/",
|
||||
attribution.url
|
||||
)
|
||||
Assert.assertEquals("Title mapbox should match", "© Mapbox", attribution.title)
|
||||
Assert.assertEquals("Title mapbox should match", "© MapLibre", attribution.title)
|
||||
}
|
||||
1 -> {
|
||||
Assert.assertEquals(
|
||||
@@ -178,7 +178,7 @@ class AttributionParseTest {
|
||||
"https://www.mapbox.com/about/maps/",
|
||||
attribution.url
|
||||
)
|
||||
Assert.assertEquals("Title mapbox should match", "© Mapbox", attribution.title)
|
||||
Assert.assertEquals("Title mapbox should match", "© MapLibre", attribution.title)
|
||||
}
|
||||
1 -> {
|
||||
Assert.assertEquals(
|
||||
@@ -225,7 +225,7 @@ class AttributionParseTest {
|
||||
"https://www.mapbox.com/about/maps/",
|
||||
attribution.url
|
||||
)
|
||||
Assert.assertEquals("Title mapbox should match", "Mapbox", attribution.title)
|
||||
Assert.assertEquals("Title mapbox should match", "MapLibre", attribution.title)
|
||||
}
|
||||
1 -> {
|
||||
Assert.assertEquals(
|
||||
@@ -265,7 +265,7 @@ class AttributionParseTest {
|
||||
.build()
|
||||
Assert.assertEquals(
|
||||
"Attribution string should match",
|
||||
"© Mapbox / OpenStreetMap",
|
||||
"© MapLibre / OpenStreetMap",
|
||||
attributionParser.createAttributionString()
|
||||
)
|
||||
}
|
||||
@@ -279,7 +279,7 @@ class AttributionParseTest {
|
||||
.build()
|
||||
Assert.assertEquals(
|
||||
"Attribution string should match",
|
||||
"© Mapbox / © OpenStreetMap",
|
||||
"© MapLibre / © OpenStreetMap",
|
||||
attributionParser.createAttributionString()
|
||||
)
|
||||
}
|
||||
@@ -357,15 +357,15 @@ class AttributionParseTest {
|
||||
.build()
|
||||
Assert.assertEquals(
|
||||
"Attribution string should match",
|
||||
"© Mapbox / OSM / DigitalGlobe",
|
||||
"© MapLibre / OSM / DigitalGlobe",
|
||||
attributionParser.createAttributionString(true)
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val STREETS_ATTRIBUTION =
|
||||
"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">© OpenStreetMap</a> \n"
|
||||
"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© MapLibre</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">© OpenStreetMap</a> \n"
|
||||
private const val SATELLITE_ATTRIBUTION =
|
||||
"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© Mapbox</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">© OpenStreetMap</a> <a href=\"https://www.digitalglobe.com/\" target=\"_blank\">© DigitalGlobe</a>\n"
|
||||
"<a href=\"https://www.mapbox.com/about/maps/\" target=\"_blank\">© MapLibre</a> <a href=\"http://www.openstreetmap.org/about/\" target=\"_blank\">© OpenStreetMap</a> <a href=\"https://www.digitalglobe.com/\" target=\"_blank\">© DigitalGlobe</a>\n"
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.camera
|
||||
package org.maplibre.android.camera
|
||||
|
||||
import android.content.res.TypedArray
|
||||
import android.os.Parcel
|
||||
import com.mapbox.mapboxsdk.R
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory.ZoomUpdate
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory.zoomTo
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import org.maplibre.android.R
|
||||
import org.maplibre.android.camera.CameraUpdateFactory.ZoomUpdate
|
||||
import org.maplibre.android.camera.CameraUpdateFactory.zoomTo
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.constants
|
||||
package org.maplibre.android.constants
|
||||
|
||||
object AppConstant {
|
||||
const val STYLE_VERSION = 9
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.mapbox.mapboxsdk.geometry
|
||||
package org.maplibre.android.geometry
|
||||
|
||||
import com.mapbox.mapboxsdk.constants.GeometryConstants
|
||||
import com.mapbox.mapboxsdk.exceptions.InvalidLatLngBoundsException
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds.Companion.from
|
||||
import com.mapbox.mapboxsdk.geometry.LatLngBounds.Companion.world
|
||||
import com.mapbox.mapboxsdk.utils.MockParcel
|
||||
import org.maplibre.android.constants.GeometryConstants
|
||||
import org.maplibre.android.exceptions.InvalidLatLngBoundsException
|
||||
import org.maplibre.android.geometry.LatLngBounds.Companion.from
|
||||
import org.maplibre.android.geometry.LatLngBounds.Companion.world
|
||||
import org.maplibre.android.utils.MockParcel
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.geometry
|
||||
package org.maplibre.android.geometry
|
||||
|
||||
import com.mapbox.mapboxsdk.utils.MockParcel
|
||||
import org.maplibre.android.utils.MockParcel
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.geometry
|
||||
package org.maplibre.android.geometry
|
||||
|
||||
import android.location.Location
|
||||
import com.mapbox.mapboxsdk.utils.MockParcel
|
||||
import org.maplibre.android.utils.MockParcel
|
||||
import org.junit.Assert
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.geometry
|
||||
package org.maplibre.android.geometry
|
||||
|
||||
import com.mapbox.mapboxsdk.utils.MockParcel
|
||||
import org.maplibre.android.utils.MockParcel
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.geometry
|
||||
package org.maplibre.android.geometry
|
||||
|
||||
import com.mapbox.mapboxsdk.utils.MockParcel
|
||||
import org.maplibre.android.utils.MockParcel
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.hardware.Sensor
|
||||
import android.hardware.SensorEventListener
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentConstants.*
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer
|
||||
import com.mapbox.mapboxsdk.style.layers.Property
|
||||
import com.mapbox.mapboxsdk.utils.BitmapUtils
|
||||
import com.mapbox.mapboxsdk.utils.ColorUtils
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.location.LocationComponentConstants.*
|
||||
import org.maplibre.android.location.modes.RenderMode
|
||||
import org.maplibre.android.maps.Style
|
||||
import org.maplibre.android.style.expressions.Expression
|
||||
import org.maplibre.android.style.layers.Layer
|
||||
import org.maplibre.android.style.layers.Property
|
||||
import org.maplibre.android.utils.BitmapUtils
|
||||
import org.maplibre.android.utils.ColorUtils
|
||||
import io.mockk.*
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.ValueAnimator
|
||||
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.RenderMode
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap
|
||||
import com.mapbox.mapboxsdk.maps.Projection
|
||||
import org.maplibre.android.camera.CameraPosition
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.location.LocationComponentConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION
|
||||
import org.maplibre.android.location.LocationComponentConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION
|
||||
import org.maplibre.android.location.MapLibreAnimator.*
|
||||
import org.maplibre.android.location.modes.RenderMode
|
||||
import org.maplibre.android.maps.MapLibreMap
|
||||
import org.maplibre.android.maps.Projection
|
||||
import io.mockk.*
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
@@ -28,8 +28,8 @@ 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 animatorProvider: MapLibreAnimatorProvider = mockk()
|
||||
private val animatorSetProvider: MapLibreAnimatorSetProvider = mockk()
|
||||
|
||||
private val projection: Projection = mockk()
|
||||
|
||||
@@ -68,31 +68,47 @@ class LocationAnimatorCoordinatorTest {
|
||||
registerInstanceFactory { AnimationsValueChangeListener<Float> {} }
|
||||
registerInstanceFactory { AnimationsValueChangeListener<LatLng> {} }
|
||||
val floatsSlot = slot<Array<Float>>()
|
||||
val listenerSlot = slot<MapboxAnimator.AnimationsValueChangeListener<*>>()
|
||||
val listenerSlot = slot<AnimationsValueChangeListener<*>>()
|
||||
val maxFpsSlot = slot<Int>()
|
||||
every {
|
||||
animatorProvider.floatAnimator(capture(floatsSlot), capture(listenerSlot), capture(maxFpsSlot))
|
||||
} answers {
|
||||
MapboxFloatAnimator(floatsSlot.captured, listenerSlot.captured, maxFpsSlot.captured)
|
||||
MapLibreFloatAnimator(
|
||||
floatsSlot.captured,
|
||||
listenerSlot.captured,
|
||||
maxFpsSlot.captured
|
||||
)
|
||||
}
|
||||
|
||||
val latLngsSlot = slot<Array<LatLng>>()
|
||||
every {
|
||||
animatorProvider.latLngAnimator(capture(latLngsSlot), capture(listenerSlot), capture(maxFpsSlot))
|
||||
} answers {
|
||||
MapboxLatLngAnimator(latLngsSlot.captured, listenerSlot.captured, maxFpsSlot.captured)
|
||||
MapLibreLatLngAnimator(
|
||||
latLngsSlot.captured,
|
||||
listenerSlot.captured,
|
||||
maxFpsSlot.captured
|
||||
)
|
||||
}
|
||||
|
||||
val callback = slot<MapboxMap.CancelableCallback>()
|
||||
val callback = slot<MapLibreMap.CancelableCallback>()
|
||||
every {
|
||||
animatorProvider.cameraAnimator(capture(floatsSlot), capture(listenerSlot), capture(callback))
|
||||
} answers {
|
||||
MapboxCameraAnimatorAdapter(floatsSlot.captured, listenerSlot.captured, callback.captured)
|
||||
MapLibreCameraAnimatorAdapter(
|
||||
floatsSlot.captured,
|
||||
listenerSlot.captured,
|
||||
callback.captured
|
||||
)
|
||||
}
|
||||
every {
|
||||
animatorProvider.cameraAnimator(capture(floatsSlot), capture(listenerSlot), null)
|
||||
} answers {
|
||||
MapboxCameraAnimatorAdapter(floatsSlot.captured, listenerSlot.captured, null)
|
||||
MapLibreCameraAnimatorAdapter(
|
||||
floatsSlot.captured,
|
||||
listenerSlot.captured,
|
||||
null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +295,7 @@ class LocationAnimatorCoordinatorTest {
|
||||
location.longitude = 17.0
|
||||
location.bearing = 0f
|
||||
|
||||
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
|
||||
val animator = mockk<MapLibreFloatAnimator>(relaxed = true)
|
||||
every { animator.animatedValue } returns 270f
|
||||
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
|
||||
|
||||
@@ -296,7 +312,7 @@ class LocationAnimatorCoordinatorTest {
|
||||
location.longitude = 17.0
|
||||
location.bearing = 90f
|
||||
|
||||
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
|
||||
val animator = mockk<MapLibreFloatAnimator>(relaxed = true)
|
||||
every { animator.animatedValue } returns 280f
|
||||
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
|
||||
|
||||
@@ -313,7 +329,7 @@ class LocationAnimatorCoordinatorTest {
|
||||
location.longitude = 17.0
|
||||
location.bearing = 300f
|
||||
|
||||
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
|
||||
val animator = mockk<MapLibreFloatAnimator>(relaxed = true)
|
||||
every { animator.animatedValue } returns 450f
|
||||
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
|
||||
|
||||
@@ -330,7 +346,7 @@ class LocationAnimatorCoordinatorTest {
|
||||
location.longitude = 17.0
|
||||
location.bearing = 350f
|
||||
|
||||
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
|
||||
val animator = mockk<MapLibreFloatAnimator>(relaxed = true)
|
||||
every { animator.animatedValue } returns 10f
|
||||
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
|
||||
|
||||
@@ -347,7 +363,7 @@ class LocationAnimatorCoordinatorTest {
|
||||
location.longitude = 17.0
|
||||
location.bearing = 90f
|
||||
|
||||
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
|
||||
val animator = mockk<MapLibreFloatAnimator>(relaxed = true)
|
||||
every { animator.animatedValue } returns -280f
|
||||
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
|
||||
|
||||
@@ -364,7 +380,7 @@ class LocationAnimatorCoordinatorTest {
|
||||
location.longitude = 17.0
|
||||
location.bearing = 270f
|
||||
|
||||
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
|
||||
val animator = mockk<MapLibreFloatAnimator>(relaxed = true)
|
||||
every { animator.animatedValue } returns -350f
|
||||
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
|
||||
|
||||
@@ -708,7 +724,7 @@ class LocationAnimatorCoordinatorTest {
|
||||
|
||||
@Test
|
||||
fun remove_gps_animator() {
|
||||
val animator = mockk<MapboxFloatAnimator>(relaxed = true)
|
||||
val animator = mockk<MapLibreFloatAnimator>(relaxed = true)
|
||||
locationAnimatorCoordinator.animatorArray.put(ANIMATOR_LAYER_GPS_BEARING, animator)
|
||||
|
||||
locationAnimatorCoordinator.cancelAndRemoveGpsBearingAnimation()
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.content.res.TypedArray
|
||||
import android.graphics.Color
|
||||
import android.view.animation.LinearInterpolator
|
||||
import com.mapbox.mapboxsdk.R
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import org.maplibre.android.R
|
||||
import org.maplibre.android.maps.Style
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.content.res.TypedArray
|
||||
import com.mapbox.mapboxsdk.R
|
||||
import org.maplibre.android.R
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer
|
||||
import org.maplibre.android.maps.Style
|
||||
import org.maplibre.android.style.layers.Layer
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert.assertFalse
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.content.Context
|
||||
import android.location.Location
|
||||
import android.os.Looper
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition
|
||||
import com.mapbox.mapboxsdk.location.LocationComponentConstants.TRANSITION_ANIMATION_DURATION_MS
|
||||
import com.mapbox.mapboxsdk.location.engine.LocationEngine
|
||||
import com.mapbox.mapboxsdk.location.engine.LocationEngineRequest
|
||||
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 com.mapbox.mapboxsdk.maps.Style
|
||||
import com.mapbox.mapboxsdk.maps.Transform
|
||||
import org.maplibre.android.camera.CameraPosition
|
||||
import org.maplibre.android.location.LocationComponentConstants.TRANSITION_ANIMATION_DURATION_MS
|
||||
import org.maplibre.android.location.engine.LocationEngine
|
||||
import org.maplibre.android.location.engine.LocationEngineRequest
|
||||
import org.maplibre.android.location.modes.CameraMode
|
||||
import org.maplibre.android.location.modes.RenderMode
|
||||
import org.maplibre.android.maps.MapLibreMap
|
||||
import org.maplibre.android.maps.Projection
|
||||
import org.maplibre.android.maps.Style
|
||||
import org.maplibre.android.maps.Transform
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -31,7 +31,7 @@ class LocationComponentTest {
|
||||
private lateinit var locationComponentOptions: LocationComponentOptions
|
||||
|
||||
@Mock
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var maplibreMap: MapLibreMap
|
||||
|
||||
@Mock
|
||||
private lateinit var transform: Transform
|
||||
@@ -69,7 +69,7 @@ class LocationComponentTest {
|
||||
@Mock
|
||||
private lateinit var style: Style
|
||||
|
||||
private lateinit var developerAnimationListeners: List<MapboxMap.OnDeveloperAnimationListener>
|
||||
private lateinit var developerAnimationListeners: List<MapLibreMap.OnDeveloperAnimationListener>
|
||||
|
||||
private val defaultOptions: LocationComponentActivationOptions
|
||||
get() = LocationComponentActivationOptions.builder(context, style).locationEngine(locationEngine).locationEngineRequest(locationEngineRequest).locationComponentOptions(locationComponentOptions).build()
|
||||
@@ -78,8 +78,8 @@ class LocationComponentTest {
|
||||
fun before() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
developerAnimationListeners = mutableListOf()
|
||||
locationComponent = LocationComponent(mapboxMap, transform, developerAnimationListeners, currentListener, lastListener, locationLayerController, locationCameraController, locationAnimatorCoordinator, staleStateManager, compassEngine, false)
|
||||
doReturn(style).`when`(mapboxMap).style
|
||||
locationComponent = LocationComponent(maplibreMap, transform, developerAnimationListeners, currentListener, lastListener, locationLayerController, locationCameraController, locationAnimatorCoordinator, staleStateManager, compassEngine, false)
|
||||
doReturn(style).`when`(maplibreMap).style
|
||||
`when`(style.isFullyLoaded).thenReturn(true)
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
val listener = mock(OnLocationCameraTransitionListener::class.java)
|
||||
|
||||
@@ -178,7 +178,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
val listener = mock(OnLocationCameraTransitionListener::class.java)
|
||||
|
||||
@@ -197,7 +197,7 @@ class LocationComponentTest {
|
||||
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
val listener = mock(OnLocationCameraTransitionListener::class.java)
|
||||
|
||||
@@ -215,7 +215,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationCameraController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.cameraMode = CameraMode.NONE_COMPASS
|
||||
@@ -227,7 +227,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationCameraController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.cameraMode = CameraMode.TRACKING_COMPASS
|
||||
@@ -239,7 +239,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -251,7 +251,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(false)
|
||||
`when`(locationCameraController.isConsumingCompass).thenReturn(false)
|
||||
@@ -270,7 +270,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -284,7 +284,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -297,7 +297,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -311,7 +311,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -324,7 +324,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -338,7 +338,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -353,7 +353,7 @@ class LocationComponentTest {
|
||||
fun compass_notAdListenerWhenDisabled() {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -364,7 +364,7 @@ class LocationComponentTest {
|
||||
fun compass_notAdListenerWhenStopped() {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
@@ -376,7 +376,7 @@ class LocationComponentTest {
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.onStart()
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
|
||||
locationComponent.renderMode = RenderMode.COMPASS
|
||||
|
||||
@@ -459,8 +459,8 @@ class LocationComponentTest {
|
||||
location.bearing = 50f
|
||||
val projection: Projection = mock(Projection::class.java)
|
||||
`when`(projection.getMetersPerPixelAtLatitude(location.latitude)).thenReturn(10.0)
|
||||
`when`(mapboxMap.projection).thenReturn(projection)
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.projection).thenReturn(projection)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
|
||||
locationComponent.activateLocationComponent(
|
||||
LocationComponentActivationOptions.builder(context, style)
|
||||
@@ -482,11 +482,11 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun tiltWhileTracking_notReady() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.tiltWhileTracking(30.0, 500L, callback)
|
||||
verify(callback).onCancel()
|
||||
@@ -495,13 +495,13 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun tiltWhileTracking_notTracking() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationCameraController.cameraMode).thenReturn(CameraMode.NONE)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
locationComponent.onStart()
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.tiltWhileTracking(30.0, 500L, callback)
|
||||
verify(callback).onCancel()
|
||||
@@ -510,14 +510,14 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun tiltWhileTracking_transitioning() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationCameraController.cameraMode).thenReturn(CameraMode.TRACKING)
|
||||
`when`(locationCameraController.isTransitioning).thenReturn(true)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
locationComponent.onStart()
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.tiltWhileTracking(30.0, 500L, callback)
|
||||
verify(callback).onCancel()
|
||||
@@ -526,14 +526,14 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun tiltWhileTracking_sucessful() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationCameraController.cameraMode).thenReturn(CameraMode.TRACKING)
|
||||
`when`(locationCameraController.isTransitioning).thenReturn(false)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
locationComponent.onStart()
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.tiltWhileTracking(30.0, 500L, callback)
|
||||
verify(callback, times(0)).onCancel()
|
||||
@@ -542,11 +542,11 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun zoomWhileTracking_notReady() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.zoomWhileTracking(14.0, 500L, callback)
|
||||
verify(callback).onCancel()
|
||||
@@ -555,13 +555,13 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun zoomWhileTracking_notTracking() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationCameraController.cameraMode).thenReturn(CameraMode.NONE)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
locationComponent.onStart()
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.zoomWhileTracking(14.0, 500L, callback)
|
||||
verify(callback).onCancel()
|
||||
@@ -570,14 +570,14 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun zoomWhileTracking_transitioning() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationCameraController.cameraMode).thenReturn(CameraMode.TRACKING)
|
||||
`when`(locationCameraController.isTransitioning).thenReturn(true)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
locationComponent.onStart()
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.zoomWhileTracking(14.0, 500L, callback)
|
||||
verify(callback).onCancel()
|
||||
@@ -586,14 +586,14 @@ class LocationComponentTest {
|
||||
|
||||
@Test
|
||||
fun zoomWhileTracking_successful() {
|
||||
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(maplibreMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
|
||||
`when`(locationCameraController.cameraMode).thenReturn(CameraMode.TRACKING)
|
||||
`when`(locationCameraController.isTransitioning).thenReturn(false)
|
||||
locationComponent.activateLocationComponent(defaultOptions)
|
||||
locationComponent.isLocationComponentEnabled = true
|
||||
locationComponent.onStart()
|
||||
|
||||
val callback = mock(MapboxMap.CancelableCallback::class.java)
|
||||
val callback = mock(MapLibreMap.CancelableCallback::class.java)
|
||||
|
||||
locationComponent.zoomWhileTracking(14.0, 500L, callback)
|
||||
verify(callback, times(0)).onCancel()
|
||||
@@ -606,7 +606,7 @@ class LocationComponentTest {
|
||||
location.accuracy = 50f
|
||||
val projection: Projection = mock(Projection::class.java)
|
||||
`when`(projection.getMetersPerPixelAtLatitude(location.latitude)).thenReturn(10.0)
|
||||
`when`(mapboxMap.projection).thenReturn(projection)
|
||||
`when`(maplibreMap.projection).thenReturn(projection)
|
||||
locationComponent.activateLocationComponent(
|
||||
LocationComponentActivationOptions.builder(context, style)
|
||||
.locationComponentOptions(locationComponentOptions)
|
||||
@@ -625,7 +625,7 @@ class LocationComponentTest {
|
||||
fun newLocation_accuracy_indicatorLayerRadiusValue() {
|
||||
val location = Location("test")
|
||||
location.accuracy = 50f
|
||||
locationComponent = LocationComponent(mapboxMap, transform, developerAnimationListeners, currentListener, lastListener, locationLayerController, locationCameraController, locationAnimatorCoordinator, staleStateManager, compassEngine, true)
|
||||
locationComponent = LocationComponent(maplibreMap, transform, developerAnimationListeners, currentListener, lastListener, locationLayerController, locationCameraController, locationAnimatorCoordinator, staleStateManager, compassEngine, true)
|
||||
locationComponent.activateLocationComponent(
|
||||
LocationComponentActivationOptions.builder(context, style)
|
||||
.locationComponentOptions(locationComponentOptions)
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.google.gson.JsonElement
|
||||
import com.mapbox.geojson.Feature
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.location.MapboxAnimator.AnimationsValueChangeListener
|
||||
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.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.location.MapLibreAnimator.AnimationsValueChangeListener
|
||||
import org.maplibre.android.location.modes.RenderMode
|
||||
import org.maplibre.android.maps.MapLibreMap
|
||||
import org.maplibre.android.maps.Style
|
||||
import org.maplibre.android.style.layers.Layer
|
||||
import org.maplibre.android.style.sources.GeoJsonSource
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -17,7 +17,7 @@ import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mockito
|
||||
|
||||
class LocationLayerControllerTest {
|
||||
private val mapboxMap = Mockito.mock(MapboxMap::class.java)
|
||||
private val maplibreMap = Mockito.mock(MapLibreMap::class.java)
|
||||
private val style = Mockito.mock(
|
||||
Style::class.java
|
||||
)
|
||||
@@ -27,7 +27,7 @@ class LocationLayerControllerTest {
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
Mockito.`when`(mapboxMap.style).thenReturn(style)
|
||||
Mockito.`when`(maplibreMap.style).thenReturn(style)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -51,8 +51,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -89,8 +89,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -128,8 +128,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -167,8 +167,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -208,8 +208,8 @@ class LocationLayerControllerTest {
|
||||
val layerBelow = "layer-below"
|
||||
Mockito.`when`(options.layerBelow()).thenReturn(layerBelow)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -245,8 +245,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -283,8 +283,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -319,8 +319,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
val controller = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -328,7 +328,7 @@ class LocationLayerControllerTest {
|
||||
internalRenderModeChangedListener,
|
||||
false
|
||||
)
|
||||
controller.initializeComponents(mapboxMap.style, options)
|
||||
controller.initializeComponents(maplibreMap.style, options)
|
||||
Assert.assertEquals(6, layerSet.size)
|
||||
}
|
||||
|
||||
@@ -367,8 +367,8 @@ class LocationLayerControllerTest {
|
||||
|
||||
// Style is applied on initialization
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -412,8 +412,8 @@ class LocationLayerControllerTest {
|
||||
)
|
||||
Mockito.`when`(options.elevation()).thenReturn(0f)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -455,8 +455,8 @@ class LocationLayerControllerTest {
|
||||
val bitmap = Mockito.mock(Bitmap::class.java)
|
||||
Mockito.`when`(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -497,8 +497,8 @@ class LocationLayerControllerTest {
|
||||
val bitmap = Mockito.mock(Bitmap::class.java)
|
||||
Mockito.`when`(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -539,8 +539,8 @@ class LocationLayerControllerTest {
|
||||
val bitmap = Mockito.mock(Bitmap::class.java)
|
||||
Mockito.`when`(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -581,8 +581,8 @@ class LocationLayerControllerTest {
|
||||
val bitmap = Mockito.mock(Bitmap::class.java)
|
||||
Mockito.`when`(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -623,8 +623,8 @@ class LocationLayerControllerTest {
|
||||
val bitmap = Mockito.mock(Bitmap::class.java)
|
||||
Mockito.`when`(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -649,8 +649,8 @@ class LocationLayerControllerTest {
|
||||
LayerBitmapProvider::class.java
|
||||
)
|
||||
LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -699,8 +699,8 @@ class LocationLayerControllerTest {
|
||||
)
|
||||
).thenReturn(bitmap)
|
||||
val layerController = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -785,8 +785,8 @@ class LocationLayerControllerTest {
|
||||
var layerBelow = "layer-below"
|
||||
Mockito.`when`(options.layerBelow()).thenReturn(layerBelow)
|
||||
val layerController = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -845,8 +845,8 @@ class LocationLayerControllerTest {
|
||||
)
|
||||
).thenReturn(bitmap)
|
||||
val layerController = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -898,8 +898,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -940,8 +940,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -984,8 +984,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -994,7 +994,7 @@ class LocationLayerControllerTest {
|
||||
false
|
||||
)
|
||||
getAnimationListener<Any>(
|
||||
MapboxAnimator.ANIMATOR_LAYER_LATLNG,
|
||||
MapLibreAnimator.ANIMATOR_LAYER_LATLNG,
|
||||
layer.animationListeners
|
||||
)!!.onNewAnimationValue(LatLng())
|
||||
|
||||
@@ -1028,8 +1028,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -1040,7 +1040,7 @@ class LocationLayerControllerTest {
|
||||
layer.renderMode = RenderMode.GPS
|
||||
val gpsBearing = 2f
|
||||
getAnimationListener<Any>(
|
||||
MapboxAnimator.ANIMATOR_LAYER_GPS_BEARING,
|
||||
MapLibreAnimator.ANIMATOR_LAYER_GPS_BEARING,
|
||||
layer.animationListeners
|
||||
)!!.onNewAnimationValue(gpsBearing)
|
||||
Mockito.verify(locationFeature)
|
||||
@@ -1073,8 +1073,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -1086,7 +1086,7 @@ class LocationLayerControllerTest {
|
||||
val gpsBearing = 2f
|
||||
Assert.assertNull(
|
||||
getAnimationListener<Any>(
|
||||
MapboxAnimator.ANIMATOR_LAYER_GPS_BEARING,
|
||||
MapLibreAnimator.ANIMATOR_LAYER_GPS_BEARING,
|
||||
layer.animationListeners
|
||||
)
|
||||
)
|
||||
@@ -1120,8 +1120,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -1132,7 +1132,7 @@ class LocationLayerControllerTest {
|
||||
layer.renderMode = RenderMode.COMPASS
|
||||
val compassBearing = 2f
|
||||
getAnimationListener<Any>(
|
||||
MapboxAnimator.ANIMATOR_LAYER_COMPASS_BEARING,
|
||||
MapLibreAnimator.ANIMATOR_LAYER_COMPASS_BEARING,
|
||||
layer.animationListeners
|
||||
)
|
||||
?.onNewAnimationValue(compassBearing)
|
||||
@@ -1166,8 +1166,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -1179,7 +1179,7 @@ class LocationLayerControllerTest {
|
||||
val compassBearing = 2f
|
||||
Assert.assertNull(
|
||||
getAnimationListener<Any>(
|
||||
MapboxAnimator.ANIMATOR_LAYER_COMPASS_BEARING,
|
||||
MapLibreAnimator.ANIMATOR_LAYER_COMPASS_BEARING,
|
||||
layer.animationListeners
|
||||
)
|
||||
)
|
||||
@@ -1213,8 +1213,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -1224,7 +1224,7 @@ class LocationLayerControllerTest {
|
||||
)
|
||||
layer.renderMode = RenderMode.NORMAL
|
||||
val accuracyRadiusValue = 2f
|
||||
getAnimationListener<Any>(MapboxAnimator.ANIMATOR_LAYER_ACCURACY, layer.animationListeners)
|
||||
getAnimationListener<Any>(MapLibreAnimator.ANIMATOR_LAYER_ACCURACY, layer.animationListeners)
|
||||
?.onNewAnimationValue(accuracyRadiusValue)
|
||||
Mockito.verify(locationFeature).addNumberProperty(
|
||||
LocationComponentConstants.PROPERTY_ACCURACY_RADIUS,
|
||||
@@ -1258,8 +1258,8 @@ class LocationLayerControllerTest {
|
||||
Feature::class.java
|
||||
)
|
||||
val layer = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(locationFeature, options),
|
||||
bitmapProvider,
|
||||
@@ -1271,7 +1271,7 @@ class LocationLayerControllerTest {
|
||||
val accuracyRadiusValue = 2f
|
||||
Assert.assertNull(
|
||||
getAnimationListener<Any>(
|
||||
MapboxAnimator.ANIMATOR_LAYER_ACCURACY,
|
||||
MapLibreAnimator.ANIMATOR_LAYER_ACCURACY,
|
||||
layer.animationListeners
|
||||
)
|
||||
)
|
||||
@@ -1303,8 +1303,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
val controller = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -1340,8 +1340,8 @@ class LocationLayerControllerTest {
|
||||
LocationComponentOptions::class.java
|
||||
)
|
||||
val controller = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -1386,8 +1386,8 @@ class LocationLayerControllerTest {
|
||||
val bitmap = Mockito.mock(Bitmap::class.java)
|
||||
Mockito.`when`(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap)
|
||||
val controller = LocationLayerController(
|
||||
mapboxMap,
|
||||
mapboxMap.style,
|
||||
maplibreMap,
|
||||
maplibreMap.style,
|
||||
sourceProvider,
|
||||
buildFeatureProvider(options),
|
||||
bitmapProvider,
|
||||
@@ -1490,11 +1490,11 @@ class LocationLayerControllerTest {
|
||||
}
|
||||
|
||||
private fun <T> getAnimationListener(
|
||||
@MapboxAnimator.Type animatorType: Int,
|
||||
@MapLibreAnimator.Type animatorType: Int,
|
||||
holders: Set<AnimatorListenerHolder>
|
||||
): AnimationsValueChangeListener<Any>? {
|
||||
for (holder in holders) {
|
||||
@MapboxAnimator.Type val type = holder.animatorType
|
||||
@MapLibreAnimator.Type val type = holder.animatorType
|
||||
if (type == animatorType) {
|
||||
return holder.listener
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import io.mockk.every
|
||||
@@ -9,15 +9,20 @@ import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class MapboxAnimatorTest {
|
||||
class MapLibreAnimatorTest {
|
||||
|
||||
@Test
|
||||
fun fps_unlimited() {
|
||||
val valueAnimator = mockk<ValueAnimator>()
|
||||
every { valueAnimator.animatedValue } answers { 5f }
|
||||
val listener = mockk<MapboxAnimator.AnimationsValueChangeListener<Float>>()
|
||||
val listener = mockk<MapLibreAnimator.AnimationsValueChangeListener<Float>>()
|
||||
every { listener.onNewAnimationValue(any()) } answers {}
|
||||
val mapboxAnimator = MapboxFloatAnimator(floatArrayOf(0f, 10f).toTypedArray(), listener, Int.MAX_VALUE)
|
||||
val mapboxAnimator = MapLibreFloatAnimator(
|
||||
floatArrayOf(
|
||||
0f,
|
||||
10f
|
||||
).toTypedArray(), listener, Int.MAX_VALUE
|
||||
)
|
||||
|
||||
for (i in 0 until 5)
|
||||
mapboxAnimator.onAnimationUpdate(valueAnimator)
|
||||
@@ -29,9 +34,14 @@ class MapboxAnimatorTest {
|
||||
fun fps_limited() {
|
||||
val valueAnimator = mockk<ValueAnimator>()
|
||||
every { valueAnimator.animatedValue } answers { 5f }
|
||||
val listener = mockk<MapboxAnimator.AnimationsValueChangeListener<Float>>()
|
||||
val listener = mockk<MapLibreAnimator.AnimationsValueChangeListener<Float>>()
|
||||
every { listener.onNewAnimationValue(any()) } answers {}
|
||||
val mapboxAnimator = MapboxFloatAnimator(floatArrayOf(0f, 10f).toTypedArray(), listener, 5)
|
||||
val mapboxAnimator = MapLibreFloatAnimator(
|
||||
floatArrayOf(
|
||||
0f,
|
||||
10f
|
||||
).toTypedArray(), listener, 5
|
||||
)
|
||||
|
||||
for (i in 0 until 5) {
|
||||
mapboxAnimator.onAnimationUpdate(valueAnimator)
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
package org.maplibre.android.location
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location.engine;
|
||||
package org.maplibre.android.location.engine;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location.engine;
|
||||
package org.maplibre.android.location.engine;
|
||||
|
||||
import android.location.LocationListener;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location.engine;
|
||||
package org.maplibre.android.location.engine;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location.engine;
|
||||
package org.maplibre.android.location.engine;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.location.Location;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location.engine;
|
||||
package org.maplibre.android.location.engine;
|
||||
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location.engine;
|
||||
package org.maplibre.android.location.engine;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Criteria;
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MapboxFusedLocationEngineImplAdditionalTest2 {
|
||||
public class MapLibreFusedLocationEngineImplAdditionalTest2 {
|
||||
private static final long INTERVAL = 1000L;
|
||||
private static final String PROVIDER = "test_provider";
|
||||
private ArrayList<LocationEngineProxy> engines = new ArrayList<>();
|
||||
@@ -67,7 +67,7 @@ public class MapboxFusedLocationEngineImplAdditionalTest2 {
|
||||
}
|
||||
}).when(mockLocationManager)
|
||||
.requestLocationUpdates(anyString(), anyLong(), anyFloat(), any(LocationListener.class), any(Looper.class));
|
||||
engines.add(new LocationEngineProxy<>(new MapboxFusedLocationEngineImpl(mockContext)));
|
||||
engines.add(new LocationEngineProxy<>(new MapLibreFusedLocationEngineImpl(mockContext)));
|
||||
engines.add(new LocationEngineProxy<>(new AndroidLocationEngineImpl(mockContext)));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.location.engine;
|
||||
package org.maplibre.android.location.engine;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MapboxFusedLocationEngineImplTest {
|
||||
public class MapLibreFusedLocationEngineImplTest {
|
||||
private static final double LATITUDE = 37.7749;
|
||||
private static final double LONGITUDE = 122.4194;
|
||||
|
||||
@@ -43,14 +43,14 @@ public class MapboxFusedLocationEngineImplTest {
|
||||
private LocationManager locationManagerMock;
|
||||
|
||||
private LocationEngine engine;
|
||||
private MapboxFusedLocationEngineImpl mapboxFusedLocationEngineImpl;
|
||||
private MapLibreFusedLocationEngineImpl maplibreFusedLocationEngineImpl;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Context context = mock(Context.class);
|
||||
when(context.getSystemService(Context.LOCATION_SERVICE)).thenReturn(locationManagerMock);
|
||||
mapboxFusedLocationEngineImpl = new MapboxFusedLocationEngineImpl(context);
|
||||
engine = new LocationEngineProxy<>(mapboxFusedLocationEngineImpl);
|
||||
maplibreFusedLocationEngineImpl = new MapLibreFusedLocationEngineImpl(context);
|
||||
engine = new LocationEngineProxy<>(maplibreFusedLocationEngineImpl);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,7 +75,7 @@ public class MapboxFusedLocationEngineImplTest {
|
||||
@Test
|
||||
public void createListener() {
|
||||
LocationEngineCallback<LocationEngineResult> callback = mock(LocationEngineCallback.class);
|
||||
LocationListener locationListener = mapboxFusedLocationEngineImpl.createListener(callback);
|
||||
LocationListener locationListener = maplibreFusedLocationEngineImpl.createListener(callback);
|
||||
Location mockLocation = getMockLocation(LATITUDE, LONGITUDE);
|
||||
locationListener.onLocationChanged(mockLocation);
|
||||
ArgumentCaptor<LocationEngineResult> argument = ArgumentCaptor.forClass(LocationEngineResult.class);
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.log
|
||||
package org.maplibre.android.log
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import androidx.collection.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.maplibre.android.annotations.Annotation
|
||||
import org.maplibre.android.annotations.BaseMarkerOptions
|
||||
import org.maplibre.android.annotations.Marker
|
||||
import org.maplibre.android.annotations.MarkerOptions
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers
|
||||
@@ -45,9 +45,9 @@ class AnnotationManagerTest {
|
||||
val aMarkerOptions = Mockito.mock(
|
||||
BaseMarkerOptions::class.java
|
||||
)
|
||||
val aMapboxMap = Mockito.mock(MapboxMap::class.java)
|
||||
val aMapLibreMap = Mockito.mock(MapLibreMap::class.java)
|
||||
Mockito.`when`(aMarkerOptions.marker).thenReturn(aMarker)
|
||||
annotationManager.addMarker(aMarkerOptions, aMapboxMap)
|
||||
annotationManager.addMarker(aMarkerOptions, aMapLibreMap)
|
||||
Assert.assertEquals(aMarker, annotationManager.annotations[0])
|
||||
Assert.assertEquals(aMarker, annotationManager.getAnnotation(aId))
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class AnnotationManagerTest {
|
||||
val secondMarkerOption = MarkerOptions().position(LatLng()).title("second")
|
||||
markerList.add(firstMarkerOption)
|
||||
markerList.add(secondMarkerOption)
|
||||
val aMapboxMap = Mockito.mock(MapboxMap::class.java)
|
||||
val aMapLibreMap = Mockito.mock(MapLibreMap::class.java)
|
||||
Mockito.`when`(
|
||||
aNativeMapView.addMarker(
|
||||
ArgumentMatchers.any(
|
||||
@@ -94,7 +94,7 @@ class AnnotationManagerTest {
|
||||
).thenReturn(firstId, secondId)
|
||||
Mockito.`when`(aNativeMapView.addMarkers(ArgumentMatchers.anyList()))
|
||||
.thenReturn(longArrayOf(firstId, secondId))
|
||||
annotationManager.addMarkers(markerList, aMapboxMap)
|
||||
annotationManager.addMarkers(markerList, aMapLibreMap)
|
||||
Assert.assertEquals(2, annotationManager.annotations.size)
|
||||
Assert.assertEquals("first", (annotationManager.annotations[0] as Marker).title)
|
||||
Assert.assertEquals("second", (annotationManager.annotations[1] as Marker).title)
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.content.Context
|
||||
import org.junit.Assert
|
||||
@@ -17,7 +17,7 @@ class AttributionDialogManagerTest {
|
||||
)
|
||||
|
||||
@InjectMocks
|
||||
var mapboxMap = Mockito.mock(MapboxMap::class.java)
|
||||
var maplibreMap = Mockito.mock(MapLibreMap::class.java)
|
||||
|
||||
@InjectMocks
|
||||
var style = Mockito.mock(
|
||||
@@ -27,7 +27,7 @@ class AttributionDialogManagerTest {
|
||||
|
||||
@Before
|
||||
fun beforeTest() {
|
||||
attributionDialogManager = AttributionDialogManager(context, mapboxMap)
|
||||
attributionDialogManager = AttributionDialogManager(context, maplibreMap)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import com.google.common.util.concurrent.ExecutionError
|
||||
import com.mapbox.mapboxsdk.log.Logger
|
||||
import com.mapbox.mapboxsdk.log.LoggerDefinition
|
||||
import com.mapbox.mapboxsdk.maps.MapView.*
|
||||
import org.maplibre.android.log.Logger
|
||||
import org.maplibre.android.log.LoggerDefinition
|
||||
import org.maplibre.android.maps.MapView.*
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import android.content.res.TypedArray
|
||||
import com.mapbox.mapboxsdk.R
|
||||
import org.maplibre.android.R
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.RelaxedMockK
|
||||
@@ -14,10 +14,10 @@ import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class MapboxMapOptionsAttrsTest {
|
||||
class MapLibreMapOptionsAttrsTest {
|
||||
|
||||
@RelaxedMockK
|
||||
private lateinit var options: MapboxMapOptions
|
||||
private lateinit var options: MapLibreMapOptions
|
||||
|
||||
@RelaxedMockK
|
||||
private lateinit var typedArray: TypedArray
|
||||
@@ -40,7 +40,7 @@ class MapboxMapOptionsAttrsTest {
|
||||
fun enabledLocalIdeographFontFamily() {
|
||||
mockEnableLocalIdeograph(enabled = true)
|
||||
|
||||
val options = MapboxMapOptions.createFromAttributes(options, context, typedArray)
|
||||
val options = MapLibreMapOptions.createFromAttributes(options, context, typedArray)
|
||||
|
||||
verify(exactly = 1) {
|
||||
options.localIdeographFontFamily(any())
|
||||
@@ -54,7 +54,7 @@ class MapboxMapOptionsAttrsTest {
|
||||
val font = "foo"
|
||||
mockLocalIdeographString(font)
|
||||
|
||||
val options = MapboxMapOptions.createFromAttributes(options, context, typedArray)
|
||||
val options = MapLibreMapOptions.createFromAttributes(options, context, typedArray)
|
||||
|
||||
verify(exactly = 1) {
|
||||
options.localIdeographFontFamily(font)
|
||||
@@ -68,7 +68,7 @@ class MapboxMapOptionsAttrsTest {
|
||||
val fonts = arrayOf("foo", "bar")
|
||||
mockLocalIdeographStringArray(fonts)
|
||||
|
||||
val options = MapboxMapOptions.createFromAttributes(options, context, typedArray)
|
||||
val options = MapLibreMapOptions.createFromAttributes(options, context, typedArray)
|
||||
|
||||
verify(exactly = 1) {
|
||||
options.localIdeographFontFamily(*fonts)
|
||||
@@ -0,0 +1,329 @@
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.Gravity
|
||||
import org.maplibre.android.camera.CameraPosition
|
||||
import org.maplibre.android.constants.MapLibreConstants
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import java.util.*
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class MapLibreMapOptionsTest {
|
||||
@Test
|
||||
fun testSanity() {
|
||||
Assert.assertNotNull("should not be null",
|
||||
MapLibreMapOptions()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDebugEnabled() {
|
||||
Assert.assertFalse(MapLibreMapOptions().debugActive)
|
||||
Assert.assertTrue(MapLibreMapOptions().debugActive(true).debugActive)
|
||||
Assert.assertFalse(MapLibreMapOptions().debugActive(false).debugActive)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompassEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().compassEnabled(true).compassEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().compassEnabled(false).compassEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompassGravity() {
|
||||
Assert.assertEquals(
|
||||
Gravity.TOP or Gravity.END,
|
||||
MapLibreMapOptions().compassGravity
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM,
|
||||
MapLibreMapOptions().compassGravity(Gravity.BOTTOM).compassGravity
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
Gravity.START.toLong(),
|
||||
MapLibreMapOptions().compassGravity(Gravity.BOTTOM).compassGravity.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompassMargins() {
|
||||
Assert.assertTrue(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapLibreMapOptions()
|
||||
.compassMargins(intArrayOf(0, 1, 2, 3)).compassMargins
|
||||
)
|
||||
)
|
||||
Assert.assertFalse(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapLibreMapOptions()
|
||||
.compassMargins(intArrayOf(0, 0, 0, 0)).compassMargins
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLogoEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().logoEnabled(true).logoEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().logoEnabled(false).logoEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLogoGravity() {
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM or Gravity.START,
|
||||
MapLibreMapOptions().logoGravity
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM,
|
||||
MapLibreMapOptions().logoGravity(Gravity.BOTTOM).logoGravity
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
Gravity.START.toLong(),
|
||||
MapLibreMapOptions().logoGravity(Gravity.BOTTOM).logoGravity.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLogoMargins() {
|
||||
Assert.assertTrue(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapLibreMapOptions()
|
||||
.logoMargins(intArrayOf(0, 1, 2, 3)).logoMargins
|
||||
)
|
||||
)
|
||||
Assert.assertFalse(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapLibreMapOptions()
|
||||
.logoMargins(intArrayOf(0, 0, 0, 0)).logoMargins
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionTintColor() {
|
||||
Assert.assertEquals(-1, MapLibreMapOptions().attributionTintColor)
|
||||
Assert.assertEquals(
|
||||
Color.RED,
|
||||
MapLibreMapOptions().attributionTintColor(Color.RED).attributionTintColor
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().attributionEnabled(true).attributionEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().attributionEnabled(false).attributionEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionGravity() {
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM or Gravity.START,
|
||||
MapLibreMapOptions().attributionGravity
|
||||
)
|
||||
Assert.assertEquals(
|
||||
Gravity.BOTTOM,
|
||||
MapLibreMapOptions().attributionGravity(Gravity.BOTTOM).attributionGravity
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
Gravity.START.toLong(),
|
||||
MapLibreMapOptions().attributionGravity(Gravity.BOTTOM).attributionGravity.toLong()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAttributionMargins() {
|
||||
Assert.assertTrue(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapLibreMapOptions()
|
||||
.attributionMargins(intArrayOf(0, 1, 2, 3)).attributionMargins
|
||||
)
|
||||
)
|
||||
Assert.assertFalse(
|
||||
Arrays.equals(
|
||||
intArrayOf(0, 1, 2, 3),
|
||||
MapLibreMapOptions()
|
||||
.attributionMargins(intArrayOf(0, 0, 0, 0)).attributionMargins
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMinZoom() {
|
||||
Assert.assertEquals(
|
||||
MapLibreConstants.MINIMUM_ZOOM.toDouble(),
|
||||
MapLibreMapOptions().minZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapLibreMapOptions().minZoomPreference(5.0).minZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapLibreMapOptions().minZoomPreference(5.0).minZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMaxZoom() {
|
||||
Assert.assertEquals(
|
||||
MapLibreConstants.MAXIMUM_ZOOM.toDouble(),
|
||||
MapLibreMapOptions().maxZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapLibreMapOptions().maxZoomPreference(5.0).maxZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapLibreMapOptions().maxZoomPreference(5.0).maxZoomPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMinPitch() {
|
||||
Assert.assertEquals(
|
||||
MapLibreConstants.MINIMUM_PITCH.toDouble(),
|
||||
MapLibreMapOptions().minPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapLibreMapOptions().minPitchPreference(5.0).minPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapLibreMapOptions().minPitchPreference(5.0).minPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMaxPitch() {
|
||||
Assert.assertEquals(
|
||||
MapLibreConstants.MAXIMUM_PITCH.toDouble(),
|
||||
MapLibreMapOptions().maxPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertEquals(
|
||||
5.0,
|
||||
MapLibreMapOptions().maxPitchPreference(5.0).maxPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
2.0,
|
||||
MapLibreMapOptions().maxPitchPreference(5.0).maxPitchPreference,
|
||||
DELTA
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTiltGesturesEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().tiltGesturesEnabled)
|
||||
Assert.assertTrue(MapLibreMapOptions().tiltGesturesEnabled(true).tiltGesturesEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().tiltGesturesEnabled(false).tiltGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScrollGesturesEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().scrollGesturesEnabled)
|
||||
Assert.assertTrue(MapLibreMapOptions().scrollGesturesEnabled(true).scrollGesturesEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().scrollGesturesEnabled(false).scrollGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHorizontalScrollGesturesEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().horizontalScrollGesturesEnabled)
|
||||
Assert.assertTrue(MapLibreMapOptions().horizontalScrollGesturesEnabled(true).horizontalScrollGesturesEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().horizontalScrollGesturesEnabled(false).horizontalScrollGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testZoomGesturesEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().zoomGesturesEnabled)
|
||||
Assert.assertTrue(MapLibreMapOptions().zoomGesturesEnabled(true).zoomGesturesEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().zoomGesturesEnabled(false).zoomGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRotateGesturesEnabled() {
|
||||
Assert.assertTrue(MapLibreMapOptions().rotateGesturesEnabled)
|
||||
Assert.assertTrue(MapLibreMapOptions().rotateGesturesEnabled(true).rotateGesturesEnabled)
|
||||
Assert.assertFalse(MapLibreMapOptions().rotateGesturesEnabled(false).rotateGesturesEnabled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCamera() {
|
||||
val position = CameraPosition.Builder().build()
|
||||
Assert.assertEquals(
|
||||
CameraPosition.Builder(position).build(),
|
||||
MapLibreMapOptions().camera(position).camera
|
||||
)
|
||||
Assert.assertNotEquals(
|
||||
CameraPosition.Builder().target(LatLng(1.0, 1.0)),
|
||||
MapLibreMapOptions().camera(position)
|
||||
)
|
||||
Assert.assertNull(MapLibreMapOptions().camera)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPrefetchesTiles() {
|
||||
// Default value
|
||||
Assert.assertTrue(MapLibreMapOptions().prefetchesTiles)
|
||||
|
||||
// Check mutations
|
||||
Assert.assertTrue(MapLibreMapOptions().setPrefetchesTiles(true).prefetchesTiles)
|
||||
Assert.assertFalse(MapLibreMapOptions().setPrefetchesTiles(false).prefetchesTiles)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPrefetchZoomDelta() {
|
||||
// Default value
|
||||
Assert.assertEquals(4, MapLibreMapOptions().prefetchZoomDelta)
|
||||
|
||||
// Check mutations
|
||||
Assert.assertEquals(
|
||||
5,
|
||||
MapLibreMapOptions().setPrefetchZoomDelta(5).prefetchZoomDelta
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCrossSourceCollisions() {
|
||||
// Default value
|
||||
Assert.assertTrue(MapLibreMapOptions().crossSourceCollisions)
|
||||
|
||||
// check mutations
|
||||
Assert.assertTrue(MapLibreMapOptions().crossSourceCollisions(true).crossSourceCollisions)
|
||||
Assert.assertFalse(MapLibreMapOptions().crossSourceCollisions(false).crossSourceCollisions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLocalIdeographFontFamily_enabledByDefault() {
|
||||
val options = MapLibreMapOptions.createFromAttributes(RuntimeEnvironment.application, null)
|
||||
Assert.assertEquals(
|
||||
MapLibreConstants.DEFAULT_FONT,
|
||||
options.localIdeographFontFamily
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DELTA = 1e-15
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.content.Context
|
||||
import com.mapbox.mapboxsdk.MapboxInjector
|
||||
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 com.mapbox.mapboxsdk.utils.ConfigUtils
|
||||
import org.maplibre.android.MapLibreInjector
|
||||
import org.maplibre.android.camera.CameraPosition
|
||||
import org.maplibre.android.camera.CameraUpdateFactory
|
||||
import org.maplibre.android.constants.MapLibreConstants
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.geometry.LatLngBounds
|
||||
import org.maplibre.android.style.layers.TransitionOptions
|
||||
import org.maplibre.android.utils.ConfigUtils
|
||||
import io.mockk.*
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
@@ -19,9 +19,9 @@ import org.mockito.MockitoAnnotations
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class MapboxMapTest {
|
||||
class MapLibreMapTest {
|
||||
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var maplibreMap: MapLibreMap
|
||||
|
||||
private lateinit var nativeMapView: NativeMap
|
||||
|
||||
@@ -29,7 +29,7 @@ class MapboxMapTest {
|
||||
|
||||
private lateinit var cameraChangeDispatcher: CameraChangeDispatcher
|
||||
|
||||
private lateinit var developerAnimationListener: MapboxMap.OnDeveloperAnimationListener
|
||||
private lateinit var developerAnimationListener: MapLibreMap.OnDeveloperAnimationListener
|
||||
|
||||
@Mock
|
||||
private lateinit var context: Context
|
||||
@@ -40,161 +40,169 @@ class MapboxMapTest {
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MapboxInjector.inject(context, "abcdef", ConfigUtils.getMockedOptions())
|
||||
MapLibreInjector.inject(context, "abcdef", ConfigUtils.getMockedOptions())
|
||||
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))
|
||||
maplibreMap = MapLibreMap(
|
||||
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.getPredefinedStyle("Streets"))
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.injectLocationComponent(spyk())
|
||||
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTransitionOptions() {
|
||||
val expected = TransitionOptions(100, 200)
|
||||
mapboxMap.style?.transition = expected
|
||||
maplibreMap.style?.transition = expected
|
||||
verify { nativeMapView.transitionOptions = expected }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMoveCamera() {
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.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) }
|
||||
maplibreMap.moveCamera(update, callback)
|
||||
verify { transform.moveCamera(maplibreMap, update, callback) }
|
||||
verify { developerAnimationListener.onDeveloperAnimationStarted() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEaseCamera() {
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.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) }
|
||||
maplibreMap.easeCamera(update, callback)
|
||||
verify { transform.easeCamera(maplibreMap, update, MapLibreConstants.ANIMATION_DURATION, true, callback) }
|
||||
verify { developerAnimationListener.onDeveloperAnimationStarted() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAnimateCamera() {
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.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) }
|
||||
maplibreMap.animateCamera(update, callback)
|
||||
verify { transform.animateCamera(maplibreMap, update, MapLibreConstants.ANIMATION_DURATION, callback) }
|
||||
verify { developerAnimationListener.onDeveloperAnimationStarted() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScrollBy() {
|
||||
mapboxMap.scrollBy(100f, 200f)
|
||||
maplibreMap.scrollBy(100f, 200f)
|
||||
verify { nativeMapView.moveBy(100.0, 200.0, 0) }
|
||||
verify { developerAnimationListener.onDeveloperAnimationStarted() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testResetNorth() {
|
||||
mapboxMap.resetNorth()
|
||||
maplibreMap.resetNorth()
|
||||
verify { transform.resetNorth() }
|
||||
verify { developerAnimationListener.onDeveloperAnimationStarted() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFocalBearing() {
|
||||
mapboxMap.setFocalBearing(35.0, 100f, 200f, 1000)
|
||||
maplibreMap.setFocalBearing(35.0, 100f, 200f, 1000)
|
||||
verify { transform.setBearing(35.0, 100f, 200f, 1000) }
|
||||
verify { developerAnimationListener.onDeveloperAnimationStarted() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMinZoom() {
|
||||
mapboxMap.setMinZoomPreference(10.0)
|
||||
maplibreMap.setMinZoomPreference(10.0)
|
||||
verify { transform.minZoom = 10.0 }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMaxZoom() {
|
||||
mapboxMap.setMaxZoomPreference(10.0)
|
||||
maplibreMap.setMaxZoomPreference(10.0)
|
||||
verify { transform.maxZoom = 10.0 }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMinPitch() {
|
||||
mapboxMap.setMinPitchPreference(10.0)
|
||||
maplibreMap.setMinPitchPreference(10.0)
|
||||
verify { transform.minPitch = 10.0 }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMaxPitch() {
|
||||
mapboxMap.setMaxPitchPreference(10.0)
|
||||
maplibreMap.setMaxPitchPreference(10.0)
|
||||
verify { transform.maxPitch = 10.0 }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFpsListener() {
|
||||
val fpsChangedListener = mockk<MapboxMap.OnFpsChangedListener>()
|
||||
mapboxMap.onFpsChangedListener = fpsChangedListener
|
||||
assertEquals("Listener should match", fpsChangedListener, mapboxMap.onFpsChangedListener)
|
||||
val fpsChangedListener = mockk<MapLibreMap.OnFpsChangedListener>()
|
||||
maplibreMap.onFpsChangedListener = fpsChangedListener
|
||||
assertEquals("Listener should match", fpsChangedListener, maplibreMap.onFpsChangedListener)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTilePrefetch() {
|
||||
mapboxMap.prefetchesTiles = true
|
||||
maplibreMap.prefetchesTiles = true
|
||||
verify { nativeMapView.prefetchTiles = true }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetPrefetchZoomDelta() {
|
||||
every { nativeMapView.prefetchZoomDelta } answers { 3 }
|
||||
assertEquals(3, mapboxMap.prefetchZoomDelta)
|
||||
assertEquals(3, maplibreMap.prefetchZoomDelta)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSetPrefetchZoomDelta() {
|
||||
mapboxMap.prefetchZoomDelta = 2
|
||||
maplibreMap.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)
|
||||
maplibreMap.setLatLngBoundsForCameraTarget(bounds)
|
||||
verify { nativeMapView.setLatLngBounds(bounds) }
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException::class)
|
||||
fun testAnimateCameraChecksDurationPositive() {
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(LatLng(30.0, 30.0)), 0, null)
|
||||
maplibreMap.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)
|
||||
maplibreMap.easeCamera(CameraUpdateFactory.newLatLng(LatLng(30.0, 30.0)), 0, null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetNativeMapPtr() {
|
||||
assertEquals(5, mapboxMap.nativeMapPtr)
|
||||
assertEquals(5, maplibreMap.nativeMapPtr)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNativeMapIsNotCalledOnStateSave() {
|
||||
clearMocks(nativeMapView)
|
||||
mapboxMap.onSaveInstanceState(mockk(relaxed = true))
|
||||
maplibreMap.onSaveInstanceState(mockk(relaxed = true))
|
||||
verify { nativeMapView wasNot Called }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCameraChangeDispatcherCleared() {
|
||||
mapboxMap.onDestroy()
|
||||
maplibreMap.onDestroy()
|
||||
verify { cameraChangeDispatcher.onDestroy() }
|
||||
}
|
||||
|
||||
@@ -203,9 +211,9 @@ class MapboxMapTest {
|
||||
val style = mockk<Style>(relaxed = true)
|
||||
val builder = mockk<Style.Builder>(relaxed = true)
|
||||
every { builder.build(nativeMapView) } returns style
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
|
||||
mapboxMap.onDestroy()
|
||||
maplibreMap.onDestroy()
|
||||
verify(exactly = 1) { style.clear() }
|
||||
}
|
||||
|
||||
@@ -216,10 +224,10 @@ class MapboxMapTest {
|
||||
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()
|
||||
maplibreMap.setStyle(builder, onStyleLoadedListener)
|
||||
maplibreMap.onFailLoadingStyle()
|
||||
maplibreMap.setStyle(builder, onStyleLoadedListener)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { onStyleLoadedListener.onStyleLoaded(style) }
|
||||
}
|
||||
|
||||
@@ -231,9 +239,9 @@ class MapboxMapTest {
|
||||
every { builder.build(nativeMapView) } returns style
|
||||
val onStyleLoadedListener = mockk<Style.OnStyleLoaded>(relaxed = true)
|
||||
|
||||
mapboxMap.setStyle(builder, onStyleLoadedListener)
|
||||
mapboxMap.setStyle(builder, onStyleLoadedListener)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder, onStyleLoadedListener)
|
||||
maplibreMap.setStyle(builder, onStyleLoadedListener)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { onStyleLoadedListener.onStyleLoaded(style) }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.graphics.PointF
|
||||
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 com.mapbox.mapboxsdk.maps.MapboxMap.*
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import org.maplibre.android.maps.MapLibreMap.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito
|
||||
@@ -75,7 +75,7 @@ class MapTouchListenersTest {
|
||||
@Throws(Exception::class)
|
||||
fun onFlingListenerTest() {
|
||||
val listener = Mockito.mock(
|
||||
MapboxMap.OnFlingListener::class.java
|
||||
OnFlingListener::class.java
|
||||
)
|
||||
mapGestureDetector!!.addOnFlingListener(listener)
|
||||
mapGestureDetector!!.notifyOnFlingListeners()
|
||||
@@ -112,7 +112,7 @@ class MapTouchListenersTest {
|
||||
@Throws(Exception::class)
|
||||
fun onRotateListenerTest() {
|
||||
val listener = Mockito.mock(
|
||||
MapboxMap.OnRotateListener::class.java
|
||||
OnRotateListener::class.java
|
||||
)
|
||||
val detector = Mockito.mock(
|
||||
RotateGestureDetector::class.java
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.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 org.maplibre.android.style.layers.SymbolLayer
|
||||
import org.maplibre.android.style.layers.TransitionOptions
|
||||
import org.maplibre.android.style.sources.GeoJsonSource
|
||||
import org.maplibre.android.utils.BitmapUtils
|
||||
import io.mockk.mockk
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.ShapeDrawable
|
||||
import com.mapbox.mapboxsdk.MapboxInjector
|
||||
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 com.mapbox.mapboxsdk.utils.ConfigUtils
|
||||
import org.maplibre.android.MapLibreInjector
|
||||
import org.maplibre.android.constants.MapLibreConstants
|
||||
import org.maplibre.android.style.layers.CannotAddLayerException
|
||||
import org.maplibre.android.style.layers.SymbolLayer
|
||||
import org.maplibre.android.style.layers.TransitionOptions
|
||||
import org.maplibre.android.style.sources.CannotAddSourceException
|
||||
import org.maplibre.android.style.sources.GeoJsonSource
|
||||
import org.maplibre.android.utils.ConfigUtils
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.spyk
|
||||
@@ -26,7 +26,7 @@ import org.robolectric.RobolectricTestRunner
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class StyleTest {
|
||||
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var maplibreMap: MapLibreMap
|
||||
|
||||
private lateinit var nativeMapView: NativeMap
|
||||
|
||||
@@ -39,31 +39,39 @@ class StyleTest {
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
MapboxInjector.inject(context, "abcdef", ConfigUtils.getMockedOptions())
|
||||
MapLibreInjector.inject(context, "abcdef", ConfigUtils.getMockedOptions())
|
||||
nativeMapView = mockk(relaxed = true)
|
||||
mapboxMap = MapboxMap(nativeMapView, null, null, null, null, null, null)
|
||||
maplibreMap = MapLibreMap(
|
||||
nativeMapView,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)
|
||||
every { nativeMapView.isDestroyed } returns false
|
||||
mapboxMap.injectLocationComponent(spyk())
|
||||
maplibreMap.injectLocationComponent(spyk())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFromUrl() {
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFromJson() {
|
||||
val builder = Style.Builder().fromJson("{}")
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleJson = "{}" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEmptyBuilder() {
|
||||
val builder = Style.Builder()
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleJson = Style.EMPTY_JSON }
|
||||
}
|
||||
|
||||
@@ -72,12 +80,12 @@ class StyleTest {
|
||||
val layer = mockk<SymbolLayer>()
|
||||
every { layer.id } returns "1"
|
||||
val builder = Style.Builder().withLayer(layer)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) {
|
||||
nativeMapView.addLayerBelow(
|
||||
layer,
|
||||
MapboxConstants.LAYER_ID_ANNOTATIONS
|
||||
MapLibreConstants.LAYER_ID_ANNOTATIONS
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -87,8 +95,8 @@ class StyleTest {
|
||||
val layer = mockk<SymbolLayer>()
|
||||
every { layer.id } returns "1"
|
||||
val builder = Style.Builder().withLayerAbove(layer, "id")
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { nativeMapView.addLayerAbove(layer, "id") }
|
||||
}
|
||||
|
||||
@@ -97,8 +105,8 @@ class StyleTest {
|
||||
val layer = mockk<SymbolLayer>()
|
||||
every { layer.id } returns "1"
|
||||
val builder = Style.Builder().withLayerBelow(layer, "id")
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { nativeMapView.addLayerBelow(layer, "id") }
|
||||
}
|
||||
|
||||
@@ -107,8 +115,8 @@ class StyleTest {
|
||||
val layer = mockk<SymbolLayer>()
|
||||
every { layer.id } returns "1"
|
||||
val builder = Style.Builder().withLayerAt(layer, 1)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { nativeMapView.addLayerAt(layer, 1) }
|
||||
}
|
||||
|
||||
@@ -117,8 +125,8 @@ class StyleTest {
|
||||
val source = mockk<GeoJsonSource>()
|
||||
every { source.id } returns "1"
|
||||
val builder = Style.Builder().withSource(source)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { nativeMapView.addSource(source) }
|
||||
}
|
||||
|
||||
@@ -126,8 +134,8 @@ class StyleTest {
|
||||
fun testWithTransitionOptions() {
|
||||
val transitionOptions = TransitionOptions(100, 200)
|
||||
val builder = Style.Builder().withTransition(transitionOptions)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { nativeMapView.transitionOptions = transitionOptions }
|
||||
}
|
||||
|
||||
@@ -137,9 +145,9 @@ class StyleTest {
|
||||
every { source.id } returns "1"
|
||||
val builder =
|
||||
Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withSource(source)
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.addSource(source) }
|
||||
}
|
||||
|
||||
@@ -148,13 +156,13 @@ class StyleTest {
|
||||
val layer = mockk<SymbolLayer>()
|
||||
every { layer.id } returns "1"
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withLayer(layer)
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) {
|
||||
nativeMapView.addLayerBelow(
|
||||
layer,
|
||||
MapboxConstants.LAYER_ID_ANNOTATIONS
|
||||
MapLibreConstants.LAYER_ID_ANNOTATIONS
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -165,9 +173,9 @@ class StyleTest {
|
||||
every { layer.id } returns "1"
|
||||
val builder =
|
||||
Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withLayerAt(layer, 1)
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.addLayerAt(layer, 1) }
|
||||
}
|
||||
|
||||
@@ -177,9 +185,9 @@ class StyleTest {
|
||||
every { layer.id } returns "1"
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
|
||||
.withLayerBelow(layer, "below")
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.addLayerBelow(layer, "below") }
|
||||
}
|
||||
|
||||
@@ -189,9 +197,9 @@ class StyleTest {
|
||||
every { layer.id } returns "1"
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
|
||||
.withLayerBelow(layer, "below")
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.addLayerBelow(layer, "below") }
|
||||
}
|
||||
|
||||
@@ -200,9 +208,9 @@ class StyleTest {
|
||||
val transitionOptions = TransitionOptions(100, 200)
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
|
||||
.withTransition(transitionOptions)
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.transitionOptions = transitionOptions }
|
||||
}
|
||||
|
||||
@@ -211,9 +219,9 @@ class StyleTest {
|
||||
val callback = mockk<Style.OnStyleLoaded>()
|
||||
every { callback.onStyleLoaded(any()) } answers {}
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
|
||||
mapboxMap.setStyle(builder, callback)
|
||||
maplibreMap.setStyle(builder, callback)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { callback.onStyleLoaded(any()) }
|
||||
}
|
||||
|
||||
@@ -224,8 +232,8 @@ class StyleTest {
|
||||
val source = mockk<GeoJsonSource>()
|
||||
every { source.id } returns "1"
|
||||
val builder = Style.Builder().withSource(source)
|
||||
mapboxMap.setStyle(builder, callback)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder, callback)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { nativeMapView.addSource(source) }
|
||||
verify(exactly = 1) { callback.onStyleLoaded(any()) }
|
||||
}
|
||||
@@ -234,12 +242,12 @@ class StyleTest {
|
||||
fun testGetAsyncWith() {
|
||||
val callback = mockk<Style.OnStyleLoaded>()
|
||||
every { callback.onStyleLoaded(any()) } answers {}
|
||||
mapboxMap.getStyle(callback)
|
||||
maplibreMap.getStyle(callback)
|
||||
val source = mockk<GeoJsonSource>()
|
||||
every { source.id } returns "1"
|
||||
val builder = Style.Builder().withSource(source)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.onFinishLoadingStyle()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.onFinishLoadingStyle()
|
||||
verify(exactly = 1) { nativeMapView.addSource(source) }
|
||||
verify(exactly = 1) { callback.onStyleLoaded(any()) }
|
||||
}
|
||||
@@ -248,13 +256,13 @@ class StyleTest {
|
||||
fun testGetAsyncFrom() {
|
||||
val callback = mockk<Style.OnStyleLoaded>()
|
||||
every { callback.onStyleLoaded(any()) } answers {}
|
||||
mapboxMap.getStyle(callback)
|
||||
maplibreMap.getStyle(callback)
|
||||
val source = mockk<GeoJsonSource>()
|
||||
every { source.id } returns "1"
|
||||
val builder = Style.Builder().fromJson("{}")
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleJson = "{}" }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { callback.onStyleLoaded(any()) }
|
||||
}
|
||||
|
||||
@@ -262,21 +270,21 @@ class StyleTest {
|
||||
fun testGetAsyncWithFrom() {
|
||||
val callback = mockk<Style.OnStyleLoaded>()
|
||||
every { callback.onStyleLoaded(any()) } answers {}
|
||||
mapboxMap.getStyle(callback)
|
||||
maplibreMap.getStyle(callback)
|
||||
val source = mockk<GeoJsonSource>()
|
||||
every { source.id } returns "1"
|
||||
val builder =
|
||||
Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withSource(source)
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.addSource(source) }
|
||||
verify(exactly = 1) { callback.onStyleLoaded(any()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetNullStyle() {
|
||||
Assert.assertNull(mapboxMap.style)
|
||||
Assert.assertNull(maplibreMap.style)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -284,34 +292,34 @@ class StyleTest {
|
||||
val transitionOptions = TransitionOptions(100, 200)
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
|
||||
.withTransition(transitionOptions)
|
||||
mapboxMap.setStyle(builder)
|
||||
Assert.assertNull(mapboxMap.style)
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
Assert.assertNotNull(mapboxMap.style)
|
||||
maplibreMap.setStyle(builder)
|
||||
Assert.assertNull(maplibreMap.style)
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
Assert.assertNotNull(maplibreMap.style)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotReinvokeSameListener() {
|
||||
val callback = mockk<Style.OnStyleLoaded>()
|
||||
every { callback.onStyleLoaded(any()) } answers {}
|
||||
mapboxMap.getStyle(callback)
|
||||
maplibreMap.getStyle(callback)
|
||||
val source = mockk<GeoJsonSource>()
|
||||
every { source.id } returns "1"
|
||||
val builder = Style.Builder().fromJson("{}")
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleJson = "{}" }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
verify(exactly = 1) { callback.onStyleLoaded(any()) }
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException::class)
|
||||
fun testIllegalStateExceptionWithStyleReload() {
|
||||
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
val style = mapboxMap.style
|
||||
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
val style = maplibreMap.style
|
||||
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
|
||||
style!!.addLayer(mockk<SymbolLayer>())
|
||||
}
|
||||
|
||||
@@ -320,10 +328,10 @@ class StyleTest {
|
||||
val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
|
||||
val builder =
|
||||
Style.Builder().fromUrl(Style.getPredefinedStyle("Satellite Hybrid")).withImage("id", bitmap)
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Satellite Hybrid") }
|
||||
verify(exactly = 0) { nativeMapView.addImages(any()) }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.addImages(any()) }
|
||||
}
|
||||
|
||||
@@ -334,10 +342,10 @@ class StyleTest {
|
||||
drawable.intrinsicWidth = 10
|
||||
val builder =
|
||||
Style.Builder().fromUrl(Style.getPredefinedStyle("Satellite Hybrid")).withImage("id", drawable)
|
||||
mapboxMap.setStyle(builder)
|
||||
maplibreMap.setStyle(builder)
|
||||
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Satellite Hybrid") }
|
||||
verify(exactly = 0) { nativeMapView.addImages(any()) }
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
verify(exactly = 1) { nativeMapView.addImages(any()) }
|
||||
}
|
||||
|
||||
@@ -349,18 +357,18 @@ class StyleTest {
|
||||
every { source2.id } returns "source1" // same ID
|
||||
|
||||
val builder = Style.Builder().withSource(source1)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
|
||||
every { nativeMapView.addSource(any()) } throws CannotAddSourceException("Duplicate ID")
|
||||
|
||||
try {
|
||||
mapboxMap.style!!.addSource(source2)
|
||||
maplibreMap.style!!.addSource(source2)
|
||||
} catch (ex: Exception) {
|
||||
Assert.assertEquals(
|
||||
"Source that failed to be added shouldn't be cached",
|
||||
source1,
|
||||
mapboxMap.style!!.getSource("source1")
|
||||
maplibreMap.style!!.getSource("source1")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -373,18 +381,18 @@ class StyleTest {
|
||||
every { layer2.id } returns "layer1" // same ID
|
||||
|
||||
val builder = Style.Builder().withLayer(layer1)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
|
||||
every { nativeMapView.addLayer(any()) } throws CannotAddLayerException("Duplicate ID")
|
||||
|
||||
try {
|
||||
mapboxMap.style!!.addLayer(layer2)
|
||||
maplibreMap.style!!.addLayer(layer2)
|
||||
} catch (ex: Exception) {
|
||||
Assert.assertEquals(
|
||||
"Layer that failed to be added shouldn't be cached",
|
||||
layer1,
|
||||
mapboxMap.style!!.getLayer("layer1")
|
||||
maplibreMap.style!!.getLayer("layer1")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -397,8 +405,8 @@ class StyleTest {
|
||||
every { layer2.id } returns "layer1" // same ID
|
||||
|
||||
val builder = Style.Builder().withLayer(layer1)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
|
||||
every {
|
||||
nativeMapView.addLayerBelow(
|
||||
@@ -408,12 +416,12 @@ class StyleTest {
|
||||
} throws CannotAddLayerException("Duplicate ID")
|
||||
|
||||
try {
|
||||
mapboxMap.style!!.addLayerBelow(layer2, "")
|
||||
maplibreMap.style!!.addLayerBelow(layer2, "")
|
||||
} catch (ex: Exception) {
|
||||
Assert.assertEquals(
|
||||
"Layer that failed to be added shouldn't be cached",
|
||||
layer1,
|
||||
mapboxMap.style!!.getLayer("layer1")
|
||||
maplibreMap.style!!.getLayer("layer1")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -426,8 +434,8 @@ class StyleTest {
|
||||
every { layer2.id } returns "layer1" // same ID
|
||||
|
||||
val builder = Style.Builder().withLayer(layer1)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
|
||||
every {
|
||||
nativeMapView.addLayerAbove(
|
||||
@@ -437,12 +445,12 @@ class StyleTest {
|
||||
} throws CannotAddLayerException("Duplicate ID")
|
||||
|
||||
try {
|
||||
mapboxMap.style!!.addLayerAbove(layer2, "")
|
||||
maplibreMap.style!!.addLayerAbove(layer2, "")
|
||||
} catch (ex: Exception) {
|
||||
Assert.assertEquals(
|
||||
"Layer that failed to be added shouldn't be cached",
|
||||
layer1,
|
||||
mapboxMap.style!!.getLayer("layer1")
|
||||
maplibreMap.style!!.getLayer("layer1")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -455,18 +463,18 @@ class StyleTest {
|
||||
every { layer2.id } returns "layer1" // same ID
|
||||
|
||||
val builder = Style.Builder().withLayer(layer1)
|
||||
mapboxMap.setStyle(builder)
|
||||
mapboxMap.notifyStyleLoaded()
|
||||
maplibreMap.setStyle(builder)
|
||||
maplibreMap.notifyStyleLoaded()
|
||||
|
||||
every { nativeMapView.addLayerAt(any(), 5) } throws CannotAddLayerException("Duplicate ID")
|
||||
|
||||
try {
|
||||
mapboxMap.style!!.addLayerAt(layer2, 5)
|
||||
maplibreMap.style!!.addLayerAt(layer2, 5)
|
||||
} catch (ex: Exception) {
|
||||
Assert.assertEquals(
|
||||
"Layer that failed to be added shouldn't be cached",
|
||||
layer1,
|
||||
mapboxMap.style!!.getLayer("layer1")
|
||||
maplibreMap.style!!.getLayer("layer1")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.os.Looper.getMainLooper
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import org.maplibre.android.camera.CameraPosition
|
||||
import org.maplibre.android.camera.CameraUpdateFactory
|
||||
import org.maplibre.android.geometry.LatLng
|
||||
import io.mockk.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -42,10 +42,10 @@ class TransformTest {
|
||||
|
||||
@Test
|
||||
fun testMoveCamera() {
|
||||
val mapboxMap = mockk<MapboxMap>()
|
||||
every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
val maplibreMap = mockk<MapLibreMap>()
|
||||
every { maplibreMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.CancelableCallback>()
|
||||
every { callback.onFinish() } answers {}
|
||||
|
||||
val target = LatLng(1.0, 2.0)
|
||||
@@ -54,7 +54,7 @@ class TransformTest {
|
||||
|
||||
transform.cameraPosition
|
||||
every { nativeMapView.cameraPosition } returns expected
|
||||
transform.moveCamera(mapboxMap, update, callback)
|
||||
transform.moveCamera(maplibreMap, update, callback)
|
||||
|
||||
mainLooper.idle()
|
||||
verify { cameraChangeDispatcher.onCameraMove() }
|
||||
@@ -64,17 +64,17 @@ class TransformTest {
|
||||
|
||||
@Test
|
||||
fun testMoveCameraToSamePosition() {
|
||||
val mapboxMap = mockk<MapboxMap>()
|
||||
every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
val maplibreMap = mockk<MapLibreMap>()
|
||||
every { maplibreMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.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)
|
||||
transform.moveCamera(maplibreMap, update, null) // Initialize camera position
|
||||
transform.moveCamera(maplibreMap, update, callback)
|
||||
|
||||
verify(exactly = 1, verifyBlock = { nativeMapView.jumpTo(any(), any(), any(), any(), any()) })
|
||||
verify { callback.onFinish() }
|
||||
@@ -82,20 +82,20 @@ class TransformTest {
|
||||
|
||||
@Test
|
||||
fun testEaseCamera() {
|
||||
val mapboxMap = mockk<MapboxMap>()
|
||||
every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
val maplibreMap = mockk<MapLibreMap>()
|
||||
every { maplibreMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
|
||||
every { mapView.addOnCameraDidChangeListener(any()) } answers { transform.onCameraDidChange(true) }
|
||||
every { mapView.removeOnCameraDidChangeListener(any()) } answers {}
|
||||
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.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)
|
||||
transform.easeCamera(maplibreMap, update, 100, false, callback)
|
||||
|
||||
mainLooper.idle()
|
||||
verify { nativeMapView.easeTo(target, -1.0, -1.0, -1.0, null, 100, false) }
|
||||
@@ -104,17 +104,17 @@ class TransformTest {
|
||||
|
||||
@Test
|
||||
fun testEaseCameraToSamePosition() {
|
||||
val mapboxMap = mockk<MapboxMap>()
|
||||
every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
val maplibreMap = mockk<MapLibreMap>()
|
||||
every { maplibreMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.CancelableCallback>()
|
||||
every { callback.onFinish() } answers {}
|
||||
|
||||
val expected = CameraPosition.DEFAULT
|
||||
val update = CameraUpdateFactory.newCameraPosition(expected)
|
||||
transform.moveCamera(mapboxMap, update, null)
|
||||
transform.moveCamera(maplibreMap, update, null)
|
||||
|
||||
transform.easeCamera(mapboxMap, update, 100, false, callback)
|
||||
transform.easeCamera(maplibreMap, update, 100, false, callback)
|
||||
|
||||
verify(exactly = 0, verifyBlock = { nativeMapView.easeTo(any(), any(), any(), any(), any(), any(), any()) })
|
||||
verify { callback.onFinish() }
|
||||
@@ -122,20 +122,20 @@ class TransformTest {
|
||||
|
||||
@Test
|
||||
fun testAnimateCamera() {
|
||||
val mapboxMap = mockk<MapboxMap>()
|
||||
every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
val maplibreMap = mockk<MapLibreMap>()
|
||||
every { maplibreMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
|
||||
every { mapView.addOnCameraDidChangeListener(any()) } answers { transform.onCameraDidChange(true) }
|
||||
every { mapView.removeOnCameraDidChangeListener(any()) } answers {}
|
||||
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.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)
|
||||
transform.animateCamera(maplibreMap, update, 100, callback)
|
||||
|
||||
mainLooper.idle()
|
||||
verify { nativeMapView.flyTo(target, -1.0, -1.0, -1.0, null, 100) }
|
||||
@@ -144,17 +144,17 @@ class TransformTest {
|
||||
|
||||
@Test
|
||||
fun testAnimateCameraToSamePosition() {
|
||||
val mapboxMap = mockk<MapboxMap>()
|
||||
every { mapboxMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
val maplibreMap = mockk<MapLibreMap>()
|
||||
every { maplibreMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
|
||||
val callback = mockk<MapboxMap.CancelableCallback>()
|
||||
val callback = mockk<MapLibreMap.CancelableCallback>()
|
||||
every { callback.onFinish() } answers {}
|
||||
|
||||
val expected = CameraPosition.DEFAULT
|
||||
val update = CameraUpdateFactory.newCameraPosition(expected)
|
||||
transform.moveCamera(mapboxMap, update, null)
|
||||
transform.moveCamera(maplibreMap, update, null)
|
||||
|
||||
transform.animateCamera(mapboxMap, update, 100, callback)
|
||||
transform.animateCamera(maplibreMap, update, 100, callback)
|
||||
|
||||
verify(exactly = 0, verifyBlock = { nativeMapView.flyTo(any(), any(), any(), any(), any(), any()) })
|
||||
verify { callback.onFinish() }
|
||||
@@ -190,21 +190,21 @@ class TransformTest {
|
||||
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 maplibreMap = mockk<MapLibreMap>()
|
||||
every { maplibreMap.cameraPosition } answers { CameraPosition.DEFAULT }
|
||||
|
||||
val target = LatLng(1.0, 2.0)
|
||||
val expected = CameraPosition.Builder().target(target).build()
|
||||
|
||||
val callback = object : MapboxMap.CancelableCallback {
|
||||
val callback = object : MapLibreMap.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(maplibreMap, CameraUpdateFactory.newCameraPosition(expected), 500, null)
|
||||
}
|
||||
}
|
||||
transform.animateCamera(mapboxMap, CameraUpdateFactory.newCameraPosition(expected), 500, callback)
|
||||
transform.animateCamera(maplibreMap, CameraUpdateFactory.newCameraPosition(expected), 500, callback)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.maps
|
||||
package org.maplibre.android.maps
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
@@ -6,8 +6,8 @@ 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.maplibre.android.camera.CameraPosition
|
||||
import org.maplibre.android.maps.widgets.CompassView
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -56,7 +56,7 @@ class UiSettingsTest {
|
||||
FrameLayout.LayoutParams::class.java
|
||||
)
|
||||
private var uiSettings: UiSettings? = null
|
||||
private val mapboxMapOptions: MapboxMapOptions? = null
|
||||
private val maplibreMapOptions: MapLibreMapOptions? = null
|
||||
|
||||
@Before
|
||||
fun beforeTest() {
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.mapbox.mapboxsdk.module.http
|
||||
package org.maplibre.android.module.http
|
||||
|
||||
import com.mapbox.mapboxsdk.MapboxInjector
|
||||
import com.mapbox.mapboxsdk.http.HttpRequestUrl
|
||||
import com.mapbox.mapboxsdk.utils.ConfigUtils
|
||||
import org.maplibre.android.MapLibreInjector
|
||||
import org.maplibre.android.http.HttpRequestUrl
|
||||
import org.maplibre.android.utils.ConfigUtils
|
||||
import io.mockk.mockk
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -16,7 +16,7 @@ class HttpRequestUrlTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MapboxInjector.inject(mockk(relaxed = true), "pk.foobar", ConfigUtils.getMockedOptions())
|
||||
MapLibreInjector.inject(mockk(relaxed = true), "pk.foobar", ConfigUtils.getMockedOptions())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,6 +49,6 @@ class HttpRequestUrlTest {
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
MapboxInjector.clear()
|
||||
MapLibreInjector.clear()
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.module.http
|
||||
package org.maplibre.android.module.http
|
||||
|
||||
import com.mapbox.mapboxsdk.MapboxInjector
|
||||
import com.mapbox.mapboxsdk.utils.ConfigUtils
|
||||
import org.maplibre.android.MapLibreInjector
|
||||
import org.maplibre.android.utils.ConfigUtils
|
||||
import io.mockk.mockk
|
||||
import okhttp3.OkHttpClient
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -14,7 +14,7 @@ class HttpRequestUtilTest {
|
||||
|
||||
@Test
|
||||
fun replaceHttpClient() {
|
||||
MapboxInjector.inject(mockk(relaxed = true), "", ConfigUtils.getMockedOptions())
|
||||
MapLibreInjector.inject(mockk(relaxed = true), "", ConfigUtils.getMockedOptions())
|
||||
|
||||
assertEquals(HttpRequestImpl.DEFAULT_CLIENT, HttpRequestImpl.client)
|
||||
|
||||
@@ -33,6 +33,6 @@ class HttpRequestUtilTest {
|
||||
HttpRequestImpl.client
|
||||
)
|
||||
|
||||
MapboxInjector.clear()
|
||||
MapLibreInjector.clear()
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,14 @@ package com.mapbox.mapboxsdk.style.expressions
|
||||
import android.graphics.Color
|
||||
import com.mapbox.geojson.Point
|
||||
import com.mapbox.geojson.Polygon
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyValue
|
||||
import com.mapbox.mapboxsdk.utils.ColorUtils
|
||||
import org.maplibre.android.style.expressions.Expression.FormatOption
|
||||
import org.maplibre.android.style.layers.PropertyFactory
|
||||
import org.maplibre.android.style.layers.PropertyValue
|
||||
import org.maplibre.android.utils.ColorUtils
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.maplibre.android.style.expressions.Expression
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import java.util.*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.utils
|
||||
package org.maplibre.android.utils
|
||||
|
||||
import android.graphics.Color
|
||||
import org.junit.Assert
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.utils
|
||||
package org.maplibre.android.utils
|
||||
|
||||
import com.mapbox.mapboxsdk.util.DefaultStyle
|
||||
import com.mapbox.mapboxsdk.util.TileServerOptions
|
||||
import org.maplibre.android.util.DefaultStyle
|
||||
import org.maplibre.android.util.TileServerOptions
|
||||
|
||||
class ConfigUtils {
|
||||
companion object {
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.utils;
|
||||
package org.maplibre.android.utils;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
Reference in New Issue
Block a user