mirror of https://github.com/tasks/tasks
Migrate to Hilt
parent
da1a69760f
commit
52952e22cd
@ -0,0 +1,13 @@
|
|||||||
|
package org.tasks
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.test.runner.AndroidJUnitRunner
|
||||||
|
import dagger.hilt.android.testing.HiltTestApplication
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
class TestRunner : AndroidJUnitRunner() {
|
||||||
|
override fun newApplication(cl: ClassLoader?, name: String?, context: Context?): Application {
|
||||||
|
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,20 +1,16 @@
|
|||||||
package org.tasks.injection
|
package org.tasks.injection
|
||||||
|
|
||||||
import android.content.Context
|
import dagger.hilt.android.testing.HiltAndroidRule
|
||||||
import androidx.test.core.app.ApplicationProvider
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import timber.log.Timber
|
import org.junit.Rule
|
||||||
|
|
||||||
abstract class InjectingTestCase {
|
abstract class InjectingTestCase {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
var hiltRule = HiltAndroidRule(this)
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
open fun setUp() {
|
open fun setUp() {
|
||||||
Thread.setDefaultUncaughtExceptionHandler { _, e: Throwable? -> Timber.e(e) }
|
hiltRule.inject()
|
||||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
|
||||||
val component = DaggerTestComponent.builder()
|
|
||||||
.applicationModule(ApplicationModule(context))
|
|
||||||
.testModule(TestModule()).build()
|
|
||||||
inject(component)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun inject(component: TestComponent)
|
|
||||||
}
|
}
|
||||||
@ -1,52 +0,0 @@
|
|||||||
package org.tasks.injection
|
|
||||||
|
|
||||||
import com.todoroo.astrid.adapter.*
|
|
||||||
import com.todoroo.astrid.alarms.AlarmJobServiceTest
|
|
||||||
import com.todoroo.astrid.dao.TaskDaoTests
|
|
||||||
import com.todoroo.astrid.gtasks.GtasksListServiceTest
|
|
||||||
import com.todoroo.astrid.gtasks.GtasksMetadataServiceTest
|
|
||||||
import com.todoroo.astrid.model.TaskTest
|
|
||||||
import com.todoroo.astrid.reminders.ReminderServiceTest
|
|
||||||
import com.todoroo.astrid.repeats.RepeatTaskHelperTest
|
|
||||||
import com.todoroo.astrid.service.QuickAddMarkupTest
|
|
||||||
import com.todoroo.astrid.service.TaskMoverTest
|
|
||||||
import com.todoroo.astrid.service.TitleParserTest
|
|
||||||
import com.todoroo.astrid.subtasks.SubtasksHelperTest
|
|
||||||
import com.todoroo.astrid.subtasks.SubtasksMovingTest
|
|
||||||
import com.todoroo.astrid.sync.NewSyncTestCase
|
|
||||||
import dagger.Component
|
|
||||||
import org.tasks.data.*
|
|
||||||
import org.tasks.jobs.BackupServiceTests
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
@Component(modules = [TestModule::class])
|
|
||||||
interface TestComponent : ApplicationComponent {
|
|
||||||
fun inject(tests: GtasksListServiceTest)
|
|
||||||
fun inject(tests: ReminderServiceTest)
|
|
||||||
fun inject(tests: TaskTest)
|
|
||||||
fun inject(tests: TaskDaoTests)
|
|
||||||
fun inject(tests: NewSyncTestCase)
|
|
||||||
fun inject(tests: SubtasksMovingTest)
|
|
||||||
fun inject(tests: SubtasksHelperTest)
|
|
||||||
fun inject(tests: QuickAddMarkupTest)
|
|
||||||
fun inject(tests: TitleParserTest)
|
|
||||||
fun inject(tests: BackupServiceTests)
|
|
||||||
fun inject(tests: AlarmJobServiceTest)
|
|
||||||
fun inject(tests: RepeatTaskHelperTest)
|
|
||||||
fun inject(tests: GtasksMetadataServiceTest)
|
|
||||||
fun inject(tests: DeletionDaoTests)
|
|
||||||
fun inject(tests: GoogleTaskDaoTests)
|
|
||||||
fun inject(tests: TagDataDaoTest)
|
|
||||||
fun inject(tests: CaldavDaoTests)
|
|
||||||
fun inject(tests: TaskMoverTest)
|
|
||||||
fun inject(tests: LocationDaoTest)
|
|
||||||
fun inject(tests: GoogleTaskListDaoTest)
|
|
||||||
fun inject(tests: CaldavTaskAdapterTest)
|
|
||||||
fun inject(tests: ManualGoogleTaskQueryTest)
|
|
||||||
fun inject(tests: CaldavDaoShiftTests)
|
|
||||||
fun inject(tests: CaldavManualSortTaskAdapterTest)
|
|
||||||
fun inject(tests: GoogleTaskManualSortAdapterTest)
|
|
||||||
fun inject(tests: OfflineSubtaskTest)
|
|
||||||
fun inject(tests: NonRecursiveQueryTest)
|
|
||||||
}
|
|
||||||
@ -1,14 +1,13 @@
|
|||||||
package org.tasks.dashclock
|
package org.tasks.dashclock
|
||||||
|
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.tasks.R
|
import org.tasks.R
|
||||||
import org.tasks.injection.ActivityComponent
|
|
||||||
import org.tasks.preferences.BasePreferences
|
import org.tasks.preferences.BasePreferences
|
||||||
import org.tasks.preferences.fragments.DashClock
|
import org.tasks.preferences.fragments.DashClock
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
class DashClockSettings : BasePreferences() {
|
class DashClockSettings : BasePreferences() {
|
||||||
override fun getRootTitle() = R.string.pro_dashclock_extension
|
override fun getRootTitle() = R.string.pro_dashclock_extension
|
||||||
|
|
||||||
override fun getRootPreference() = DashClock()
|
override fun getRootPreference() = DashClock()
|
||||||
|
|
||||||
override fun inject(component: ActivityComponent) = component.inject(this)
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue