Skip to content

Commit

Permalink
Fix MapboxCopilotImplTest
Browse files Browse the repository at this point in the history
  • Loading branch information
kmadsen authored and dzinad committed Dec 13, 2023
1 parent ebbb248 commit a60da18
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import android.content.pm.PackageInfo
import android.os.Looper
import android.os.SystemClock
import android.util.Base64
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import com.mapbox.common.UploadOptions
import com.mapbox.navigation.base.ExperimentalPreviewMapboxNavigationAPI
Expand Down Expand Up @@ -528,7 +528,7 @@ class MapboxCopilotImplTest {
every {
mockedMapboxNavigation.retrieveCopilotHistoryRecorder()
} returns mockedHistoryRecorder
val foregroundBackgroundLifecycleObserver = slot<DefaultLifecycleObserver>()
val foregroundBackgroundLifecycleObserver = slot<LifecycleEventObserver>()
every {
mockedProcessLifecycleOwner.lifecycle.addObserver(
capture(foregroundBackgroundLifecycleObserver)
Expand All @@ -538,7 +538,8 @@ class MapboxCopilotImplTest {
mapboxCopilot.start()
val mockedLifecycleOwner = mockk<LifecycleOwner>()

foregroundBackgroundLifecycleObserver.captured.onResume(mockedLifecycleOwner)
foregroundBackgroundLifecycleObserver.captured
.onStateChanged(mockedLifecycleOwner, Lifecycle.Event.ON_RESUME)

verify(exactly = 1) {
mockedHistoryRecorder.pushHistory(GOING_TO_FOREGROUND_EVENT_NAME, "{}")
Expand All @@ -553,7 +554,7 @@ class MapboxCopilotImplTest {
every {
mockedMapboxNavigation.retrieveCopilotHistoryRecorder()
} returns mockedHistoryRecorder
val foregroundBackgroundLifecycleObserver = slot<DefaultLifecycleObserver>()
val foregroundBackgroundLifecycleObserver = slot<LifecycleEventObserver>()
every {
mockedProcessLifecycleOwner.lifecycle.addObserver(
capture(foregroundBackgroundLifecycleObserver)
Expand All @@ -563,7 +564,8 @@ class MapboxCopilotImplTest {
mapboxCopilot.start()
val mockedLifecycleOwner = mockk<LifecycleOwner>()

foregroundBackgroundLifecycleObserver.captured.onPause(mockedLifecycleOwner)
foregroundBackgroundLifecycleObserver.captured
.onStateChanged(mockedLifecycleOwner, Lifecycle.Event.ON_PAUSE)

verify(exactly = 1) {
mockedHistoryRecorder.pushHistory(GOING_TO_BACKGROUND_EVENT_NAME, "{}")
Expand Down

0 comments on commit a60da18

Please sign in to comment.