@@ -7,19 +7,20 @@ import com.mapbox.maps.MapDebugOptions
77import com.mapbox.maps.MapView
88import com.mapbox.maps.MapboxMap
99import com.mapbox.verifyNo
10+ import io.mockk.clearAllMocks
1011import io.mockk.every
1112import io.mockk.mockk
1213import io.mockk.slot
14+ import io.mockk.unmockkAll
1315import io.mockk.verify
16+ import org.junit.After
1417import org.junit.Before
15- import org.junit.Ignore
1618import org.junit.Test
1719import org.junit.runner.RunWith
1820import 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" )
2324class 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