Add isLayerReady check in LocationComponent before updating compass listener. (#19)

This commit is contained in:
Peng Liu
2019-10-23 11:06:15 +03:00
committed by GitHub
parent db02638844
commit 70214f1e6b
3 changed files with 22 additions and 3 deletions

View File

@@ -386,6 +386,23 @@ class LocationComponentTest {
verify(compassEngine, never()).addCompassListener(any(CompassListener::class.java))
}
@Test
fun compass_notAddListenerWhenLayerNotReady() {
locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)
locationComponent.onStart()
locationComponent.isLocationComponentEnabled = true
`when`(mapboxMap.cameraPosition).thenReturn(CameraPosition.DEFAULT)
`when`(locationLayerController.isConsumingCompass).thenReturn(true)
locationComponent.renderMode = RenderMode.COMPASS
verify(compassEngine, times(1)).addCompassListener(any(CompassListener::class.java))
locationComponent.onStartLoadingMap()
// Layer should be disabled at this point
locationComponent.setCameraMode(CameraMode.TRACKING_COMPASS)
verify(compassEngine, times(1)).addCompassListener(any(CompassListener::class.java))
}
@Test
fun developerAnimationCalled() {
locationComponent.activateLocationComponent(context, mock(Style::class.java), locationEngine, locationEngineRequest, locationComponentOptions)