[android] - move camera and puck immediately when starting to track and displacement is big

This commit is contained in:
Łukasz Paczos
2018-10-03 11:30:54 +02:00
parent b31245b965
commit 5bfdd9fb8d
4 changed files with 50 additions and 10 deletions

View File

@@ -1099,6 +1099,29 @@ class LocationComponentTest : BaseActivityTest() {
executeComponentTest(componentAction)
}
@Test
fun cameraPositionSnappedToTargetIfExceedsThreshold() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context, false)
component.isLocationComponentEnabled = true
val target = LatLng(51.0, 17.0)
assertTrue(target.distanceTo(LatLng(location)) > LocationComponentConstants.INSTANT_LOCATION_TRANSITION_THRESHOLD)
component.cameraMode = CameraMode.NONE
component.forceLocationUpdate(location)
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(target))
mapboxMap.moveCamera(CameraUpdateFactory.bearingTo(90.0))
component.cameraMode = CameraMode.TRACKING_GPS
assertEquals(location.bearing.toDouble(), mapboxMap.cameraPosition.bearing, 0.1)
assertEquals(location.latitude, mapboxMap.cameraPosition.target.latitude, 0.1)
assertEquals(location.longitude, mapboxMap.cameraPosition.target.longitude, 0.1)
}
}
executeComponentTest(componentAction)
}
@Test
fun compassEngine_onComponentInitializedDefaultIsProvided() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {