Skip to content

Commit fa67481

Browse files
natiginfogithub-actions[bot]
authored andcommitted
[maps-android] fix flaky DebugOptionsControllerTest (#6471)
GitOrigin-RevId: 70d428d1a19560067c502619d0f58fa8b707b1ae
1 parent 4d17bc2 commit fa67481

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

maps-sdk/src/test/java/com/mapbox/maps/debugoptions/DebugOptionsControllerTest.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ import com.mapbox.maps.MapDebugOptions
77
import com.mapbox.maps.MapView
88
import com.mapbox.maps.MapboxMap
99
import com.mapbox.verifyNo
10+
import io.mockk.clearAllMocks
1011
import io.mockk.every
1112
import io.mockk.mockk
1213
import io.mockk.slot
14+
import io.mockk.unmockkAll
1315
import io.mockk.verify
16+
import org.junit.After
1417
import org.junit.Before
15-
import org.junit.Ignore
1618
import org.junit.Test
1719
import org.junit.runner.RunWith
1820
import org.robolectric.RobolectricTestRunner
1921

2022
@OptIn(MapboxExperimental::class)
2123
@RunWith(RobolectricTestRunner::class)
22-
@Ignore("Ignoring this test as it is flaky and requires two runs to pass")
2324
class DebugOptionsControllerTest {
2425
private val mapboxMap: MapboxMap = mockk(relaxed = true)
2526
private val cameraDebugView: CameraDebugView = mockk(relaxed = true)
@@ -29,6 +30,7 @@ class DebugOptionsControllerTest {
2930

3031
@Before
3132
fun setUp() {
33+
clearAllMocks()
3234
every { mapView.context } returns mockk(relaxed = true)
3335
every { cameraDebugView.parent } returns null
3436
every { paddingDebugView.parent } returns null
@@ -37,6 +39,11 @@ class DebugOptionsControllerTest {
3739
DebugOptionsController(mapView, mapboxMap, { cameraDebugView }, { paddingDebugView })
3840
}
3941

42+
@After
43+
fun tearDown() {
44+
unmockkAll()
45+
}
46+
4047
@Test
4148
fun updatesDebugViewsWhenCameraUpdated() {
4249
val onCameraChangeCoalescedListenerSlot = slot<CameraChangedCoalescedCallback>()
@@ -45,6 +52,8 @@ class DebugOptionsControllerTest {
4552
debugOptionsController.started = true
4653
debugOptionsController.options = setOf(MapViewDebugOptions.CAMERA, MapViewDebugOptions.PADDING)
4754

55+
// Verify the callback was captured, then invoke it
56+
verify { mapboxMap.subscribeCameraChangedCoalesced(any()) }
4857
val onCameraChangeCoalescedListener = onCameraChangeCoalescedListenerSlot.captured
4958
onCameraChangeCoalescedListener.run(mockk(relaxed = true))
5059

0 commit comments

Comments
 (0)