From cd925693554f64485c523c31d7c08dba2ffb1952 Mon Sep 17 00:00:00 2001 From: len Date: Wed, 15 Jun 2016 17:58:28 +0200 Subject: [PATCH] Restart inject module when the app is created --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 4 ++++ .../tachiyomi/data/library/LibraryUpdateAlarmTest.kt | 7 ------- .../tachiyomi/data/library/LibraryUpdateServiceTest.kt | 7 ------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 46f2e80625..8103fb5f13 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -5,6 +5,8 @@ import org.acra.ACRA import org.acra.annotation.ReportsCrashes import timber.log.Timber import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.InjektScope +import uy.kohesive.injekt.registry.default.DefaultRegistrar @ReportsCrashes( formUri = "http://tachiyomi.kanade.eu/crash_report", @@ -17,7 +19,9 @@ open class App : Application() { override fun onCreate() { super.onCreate() + Injekt = InjektScope(DefaultRegistrar()) Injekt.importModule(AppModule(this)) + if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) setupAcra() diff --git a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateAlarmTest.kt b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateAlarmTest.kt index 0895523e1d..deddd2c1c6 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateAlarmTest.kt +++ b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateAlarmTest.kt @@ -5,8 +5,6 @@ import android.content.Context import android.content.Intent import android.os.Build import android.os.SystemClock -import eu.kanade.tachiyomi.App -import eu.kanade.tachiyomi.AppModule import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner import eu.kanade.tachiyomi.data.preference.PreferencesHelper @@ -19,9 +17,6 @@ import org.robolectric.Shadows.shadowOf import org.robolectric.annotation.Config import org.robolectric.shadows.ShadowAlarmManager 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)) @RunWith(CustomRobolectricGradleTestRunner::class) @@ -35,8 +30,6 @@ class LibraryUpdateAlarmTest { fun setup() { app = ShadowApplication.getInstance() context = spy(app.applicationContext) - Injekt = InjektScope(DefaultRegistrar()) - Injekt.importModule(AppModule(context as App)) alarmManager = shadowOf(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager) } diff --git a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt index 0e12fcda54..139abad41d 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt +++ b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.library import android.app.Application import android.content.Context -import eu.kanade.tachiyomi.AppModule import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner import eu.kanade.tachiyomi.data.database.models.Chapter @@ -23,9 +22,7 @@ import rx.Observable import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.InjektModule import uy.kohesive.injekt.api.InjektRegistrar -import uy.kohesive.injekt.api.InjektScope import uy.kohesive.injekt.api.addSingleton -import uy.kohesive.injekt.registry.default.DefaultRegistrar import java.util.* @Config(constants = BuildConfig::class) @@ -48,10 +45,6 @@ class LibraryUpdateServiceTest { addSingleton(Mockito.mock(SourceManager::class.java, RETURNS_DEEP_STUBS)) } } - - // Restart injections for each test - Injekt = InjektScope(DefaultRegistrar()) - Injekt.importModule(AppModule(app)) Injekt.importModule(module) service = Robolectric.setupService(LibraryUpdateService::class.java)