[android] updated naming scheme and packages structure for LocationLayerPlugin, now called LocationComponent
This commit is contained in:
committed by
Łukasz Paczos
parent
cf7752c80c
commit
907612e93d
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
@@ -19,7 +19,7 @@ import static org.mockito.Mockito.when;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CompassEngineTest {
|
||||
|
||||
private LocationLayerCompassEngine compassEngine;
|
||||
private LocationComponentCompassEngine compassEngine;
|
||||
|
||||
@Mock
|
||||
private WindowManager windowManager;
|
||||
@@ -29,7 +29,7 @@ public class CompassEngineTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
compassEngine = new LocationLayerCompassEngine(windowManager, sensorManager);
|
||||
compassEngine = new LocationComponentCompassEngine(windowManager, sensorManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ public class CompassEngineTest {
|
||||
public void whenGyroscopeIsNull_fallbackToGravity() {
|
||||
SensorManager sensorManager = mock(SensorManager.class);
|
||||
when(sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)).thenReturn(null);
|
||||
new LocationLayerCompassEngine(windowManager, sensorManager);
|
||||
new LocationComponentCompassEngine(windowManager, sensorManager);
|
||||
|
||||
verify(sensorManager, times(1)).getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class CompassEngineTest {
|
||||
public void whenGyroscopeIsNull_fallbackToMagneticField() {
|
||||
SensorManager sensorManager = mock(SensorManager.class);
|
||||
when(sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)).thenReturn(null);
|
||||
new LocationLayerCompassEngine(windowManager, sensorManager);
|
||||
new LocationComponentCompassEngine(windowManager, sensorManager);
|
||||
|
||||
verify(sensorManager, times(1)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.graphics.PointF;
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.mapbox.android.gestures.MoveGestureDetector;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdate;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.location.modes.CameraMode;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.Projection;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.CameraMode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -19,13 +19,13 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class LocationLayerCameraTest {
|
||||
public class LocationCameraControllerTest {
|
||||
|
||||
@Test
|
||||
public void setCameraMode_mapTransitionsAreCancelled() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
|
||||
@@ -35,8 +35,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_gestureThresholdIsAdjusted() {
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
LocationLayerCamera camera = buildCamera(moveGestureDetector);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationCameraController camera = buildCamera(moveGestureDetector);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
float moveThreshold = 5f;
|
||||
when(options.trackingInitialMoveThreshold()).thenReturn(moveThreshold);
|
||||
camera.initializeOptions(options);
|
||||
@@ -49,8 +49,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_gestureThresholdIsResetWhenNotTracking() {
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
LocationLayerCamera camera = buildCamera(moveGestureDetector);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(moveGestureDetector);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
|
||||
@@ -61,8 +61,8 @@ public class LocationLayerCameraTest {
|
||||
public void setCameraMode_notTrackingAdjustsFocalPoint() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
@@ -73,8 +73,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_trackingChangeListenerCameraDismissedIsCalled() {
|
||||
OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
LocationLayerCamera camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
@@ -85,8 +85,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void setCameraMode_internalCameraTrackingChangeListenerIsCalled() {
|
||||
OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
LocationLayerCamera camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(internalTrackingChangedListener);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
int cameraMode = CameraMode.NONE;
|
||||
|
||||
camera.setCameraMode(cameraMode);
|
||||
@@ -99,8 +99,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -114,8 +114,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -129,8 +129,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -144,8 +144,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_COMPASS);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -159,8 +159,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
when(mapboxMap.getProjection()).thenReturn(mock(Projection.class));
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -178,8 +178,8 @@ public class LocationLayerCameraTest {
|
||||
PointF pointF = mock(PointF.class);
|
||||
when(projection.toScreenLocation(any(LatLng.class))).thenReturn(pointF);
|
||||
when(mapboxMap.getProjection()).thenReturn(projection);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING);
|
||||
LatLng latLng = mock(LatLng.class);
|
||||
|
||||
@@ -191,8 +191,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewGpsBearingValue_cameraModeTrackingGpsUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -204,8 +204,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewGpsBearingValue_cameraModeNoneGpsUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE_GPS);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -219,8 +219,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder().bearing(7d).build();
|
||||
when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -234,8 +234,8 @@ public class LocationLayerCameraTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder().bearing(0d).build();
|
||||
when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_GPS_NORTH);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -247,8 +247,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewGpsBearingValue_cameraModeNoneIgnored() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
float gpsBearing = 5f;
|
||||
|
||||
@@ -260,8 +260,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewCompassBearingValue_cameraModeTrackingCompassUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING_COMPASS);
|
||||
float compassBearing = 5f;
|
||||
|
||||
@@ -273,8 +273,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewCompassBearingValue_cameraModeNoneCompassUpdatesBearing() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE_COMPASS);
|
||||
float compassBearing = 5f;
|
||||
|
||||
@@ -286,8 +286,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewCompassBearingValue_cameraModeNoneIgnored() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.NONE);
|
||||
float compassBearing = 5f;
|
||||
|
||||
@@ -299,8 +299,8 @@ public class LocationLayerCameraTest {
|
||||
@Test
|
||||
public void onNewZoomValue_cameraIsUpdated() {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LocationLayerCamera camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationLayerOptions.class));
|
||||
LocationCameraController camera = buildCamera(mapboxMap);
|
||||
camera.initializeOptions(mock(LocationComponentOptions.class));
|
||||
camera.setCameraMode(CameraMode.TRACKING);
|
||||
float zoom = 5f;
|
||||
|
||||
@@ -309,29 +309,29 @@ public class LocationLayerCameraTest {
|
||||
verify(mapboxMap).moveCamera(any(CameraUpdate.class));
|
||||
}
|
||||
|
||||
private LocationLayerCamera buildCamera(OnCameraTrackingChangedListener onCameraTrackingChangedListener) {
|
||||
private LocationCameraController buildCamera(OnCameraTrackingChangedListener onCameraTrackingChangedListener) {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
|
||||
return new LocationLayerCamera(mapboxMap, moveGestureDetector,
|
||||
return new LocationCameraController(mapboxMap, moveGestureDetector,
|
||||
onCameraTrackingChangedListener, onCameraMoveInvalidateListener);
|
||||
}
|
||||
|
||||
private LocationLayerCamera buildCamera(MoveGestureDetector moveGestureDetector) {
|
||||
private LocationCameraController buildCamera(MoveGestureDetector moveGestureDetector) {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class));
|
||||
OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
|
||||
return new LocationLayerCamera(mapboxMap, moveGestureDetector,
|
||||
return new LocationCameraController(mapboxMap, moveGestureDetector,
|
||||
onCameraTrackingChangedListener, onCameraMoveInvalidateListener);
|
||||
}
|
||||
|
||||
private LocationLayerCamera buildCamera(MapboxMap mapboxMap) {
|
||||
private LocationCameraController buildCamera(MapboxMap mapboxMap) {
|
||||
MoveGestureDetector moveGestureDetector = mock(MoveGestureDetector.class);
|
||||
OnCameraTrackingChangedListener onCameraTrackingChangedListener = mock(OnCameraTrackingChangedListener.class);
|
||||
OnCameraMoveInvalidateListener onCameraMoveInvalidateListener = mock(OnCameraMoveInvalidateListener.class);
|
||||
return new LocationLayerCamera(mapboxMap, moveGestureDetector,
|
||||
return new LocationCameraController(mapboxMap, moveGestureDetector,
|
||||
onCameraTrackingChangedListener, onCameraMoveInvalidateListener);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class LocationLayerOptionsTest {
|
||||
public class LocationComponentOptionsTest {
|
||||
|
||||
@Mock
|
||||
private Context context;
|
||||
@@ -32,27 +32,27 @@ public class LocationLayerOptionsTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
when(context.obtainStyledAttributes(R.style.mapbox_LocationLayer, R.styleable.mapbox_LocationLayer))
|
||||
when(context.obtainStyledAttributes(R.style.mapbox_LocationComponent, R.styleable.mapbox_LocationComponent))
|
||||
.thenReturn(array);
|
||||
when(array.getResourceId(R.styleable.mapbox_LocationLayer_mapbox_foregroundDrawable, -1))
|
||||
when(array.getResourceId(R.styleable.mapbox_LocationComponent_mapbox_foregroundDrawable, -1))
|
||||
.thenReturn(R.drawable.mapbox_user_icon);
|
||||
when(context.getResources()).thenReturn(resources);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sanity() throws Exception {
|
||||
LocationLayerOptions locationLayerOptions = LocationLayerOptions.builder(context)
|
||||
LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(context)
|
||||
.accuracyAlpha(0.5f)
|
||||
.build();
|
||||
assertNotNull(locationLayerOptions);
|
||||
assertNotNull(locationComponentOptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void passingOutOfRangeAccuracyAlpha_throwsException() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Location layer accuracy alpha value must be between 0.0 and "
|
||||
thrown.expectMessage("Accuracy alpha value must be between 0.0 and "
|
||||
+ "1.0.");
|
||||
LocationLayerOptions.builder(context)
|
||||
LocationComponentOptions.builder(context)
|
||||
.accuracyAlpha(2f)
|
||||
.build();
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class LocationLayerOptionsTest {
|
||||
public void negativeElevation_causesExceptionToBeThrown() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid shadow size -500.0. Must be >= 0");
|
||||
LocationLayerOptions.builder(context)
|
||||
LocationComponentOptions.builder(context)
|
||||
.elevation(-500)
|
||||
.build();
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.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.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BACKGROUND_ICON;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BACKGROUND_LAYER;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BACKGROUND_STALE_ICON;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BEARING_ICON;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.BEARING_LAYER;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.FOREGROUND_ICON;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.FOREGROUND_LAYER;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.FOREGROUND_STALE_ICON;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.LOCATION_SOURCE;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_ACCURACY_RADIUS;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_COMPASS_BEARING;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_GPS_BEARING;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.PROPERTY_SHADOW_ICON_OFFSET;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.SHADOW_ICON;
|
||||
import static com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.SHADOW_LAYER;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_ICON;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_LAYER;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_STALE_ICON;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_ICON;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_LAYER;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_ICON;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_LAYER;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_STALE_ICON;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.LOCATION_SOURCE;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_RADIUS;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_SHADOW_ICON_OFFSET;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
|
||||
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_LAYER;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class LocationLayerTest {
|
||||
public class LocationLayerControllerTest {
|
||||
|
||||
@Test
|
||||
public void onInitialization_locationSourceIsAdded() {
|
||||
@@ -44,9 +44,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addSource(locationSource);
|
||||
}
|
||||
@@ -60,9 +60,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(shadowLayer, BACKGROUND_LAYER);
|
||||
}
|
||||
@@ -76,9 +76,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(backgroundLayer, FOREGROUND_LAYER);
|
||||
}
|
||||
@@ -92,9 +92,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(foregroundLayer, BEARING_LAYER);
|
||||
}
|
||||
@@ -108,11 +108,11 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
String layerBelow = "layer-below";
|
||||
when(options.layerBelow()).thenReturn(layerBelow);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(bearingLayer, layerBelow);
|
||||
}
|
||||
@@ -126,9 +126,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addLayerBelow(accuracyLayer, BACKGROUND_LAYER);
|
||||
}
|
||||
@@ -140,12 +140,12 @@ public class LocationLayerTest {
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationLayerOptions.class))).thenReturn(bitmap);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
when(options.elevation()).thenReturn(2f);
|
||||
|
||||
// Style is applied on initialization
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(SHADOW_ICON, bitmap);
|
||||
}
|
||||
@@ -157,11 +157,11 @@ public class LocationLayerTest {
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationLayerOptions.class))).thenReturn(bitmap);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
when(bitmapProvider.generateShadowBitmap(any(LocationComponentOptions.class))).thenReturn(bitmap);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
when(options.elevation()).thenReturn(0f);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap, times(0)).addImage(SHADOW_ICON, bitmap);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.foregroundDrawable()).thenReturn(drawableResId);
|
||||
@@ -180,7 +180,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(FOREGROUND_ICON, bitmap);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.foregroundDrawableStale()).thenReturn(drawableResId);
|
||||
@@ -199,7 +199,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(FOREGROUND_STALE_ICON, bitmap);
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.backgroundDrawable()).thenReturn(drawableResId);
|
||||
@@ -218,7 +218,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(BACKGROUND_ICON, bitmap);
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.backgroundDrawableStale()).thenReturn(drawableResId);
|
||||
@@ -237,7 +237,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(BACKGROUND_STALE_ICON, bitmap);
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class LocationLayerTest {
|
||||
MapboxMap mapboxMap = mock(MapboxMap.class);
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(mock(GeoJsonSource.class));
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
int drawableResId = 123;
|
||||
int tintColor = 456;
|
||||
when(options.bearingDrawable()).thenReturn(drawableResId);
|
||||
@@ -256,7 +256,7 @@ public class LocationLayerTest {
|
||||
Bitmap bitmap = mock(Bitmap.class);
|
||||
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
|
||||
|
||||
new LocationLayer(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
|
||||
|
||||
verify(mapboxMap).addImage(BEARING_ICON, bitmap);
|
||||
}
|
||||
@@ -268,9 +268,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
|
||||
@@ -286,9 +286,9 @@ public class LocationLayerTest {
|
||||
GeoJsonSource locationSource = mock(GeoJsonSource.class);
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
|
||||
@@ -305,9 +305,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
|
||||
@@ -325,9 +325,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.GPS);
|
||||
@@ -346,9 +346,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.COMPASS);
|
||||
@@ -367,9 +367,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.COMPASS);
|
||||
@@ -388,9 +388,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.GPS);
|
||||
@@ -409,9 +409,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
float accuracyRadiusValue = 2f;
|
||||
@@ -429,9 +429,9 @@ public class LocationLayerTest {
|
||||
LayerSourceProvider sourceProvider = buildLayerProvider();
|
||||
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
|
||||
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
|
||||
LocationLayerOptions options = mock(LocationLayerOptions.class);
|
||||
LocationComponentOptions options = mock(LocationComponentOptions.class);
|
||||
Feature locationFeature = mock(Feature.class);
|
||||
LocationLayer layer = new LocationLayer(
|
||||
LocationLayerController layer = new LocationLayerController(
|
||||
mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
|
||||
);
|
||||
layer.setRenderMode(RenderMode.GPS);
|
||||
@@ -442,13 +442,13 @@ public class LocationLayerTest {
|
||||
verify(locationFeature, times(0)).addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracyRadiusValue);
|
||||
}
|
||||
|
||||
private LayerFeatureProvider buildFeatureProvider(LocationLayerOptions options) {
|
||||
private LayerFeatureProvider buildFeatureProvider(LocationComponentOptions options) {
|
||||
LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
|
||||
when(provider.generateLocationFeature(null, options)).thenReturn(mock(Feature.class));
|
||||
return provider;
|
||||
}
|
||||
|
||||
private LayerFeatureProvider buildFeatureProvider(Feature feature, LocationLayerOptions options) {
|
||||
private LayerFeatureProvider buildFeatureProvider(Feature feature, LocationComponentOptions options) {
|
||||
LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
|
||||
when(provider.generateLocationFeature(null, options)).thenReturn(feature);
|
||||
return provider;
|
||||
@@ -0,0 +1,284 @@
|
||||
package com.mapbox.mapboxsdk.location
|
||||
|
||||
import android.location.Location
|
||||
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 junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class MapboxAnimatorCoordinatorTest {
|
||||
|
||||
private lateinit var locationAnimatorCoordinator: LocationAnimatorCoordinator
|
||||
private val cameraPosition: CameraPosition = CameraPosition.DEFAULT
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
locationAnimatorCoordinator = LocationAnimatorCoordinator()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorsAreCreated() {
|
||||
locationAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, false)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
val cameraLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorsAreCreated() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
locationAnimatorCoordinator.feedNewLocation(location, cameraPosition, true)
|
||||
|
||||
val cameraLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(0f, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorsAreCreated() {
|
||||
locationAnimatorCoordinator.feedNewCompassBearing(77f, cameraPosition)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING] != null)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorValue() {
|
||||
val bearing = 77f
|
||||
locationAnimatorCoordinator.feedNewCompassBearing(bearing, cameraPosition)
|
||||
|
||||
val cameraBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(150f, false)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorValue() {
|
||||
val accuracy = 150f
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(accuracy, false)
|
||||
|
||||
val layerAccuracy = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(LocationComponentConstants.ACCURACY_RADIUS_ANIMATION_DURATION, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(150f, true)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorValue() {
|
||||
val accuracy = 150f
|
||||
locationAnimatorCoordinator.feedNewAccuracyRadius(accuracy, true)
|
||||
|
||||
val layerAccuracy = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(0L, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorValue() {
|
||||
val zoom = 15.0f
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(
|
||||
zoom.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_ZOOM_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.target as Float
|
||||
assertEquals(zoom, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorsCreated() {
|
||||
locationAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorValue() {
|
||||
val tilt = 30.0f
|
||||
locationAnimatorCoordinator.feedNewTilt(
|
||||
tilt.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_TILT_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.target as Float
|
||||
assertEquals(tilt, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelAllAnimators() {
|
||||
locationAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, true)
|
||||
locationAnimatorCoordinator.cancelAllAnimations()
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelZoomAnimators() {
|
||||
locationAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
locationAnimatorCoordinator.cancelZoomAnimation()
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelTiltAnimation() {
|
||||
locationAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
locationAnimatorCoordinator.cancelTiltAnimation()
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap[ANIMATOR_TILT] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resetAllCameraAnimations_empty() {
|
||||
locationAnimatorCoordinator.resetAllCameraAnimations(cameraPosition, false)
|
||||
assertTrue(locationAnimatorCoordinator.animatorMap.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addLayerListener(layerListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.layerListeners.contains(layerListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addLayerListener(layerListener)
|
||||
locationAnimatorCoordinator.removeLayerListener(layerListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.layerListeners.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.cameraListeners.contains(cameraListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
locationAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
locationAnimatorCoordinator.removeCameraListener(cameraListener)
|
||||
|
||||
assertTrue(locationAnimatorCoordinator.cameraListeners.isEmpty())
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer;
|
||||
package com.mapbox.mapboxsdk.location;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -6,7 +6,6 @@ import static junit.framework.Assert.assertEquals;
|
||||
|
||||
public final class UtilsTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void shortestRotation_doesReturnValueDistanceQuickestToZero() throws Exception {
|
||||
float value = Utils.shortestRotation(0, 181);
|
||||
@@ -1,284 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.plugins.locationlayer
|
||||
|
||||
import android.location.Location
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.DEFAULT_TRACKING_TILT_ANIM_DURATION
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerConstants.DEFAULT_TRACKING_ZOOM_ANIM_DURATION
|
||||
import com.mapbox.mapboxsdk.plugins.locationlayer.PluginAnimator.*
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class PluginAnimatorCoordinatorTest {
|
||||
|
||||
private lateinit var pluginAnimatorCoordinator: PluginAnimatorCoordinator
|
||||
private val cameraPosition: CameraPosition = CameraPosition.DEFAULT
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
pluginAnimatorCoordinator = PluginAnimatorCoordinator()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorsAreCreated() {
|
||||
pluginAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, false)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
pluginAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
val cameraLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorsAreCreated() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
pluginAnimatorCoordinator.feedNewLocation(location, cameraPosition, false)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewLocation_isNorth_animatorValue() {
|
||||
val location = Location("")
|
||||
location.latitude = 51.0
|
||||
location.longitude = 17.0
|
||||
location.bearing = 35f
|
||||
pluginAnimatorCoordinator.feedNewLocation(location, cameraPosition, true)
|
||||
|
||||
val cameraLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG]?.target as LatLng
|
||||
assertEquals(cameraLatLngTarget.latitude, cameraLatLngTarget.latitude)
|
||||
|
||||
val layerLatLngTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_LATLNG]?.target as LatLng
|
||||
assertEquals(layerLatLngTarget.latitude, layerLatLngTarget.latitude)
|
||||
|
||||
val cameraBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_GPS_BEARING]?.target as Float
|
||||
assertEquals(0f, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_GPS_BEARING]?.target as Float
|
||||
assertEquals(location.bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorsAreCreated() {
|
||||
pluginAnimatorCoordinator.feedNewCompassBearing(77f, cameraPosition)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING] != null)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewCompassBearing_animatorValue() {
|
||||
val bearing = 77f
|
||||
pluginAnimatorCoordinator.feedNewCompassBearing(bearing, cameraPosition)
|
||||
|
||||
val cameraBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, cameraBearingTarget)
|
||||
|
||||
val layerBearingTarget = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_COMPASS_BEARING]?.target as Float
|
||||
assertEquals(bearing, layerBearingTarget)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(150f, false)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_animatorValue() {
|
||||
val accuracy = 150f
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(accuracy, false)
|
||||
|
||||
val layerAccuracy = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(LocationLayerConstants.ACCURACY_RADIUS_ANIMATION_DURATION, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(150f, true)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewAccuracyRadius_noAnimation_animatorValue() {
|
||||
val accuracy = 150f
|
||||
pluginAnimatorCoordinator.feedNewAccuracyRadius(accuracy, true)
|
||||
|
||||
val layerAccuracy = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.target as Float
|
||||
assertEquals(layerAccuracy, accuracy)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_LAYER_ACCURACY]?.duration as Long
|
||||
assertEquals(0L, animationDuration)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewZoomLevel_animatorValue() {
|
||||
val zoom = 15.0f
|
||||
pluginAnimatorCoordinator.feedNewZoomLevel(
|
||||
zoom.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_ZOOM_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM]?.target as Float
|
||||
assertEquals(zoom, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorsCreated() {
|
||||
pluginAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT] != null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun feedNewTiltLevel_animatorValue() {
|
||||
val tilt = 30.0f
|
||||
pluginAnimatorCoordinator.feedNewTilt(
|
||||
tilt.toDouble(),
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
val animationDuration = pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.duration as Long
|
||||
assertEquals(DEFAULT_TRACKING_TILT_ANIM_DURATION, animationDuration)
|
||||
|
||||
val target = pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT]?.target as Float
|
||||
assertEquals(tilt, target)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelAllAnimators() {
|
||||
pluginAnimatorCoordinator.feedNewLocation(Location(""), cameraPosition, true)
|
||||
pluginAnimatorCoordinator.cancelAllAnimations()
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_CAMERA_LATLNG] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelZoomAnimators() {
|
||||
pluginAnimatorCoordinator.feedNewZoomLevel(
|
||||
15.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_ZOOM_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
pluginAnimatorCoordinator.cancelZoomAnimation()
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_ZOOM] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cancelTiltAnimation() {
|
||||
pluginAnimatorCoordinator.feedNewTilt(
|
||||
30.0,
|
||||
cameraPosition,
|
||||
DEFAULT_TRACKING_TILT_ANIM_DURATION,
|
||||
null
|
||||
)
|
||||
|
||||
pluginAnimatorCoordinator.cancelTiltAnimation()
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap[ANIMATOR_TILT] == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resetAllCameraAnimations_empty() {
|
||||
pluginAnimatorCoordinator.resetAllCameraAnimations(cameraPosition, false)
|
||||
assertTrue(pluginAnimatorCoordinator.animatorMap.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addLayerListener(layerListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.layerListeners.contains(layerListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeLayerListener() {
|
||||
val layerListener = Mockito.mock(OnLayerAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addLayerListener(layerListener)
|
||||
pluginAnimatorCoordinator.removeLayerListener(layerListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.layerListeners.isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun addCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.cameraListeners.contains(cameraListener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun removeCameraListener() {
|
||||
val cameraListener = Mockito.mock(OnCameraAnimationsValuesChangeListener::class.java)
|
||||
pluginAnimatorCoordinator.addCameraListener(cameraListener)
|
||||
pluginAnimatorCoordinator.removeCameraListener(cameraListener)
|
||||
|
||||
assertTrue(pluginAnimatorCoordinator.cameraListeners.isEmpty())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user