diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2019-07-03 20:14:26 +0200 |
---|---|---|
committer | Tobrun <tobrun.van.nuland@gmail.com> | 2019-07-04 12:08:49 +0200 |
commit | dd16eadc382fe853f4b877fbcfd909d103a339f5 (patch) | |
tree | aa1ec40ae3fccc4745434a16a108d9814a8a51ec /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt | |
parent | 16f1854a9ca98c00a5058c55e8a59df2c3463f4d (diff) | |
download | qtlocation-mapboxgl-dd16eadc382fe853f4b877fbcfd909d103a339f5.tar.gz |
[android] - add ktlint, optimise code for ktlint validation
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt')
-rw-r--r-- | platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt | 152 |
1 files changed, 114 insertions, 38 deletions
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 |