diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location')
5 files changed, 440 insertions, 152 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt index f9827c767e..fb113502ee 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt @@ -54,7 +54,6 @@ class LocationComponentTest : EspressoTest() { private lateinit var locationComponentActivationOptions: LocationComponentActivationOptions - override fun validateTestSetup() { super.validateTestSetup() assertThat(mapboxMap.style, notNullValue()) @@ -71,8 +70,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvided() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) @@ -93,9 +97,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponent_initializesLocationEngineCorrectlyWhenOnesNotProvidedButHasOptions() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .locationComponentOptions( @@ -131,9 +139,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponent_doesntInitializeEngineWhenNullProvided() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .locationEngine(null) @@ -170,8 +182,13 @@ class LocationComponentTest : EspressoTest() { fun settingMapStyleImmediatelyBeforeLoadingComponent_throwsInvalidStyle() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT)) component.activateLocationComponent(LocationComponentActivationOptions @@ -188,9 +205,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponent_doesntShowUntilFirstLocationFix() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -222,10 +243,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponentOptions_disablingStaleStateDoesWorkCorrectly() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -258,9 +282,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponentOptions_loadsForegroundBitmapFromNameOption() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -306,9 +334,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponentOptions_loadsGpsNameWithGpsRenderMode() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -343,9 +375,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponentOptions_customIconNameRevertsToDefault() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -379,9 +415,13 @@ class LocationComponentTest : EspressoTest() { fun locationComponentOptions_customGpsIconNameChangeBackWithMode() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -414,9 +454,13 @@ class LocationComponentTest : EspressoTest() { fun stillStaleAfterResuming() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -451,9 +495,13 @@ class LocationComponentTest : EspressoTest() { fun stillNotStaleAfterResuming() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -483,9 +531,13 @@ class LocationComponentTest : EspressoTest() { val rgbaColor = ColorUtils.colorToRgbaString(color) val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { locationComponentActivationOptions = LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -516,9 +568,13 @@ class LocationComponentTest : EspressoTest() { fun forceLocationUpdate_doesMoveLocationLayerIconToCorrectPosition() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -541,9 +597,13 @@ class LocationComponentTest : EspressoTest() { fun disablingComponentHidesPuck() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -568,9 +628,13 @@ class LocationComponentTest : EspressoTest() { fun disablingComponentAndChangingStyleAllowsToEnableAgain() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -592,9 +656,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_isDisabledOnStart() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.onStop() component.onStart() @@ -619,9 +687,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_keepsEnabledWhenStoppedAndStarted() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { - + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -641,8 +713,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_keepsDisabledWhenStoppedAndStarted() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent( LocationComponentActivationOptions .builder(context, style) @@ -663,8 +740,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_ableToChangeStyleAfterResuming() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -685,8 +767,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_interruptedDuringStyleChange() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -705,8 +792,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_forceLocationUpdateAfterStopped() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -726,8 +818,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_acceptAndReuseLocationUpdatesBeforeLayerStarted() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -750,8 +847,13 @@ class LocationComponentTest : EspressoTest() { fun lifecycle_lifecycleChangeRightAfterStyleReload() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -781,8 +883,13 @@ class LocationComponentTest : EspressoTest() { fun mapChange_settingComponentStyle() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -810,8 +917,13 @@ class LocationComponentTest : EspressoTest() { fun mapChange_forcingLocation() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -836,8 +948,13 @@ class LocationComponentTest : EspressoTest() { fun mapChange_settingMapStyleBeforeComponentCreation() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE) TestingAsyncUtils.waitForLayer(uiController, mapView) @@ -868,8 +985,13 @@ class LocationComponentTest : EspressoTest() { fun animators_layerBearingCorrect() { validateTestSetup() val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -896,8 +1018,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_cameraLatLngBearingCorrect() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -932,8 +1059,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_cameraBearingCorrect() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -971,8 +1103,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_cameraNoneCorrect() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1011,8 +1148,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_focalPointAdjustment() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1033,8 +1175,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_dontZoomWhileNotTracking() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1056,8 +1203,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_zoomWhileTracking() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1079,8 +1231,13 @@ class LocationComponentTest : EspressoTest() { @Ignore fun animators_zoomWhileTrackingCanceledOnModeChange() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1103,8 +1260,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_dontZoomWhileStopped() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1130,8 +1292,13 @@ class LocationComponentTest : EspressoTest() { @Ignore fun animators_cancelZoomWhileTracking() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1154,8 +1321,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_dontTiltWhileNotTracking() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1177,8 +1349,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_tiltWhileTracking() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1200,8 +1377,13 @@ class LocationComponentTest : EspressoTest() { @Ignore fun animators_tiltWhileTrackingCanceledOnModeChange() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1224,8 +1406,13 @@ class LocationComponentTest : EspressoTest() { @Test fun animators_dontTiltWhileStopped() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1250,8 +1437,13 @@ class LocationComponentTest : EspressoTest() { @Ignore fun animators_cancelTiltWhileTracking() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1273,8 +1465,13 @@ class LocationComponentTest : EspressoTest() { @Test fun cameraPositionAdjustedToTrackingModeWhenComponentEnabled() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1301,8 +1498,13 @@ class LocationComponentTest : EspressoTest() { @Test fun cameraPositionSnappedToTargetIfExceedsThreshold() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1330,8 +1532,13 @@ class LocationComponentTest : EspressoTest() { @Test fun compassEngine_onComponentInitializedDefaultIsProvided() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -1347,8 +1554,13 @@ class LocationComponentTest : EspressoTest() { @Test fun compassEngine_changesWhenNewProvided() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt index 95a3891b6d..110d879bf3 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt @@ -35,6 +35,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import kotlin.math.abs @RunWith(AndroidJUnit4::class) class LocationLayerControllerTest : EspressoTest() { @@ -67,8 +68,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun renderModeNormal_sourceDoesGetAdded() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -90,8 +96,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun renderModeNormal_trackingNormalLayersDoGetAdded() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -114,8 +125,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun renderModeCompass_bearingLayersDoGetAdded() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -138,8 +154,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun renderModeGps_navigationLayersDoGetAdded() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -162,8 +183,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun dontShowPuckWhenRenderModeSetAndComponentDisabled() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -187,8 +213,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun whenLocationComponentDisabled_doesSetAllLayersToVisibilityNone() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -213,8 +244,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun onMapChange_locationComponentLayersDoGetRedrawn() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -245,8 +281,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun whenStyleChanged_continuesUsingStaleIcons() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -271,8 +312,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun whenStyleChanged_isDisabled_hasLayerBelow_staysHidden() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -300,8 +346,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun whenStyleChanged_staleStateChanges() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -323,8 +374,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun whenStyleChanged_layerVisibilityUpdates() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE) uiController.loopMainThreadForAtLeast(100) var show = true @@ -349,8 +405,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun accuracy_visibleWithNewLocation() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -372,8 +433,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun accuracy_visibleWhenCameraEased() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -387,10 +453,9 @@ class LocationLayerControllerTest : EspressoTest() { uiController.loopMainThreadForAtLeast(300) TestingAsyncUtils.waitForLayer(uiController, mapView) - - assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 - && Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 - && Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1, + assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 && + Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 && + Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1, `is`(true)) val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/ @@ -405,8 +470,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun accuracy_visibleWhenCameraMoved() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -419,9 +489,10 @@ class LocationLayerControllerTest : EspressoTest() { mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target, zoom)) TestingAsyncUtils.waitForLayer(uiController, mapView) - assertThat(Math.abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 - && Math.abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 - && Math.abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1, + assertThat( + abs(zoom - mapboxMap.cameraPosition.zoom) < 0.1 && + abs(target.latitude - mapboxMap.cameraPosition.target.latitude) < 0.1 && + abs(target.longitude - mapboxMap.cameraPosition.target.longitude) < 0.1, `is`(true)) val expectedRadius = Utils.calculateZoomLevelRadius(mapboxMap, location) /*meters projected to radius on zoom 16*/ @@ -436,8 +507,13 @@ class LocationLayerControllerTest : EspressoTest() { @Test fun applyStyle_layerBelow_restoreLayerVisibility() { val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction { - override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap, - style: Style, uiController: UiController, context: Context) { + override fun onLocationComponentAction( + component: LocationComponent, + mapboxMap: MapboxMap, + style: Style, + uiController: UiController, + context: Context + ) { component.activateLocationComponent(LocationComponentActivationOptions .builder(context, style) .useDefaultLocationEngine(false) @@ -467,4 +543,4 @@ class LocationLayerControllerTest : EspressoTest() { private fun executeComponentTest(listener: LocationComponentAction.OnPerformLocationComponentAction) { onView(withId(R.id.content)).perform(LocationComponentAction(mapboxMap, listener)) } -} +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt index 64123cc8c4..daf6b89f59 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/LocationComponentAction.kt @@ -10,8 +10,10 @@ import com.mapbox.mapboxsdk.location.LocationComponent import com.mapbox.mapboxsdk.maps.Style import org.hamcrest.Matcher -class LocationComponentAction(private val mapboxMap: MapboxMap, - private val onPerformLocationComponentAction: OnPerformLocationComponentAction) : ViewAction { +class LocationComponentAction( + private val mapboxMap: MapboxMap, + private val onPerformLocationComponentAction: OnPerformLocationComponentAction +) : ViewAction { override fun getConstraints(): Matcher<View> { return isDisplayed() diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt index edbb1c6c65..18da6d1d10 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxLocationTestingUtils.kt @@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable import android.location.Location import android.os.Handler import android.os.Looper -import android.support.test.espresso.UiController import com.mapbox.geojson.Feature import com.mapbox.mapboxsdk.geometry.LatLng import com.mapbox.mapboxsdk.maps.MapboxMap diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt index 5aded25d1e..050535f6df 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt @@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.location.utils import android.support.test.espresso.IdlingResource import com.mapbox.mapboxsdk.maps.MapboxMap import com.mapbox.mapboxsdk.maps.Style -import java.util.logging.Handler /** * Resource, that's idling until the provided style is loaded. |