aboutsummaryrefslogtreecommitdiff
path: root/app/src/androidTest/kotlin/com
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-04-18 17:58:23 -0700
committerAllan Wang <me@allanwang.ca>2021-04-18 17:58:23 -0700
commit41b6765da8fb0c05dff8b339ca23b6a3d39839d9 (patch)
tree4b51d7fc8cb476619a337f1b308c5540ec3f365d /app/src/androidTest/kotlin/com
parent6abaf596e4db5a36057f6a8acf31b72f57a12e18 (diff)
downloadfrost-41b6765da8fb0c05dff8b339ca23b6a3d39839d9.tar.gz
frost-41b6765da8fb0c05dff8b339ca23b6a3d39839d9.tar.bz2
frost-41b6765da8fb0c05dff8b339ca23b6a3d39839d9.zip
Fix coroutine tests
Diffstat (limited to 'app/src/androidTest/kotlin/com')
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt41
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt19
2 files changed, 21 insertions, 39 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt
index 9d0caae6..2a834cc8 100644
--- a/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/FrostTestApp.kt
@@ -19,22 +19,13 @@ package com.pitchedapps.frost
import android.app.Application
import android.content.Context
import androidx.test.runner.AndroidJUnitRunner
-import ca.allanwang.kau.kpref.KPrefFactory
-import ca.allanwang.kau.kpref.KPrefFactoryInMemory
-import com.pitchedapps.frost.db.FrostDatabase
-import com.pitchedapps.frost.facebook.FbCookie
-import com.pitchedapps.frost.injectors.ThemeProvider
import com.pitchedapps.frost.prefs.Prefs
+import dagger.hilt.android.testing.HiltTestApplication
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
-import org.koin.android.ext.koin.androidContext
-import org.koin.android.ext.koin.androidLogger
import org.koin.core.component.KoinComponent
import org.koin.core.component.get
-import org.koin.core.context.startKoin
-import org.koin.core.module.Module
-import org.koin.dsl.module
class FrostTestRunner : AndroidJUnitRunner() {
override fun newApplication(
@@ -42,7 +33,7 @@ class FrostTestRunner : AndroidJUnitRunner() {
className: String?,
context: Context?
): Application {
- return super.newApplication(cl, FrostTestApp::class.java.name, context)
+ return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
}
@@ -58,31 +49,3 @@ class FrostTestRule : TestRule {
}
}
}
-
-class FrostTestApp : Application() {
-
- override fun onCreate() {
- super.onCreate()
- startKoin {
- androidLogger()
- androidContext(this@FrostTestApp)
- modules(
- listOf(
- FrostDatabase.module(),
- prefFactoryModule(),
- Prefs.module(),
- FbCookie.module(),
- ThemeProvider.module()
- )
- )
- }
- }
-
- companion object {
- fun prefFactoryModule(): Module = module {
- single<KPrefFactory> {
- KPrefFactoryInMemory
- }
- }
- }
-}
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt
new file mode 100644
index 00000000..3d43f1b1
--- /dev/null
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/TestModules.kt
@@ -0,0 +1,19 @@
+package com.pitchedapps.frost
+
+import ca.allanwang.kau.kpref.KPrefFactory
+import ca.allanwang.kau.kpref.KPrefFactoryInMemory
+import com.pitchedapps.frost.prefs.PrefFactoryModule
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.components.SingletonComponent
+import dagger.hilt.testing.TestInstallIn
+
+@Module
+@TestInstallIn(
+ components = [SingletonComponent::class],
+ replaces = [PrefFactoryModule::class]
+)
+object PrefFactoryTestModule {
+ @Provides
+ fun factory(): KPrefFactory = KPrefFactoryInMemory
+}