Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.verify
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.TestDispatcher
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.test.setMain
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
Expand All @@ -51,6 +53,7 @@ class GoogleMapsInitializerTest {
every { MapsApiSettings.addInternalUsageAttributionId(any(), any()) } returns Unit

testDispatcher = UnconfinedTestDispatcher()
Dispatchers.setMain(testDispatcher)
googleMapsInitializer = DefaultGoogleMapsInitializer(testDispatcher)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ public class DefaultGoogleMapsInitializer(
_state.value = InitializationState.INITIALIZING
}

withContext(ioDispatcher) {
withContext(Dispatchers.Main) {
if (MapsInitializer.initialize(context) == ConnectionResult.SUCCESS) {
MapsApiSettings.addInternalUsageAttributionId(context, attributionId)
withContext(ioDispatcher) {
MapsApiSettings.addInternalUsageAttributionId(context, attributionId)
}
_state.value = InitializationState.SUCCESS
} else {
_state.value = InitializationState.FAILURE
Expand Down
Loading