Skip to content

Commit d649bd5

Browse files
jushgithub-actions[bot]
authored andcommitted
Wait for mapview instead of map style and map idle (#4696)
Yet another attempt to avoid causing time outs on camera for coordinates tests. cc @mapbox/maps-android GitOrigin-RevId: cd9c9d28c8f888120e6a53e19a7f01d8454ede07
1 parent 9796f20 commit d649bd5

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

maps-sdk/src/androidTest/java/com/mapbox/maps/CameraForCoordinatesTest.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mapbox.maps
22

3+
import androidx.core.view.doOnLayout
34
import androidx.test.annotation.UiThreadTest
45
import androidx.test.ext.junit.rules.ActivityScenarioRule
56
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -27,7 +28,7 @@ class CameraForCoordinatesTest {
2728

2829
@Before
2930
fun setUp() {
30-
val latch = CountDownLatch(2)
31+
val latch = CountDownLatch(1)
3132
rule.scenario.onActivity {
3233
val mapOptions = MapInitOptions.getDefaultMapOptions(it).toBuilder()
3334
.pixelRatio(1F)
@@ -37,13 +38,10 @@ class CameraForCoordinatesTest {
3738
mapboxMap.loadStyle("{}")
3839
// Hardcoded width and height to avoid issues with different screen sizes
3940
it.frameLayout.addView(mapView, 200, 200)
40-
mapboxMap.setStyleProjection(Value.valueOf(hashMapOf("name" to Value.valueOf("mercator"))))
41-
mapboxMap.getStyle {
42-
latch.countDown()
43-
}
44-
mapboxMap.subscribeMapIdle {
41+
mapView.doOnLayout {
4542
latch.countDown()
4643
}
44+
mapboxMap.setStyleProjection(Value.valueOf(hashMapOf("name" to Value.valueOf("mercator"))))
4745
}
4846
latch.throwExceptionOnTimeoutMs(timeoutMs = 30_000L)
4947
}
@@ -97,7 +95,6 @@ class CameraForCoordinatesTest {
9795
offset = null,
9896
)
9997
Assert.assertFalse(cameraForCoordinates.isEmpty)
100-
mapboxMap.setCamera(cameraForCoordinates)
10198
Assert.assertEquals(0.0, cameraForCoordinates.center!!.longitude(), 0.001)
10299
Assert.assertEquals(15.058, cameraForCoordinates.center!!.latitude(), 0.001)
103100
Assert.assertEquals(-1.356, cameraForCoordinates.zoom!!, 0.001)

0 commit comments

Comments
 (0)