[android] - optimise loaded style for location component, expose isFullyLoaded

This commit is contained in:
Tobrun
2018-12-07 19:25:29 +02:00
committed by Tobrun
parent 8eaff9ce13
commit aa9e6c59bb
7 changed files with 150 additions and 18 deletions

View File

@@ -153,7 +153,7 @@ class LocationComponentTest : BaseActivityTest() {
executeComponentTest(componentAction)
}
@Test
@Test(expected = IllegalStateException::class)
fun settingMapStyleImmediatelyBeforeLoadingComponent_doesStillLoadLayersProperly() {
validateTestSetup()
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {

View File

@@ -48,6 +48,15 @@ fun MapboxMap.waitForLayer(uiController: UiController, location: Location, layer
}
}
fun MapboxMap.waitForStyle(uiController: UiController, mapboxMap: MapboxMap) {
var counter = 0
val delay = MapboxTestingUtils.MAP_RENDER_DELAY
while ((mapboxMap.style == null && !mapboxMap.style?.isFullyLoaded!!) && delay * counter < MapboxTestingUtils.RENDER_TIMEOUT) {
uiController.loopMainThreadForAtLeast(delay)
counter++
}
}
inline fun waitForRenderResult(uiController: UiController, checkFunction: () -> Boolean, expectedResult: Boolean) {
var counter = 0
val delay = MapboxTestingUtils.MAP_RENDER_DELAY
@@ -62,7 +71,7 @@ class MapboxTestingUtils {
const val MAP_RENDER_DELAY = 250L
const val MAP_CONNECTION_DELAY = 1000L
const val RENDER_TIMEOUT = 2_500L
const val RENDER_TIMEOUT = 5_500L
/**
* Used to increase style load time for stress testing.