From 8db0b67ce9ba4a5e56c04c1bea3a738eacb176cf Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 9 Dec 2021 10:07:54 +0530 Subject: Refactor coroutine testing setup (#1583) * coroutine-utils: init * coroutine-utils-testing: init * format-common: switch over to using DispatcherProvider * Convert Binds method to an extension function * Add Dispatcher module --- .../aps/injection/coroutines/DispatcherModule.kt | 19 +++++++++++++++++++ .../dev/msfjarvis/aps/injection/totp/TotpModule.kt | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/dev/msfjarvis/aps/injection/coroutines/DispatcherModule.kt (limited to 'app/src') diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/coroutines/DispatcherModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/coroutines/DispatcherModule.kt new file mode 100644 index 00000000..bf84fc27 --- /dev/null +++ b/app/src/main/java/dev/msfjarvis/aps/injection/coroutines/DispatcherModule.kt @@ -0,0 +1,19 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package dev.msfjarvis.aps.injection.coroutines + +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import dev.msfjarvis.aps.util.coroutines.DefaultDispatcherProvider +import dev.msfjarvis.aps.util.coroutines.DispatcherProvider + +@Module +@InstallIn(SingletonComponent::class) +interface DispatcherModule { + @Binds fun DefaultDispatcherProvider.bind(): DispatcherProvider +} diff --git a/app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt b/app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt index e02a3b86..859559cd 100644 --- a/app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt +++ b/app/src/main/java/dev/msfjarvis/aps/injection/totp/TotpModule.kt @@ -15,5 +15,5 @@ import dev.msfjarvis.aps.util.totp.UriTotpFinder @Module @InstallIn(ActivityComponent::class) interface TotpModule { - @Binds abstract fun bindTotpFinder(totpFinder: UriTotpFinder): TotpFinder + @Binds fun UriTotpFinder.bind(): TotpFinder } -- cgit v1.2.3