Skip to content

Commit

Permalink
switch to common test util to clear pending dispatches
Browse files Browse the repository at this point in the history
  • Loading branch information
frett committed Oct 11, 2024
1 parent 16e6f82 commit 942c4b3
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 57 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ dependencies {
ksp(libs.dagger.compiler)
ksp(libs.hilt.compiler)

testApi(testFixtures(libs.gtoSupport.androidx.compose))
testImplementation(libs.androidx.arch.core.testing)
testImplementation(libs.androidx.lifecycle.runtime.testing)
testImplementation(libs.androidx.test.espresso.core)
Expand Down
44 changes: 0 additions & 44 deletions app/src/test/kotlin/org/cru/godtools/TestUtils.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlin.test.AfterTest
import kotlin.test.Test
import kotlin.test.assertIs
import kotlinx.coroutines.test.runTest
import org.cru.godtools.TestUtils.clearAndroidUiDispatcher
import org.ccci.gto.android.common.androidx.compose.ui.platform.AndroidUiDispatcherUtil
import org.cru.godtools.account.GodToolsAccountManager
import org.cru.godtools.ui.account.delete.DeleteAccountScreen.Event
import org.cru.godtools.ui.account.delete.DeleteAccountScreen.State
Expand All @@ -34,7 +34,7 @@ class DeleteAccountPresenterTest {
private val presenter = DeleteAccountPresenter(navigator, accountManager)

@AfterTest
fun cleanup() = clearAndroidUiDispatcher()
fun cleanup() = AndroidUiDispatcherUtil.runScheduledDispatches()

@Test
fun `Delete Account - succeeds`() = runTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import kotlin.test.assertTrue
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runTest
import org.cru.godtools.TestUtils.clearAndroidUiDispatcher
import org.ccci.gto.android.common.androidx.compose.ui.platform.AndroidUiDispatcherUtil
import org.cru.godtools.base.Settings
import org.cru.godtools.db.repository.LanguagesRepository
import org.cru.godtools.db.repository.ToolsRepository
Expand Down Expand Up @@ -101,7 +101,7 @@ class ToolsPresenterTest {
}

@AfterTest
fun cleanup() = clearAndroidUiDispatcher()
fun cleanup() = AndroidUiDispatcherUtil.runScheduledDispatches()

// region State.banner
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlin.test.assertFalse
import kotlin.test.assertTrue
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.runTest
import org.cru.godtools.TestUtils.clearAndroidUiDispatcher
import org.ccci.gto.android.common.androidx.compose.ui.platform.AndroidUiDispatcherUtil
import org.cru.godtools.account.GodToolsAccountManager
import org.junit.runner.RunWith
import org.robolectric.annotation.Config
Expand All @@ -34,7 +34,7 @@ class DrawerMenuPresenterTest {
)

@AfterTest
fun cleanup() = clearAndroidUiDispatcher()
fun cleanup() = AndroidUiDispatcherUtil.runScheduledDispatches()

@Test
fun `State - isLoggedIn`() = runTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import kotlin.test.assertNotEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlinx.coroutines.test.runTest
import org.ccci.gto.android.common.androidx.compose.ui.platform.AndroidUiDispatcherUtil
import org.ccci.gto.android.common.androidx.core.app.LocaleConfigCompat
import org.cru.godtools.TestUtils.clearAndroidUiDispatcher
import org.cru.godtools.base.Settings
import org.junit.runner.RunWith
import org.robolectric.annotation.Config
Expand Down Expand Up @@ -55,7 +55,7 @@ class AppLanguagePresenterTest {

@AfterTest
fun cleanup() {
clearAndroidUiDispatcher()
AndroidUiDispatcherUtil.runScheduledDispatches()
unmockkObject(LocaleConfigCompat)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import kotlin.test.assertTrue
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runTest
import org.ccci.gto.android.common.androidx.compose.ui.platform.AndroidUiDispatcherUtil
import org.ccci.gto.android.common.util.content.equalsIntent
import org.cru.godtools.TestUtils.clearAndroidUiDispatcher
import org.cru.godtools.analytics.model.OpenAnalyticsActionEvent
import org.cru.godtools.analytics.model.OpenAnalyticsActionEvent.Companion.ACTION_OPEN_TOOL
import org.cru.godtools.analytics.model.OpenAnalyticsActionEvent.Companion.SOURCE_TOOL_DETAILS
Expand Down Expand Up @@ -163,7 +163,7 @@ class ToolDetailsPresenterTest {
@AfterTest
fun cleanup() {
unmockkStatic("org.cru.godtools.downloadmanager.compose.DownloadLatestTranslationKt")
clearAndroidUiDispatcher()
AndroidUiDispatcherUtil.runScheduledDispatches()
}

// region State.tool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runTest
import org.cru.godtools.TestUtils.clearAndroidUiDispatcher
import org.ccci.gto.android.common.androidx.compose.ui.platform.AndroidUiDispatcherUtil
import org.cru.godtools.base.Settings
import org.cru.godtools.base.ToolFileSystem
import org.cru.godtools.db.repository.AttachmentsRepository
Expand Down Expand Up @@ -86,7 +86,7 @@ class ToolCardPresenterTest {
)

@AfterTest
fun cleanup() = clearAndroidUiDispatcher()
fun cleanup() = AndroidUiDispatcherUtil.runScheduledDispatches()

// region ToolCard.State.tool
@Test
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ firebase-crashlytics = "19.2.0"
firebase-perf = "21.0.1"
godtoolsShared = "1.0.1"
google-auto-value = "1.11.0"
gtoSupport = "4.2.2"
gtoSupport = "4.2.3-SNAPSHOT"
kotlin = "2.0.20"
kotlinCoroutines = "1.9.0"
kotlinKover = "0.7.6"
Expand Down

0 comments on commit 942c4b3

Please sign in to comment.