mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 06:51:49 +01:00
Restart inject module when the app is created
This commit is contained in:
parent
a82e1d0e45
commit
cd92569355
@ -5,6 +5,8 @@ import org.acra.ACRA
|
|||||||
import org.acra.annotation.ReportsCrashes
|
import org.acra.annotation.ReportsCrashes
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.InjektScope
|
||||||
|
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
||||||
|
|
||||||
@ReportsCrashes(
|
@ReportsCrashes(
|
||||||
formUri = "http://tachiyomi.kanade.eu/crash_report",
|
formUri = "http://tachiyomi.kanade.eu/crash_report",
|
||||||
@ -17,7 +19,9 @@ open class App : Application() {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
Injekt = InjektScope(DefaultRegistrar())
|
||||||
Injekt.importModule(AppModule(this))
|
Injekt.importModule(AppModule(this))
|
||||||
|
|
||||||
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
|
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
|
||||||
|
|
||||||
setupAcra()
|
setupAcra()
|
||||||
|
@ -5,8 +5,6 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import eu.kanade.tachiyomi.App
|
|
||||||
import eu.kanade.tachiyomi.AppModule
|
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner
|
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
@ -19,9 +17,6 @@ import org.robolectric.Shadows.shadowOf
|
|||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
import org.robolectric.shadows.ShadowAlarmManager
|
import org.robolectric.shadows.ShadowAlarmManager
|
||||||
import org.robolectric.shadows.ShadowApplication
|
import org.robolectric.shadows.ShadowApplication
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.InjektScope
|
|
||||||
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
|
||||||
|
|
||||||
@Config(constants = BuildConfig::class, sdk = intArrayOf(Build.VERSION_CODES.LOLLIPOP))
|
@Config(constants = BuildConfig::class, sdk = intArrayOf(Build.VERSION_CODES.LOLLIPOP))
|
||||||
@RunWith(CustomRobolectricGradleTestRunner::class)
|
@RunWith(CustomRobolectricGradleTestRunner::class)
|
||||||
@ -35,8 +30,6 @@ class LibraryUpdateAlarmTest {
|
|||||||
fun setup() {
|
fun setup() {
|
||||||
app = ShadowApplication.getInstance()
|
app = ShadowApplication.getInstance()
|
||||||
context = spy(app.applicationContext)
|
context = spy(app.applicationContext)
|
||||||
Injekt = InjektScope(DefaultRegistrar())
|
|
||||||
Injekt.importModule(AppModule(context as App))
|
|
||||||
|
|
||||||
alarmManager = shadowOf(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager)
|
alarmManager = shadowOf(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.library
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import eu.kanade.tachiyomi.AppModule
|
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner
|
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
@ -23,9 +22,7 @@ import rx.Observable
|
|||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.InjektModule
|
import uy.kohesive.injekt.api.InjektModule
|
||||||
import uy.kohesive.injekt.api.InjektRegistrar
|
import uy.kohesive.injekt.api.InjektRegistrar
|
||||||
import uy.kohesive.injekt.api.InjektScope
|
|
||||||
import uy.kohesive.injekt.api.addSingleton
|
import uy.kohesive.injekt.api.addSingleton
|
||||||
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@Config(constants = BuildConfig::class)
|
@Config(constants = BuildConfig::class)
|
||||||
@ -48,10 +45,6 @@ class LibraryUpdateServiceTest {
|
|||||||
addSingleton(Mockito.mock(SourceManager::class.java, RETURNS_DEEP_STUBS))
|
addSingleton(Mockito.mock(SourceManager::class.java, RETURNS_DEEP_STUBS))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart injections for each test
|
|
||||||
Injekt = InjektScope(DefaultRegistrar())
|
|
||||||
Injekt.importModule(AppModule(app))
|
|
||||||
Injekt.importModule(module)
|
Injekt.importModule(module)
|
||||||
|
|
||||||
service = Robolectric.setupService(LibraryUpdateService::class.java)
|
service = Robolectric.setupService(LibraryUpdateService::class.java)
|
||||||
|
Loading…
Reference in New Issue
Block a user