Remove dependencies to other presenters from RootPresenter
This commit is contained in:
parent
4394b76d07
commit
c709b8d76e
3 changed files with 37 additions and 34 deletions
|
|
@ -12,8 +12,8 @@ import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import im.vector.app.features.analytics.plan.SuperProperties
|
import im.vector.app.features.analytics.plan.SuperProperties
|
||||||
import io.element.android.features.rageshake.api.crash.CrashDetectionPresenter
|
import io.element.android.features.rageshake.api.crash.CrashDetectionState
|
||||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionPresenter
|
import io.element.android.features.rageshake.api.detection.RageshakeDetectionState
|
||||||
import io.element.android.features.share.api.ShareService
|
import io.element.android.features.share.api.ShareService
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
import io.element.android.libraries.matrix.api.SdkMetadata
|
import io.element.android.libraries.matrix.api.SdkMetadata
|
||||||
|
|
@ -22,8 +22,8 @@ import io.element.android.services.apperror.api.AppErrorStateService
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class RootPresenter @Inject constructor(
|
class RootPresenter @Inject constructor(
|
||||||
private val crashDetectionPresenter: CrashDetectionPresenter,
|
private val crashDetectionPresenter: Presenter<CrashDetectionState>,
|
||||||
private val rageshakeDetectionPresenter: RageshakeDetectionPresenter,
|
private val rageshakeDetectionPresenter: Presenter<RageshakeDetectionState>,
|
||||||
private val appErrorStateService: AppErrorStateService,
|
private val appErrorStateService: AppErrorStateService,
|
||||||
private val analyticsService: AnalyticsService,
|
private val analyticsService: AnalyticsService,
|
||||||
private val shareService: ShareService,
|
private val shareService: ShareService,
|
||||||
|
|
|
||||||
|
|
@ -12,17 +12,11 @@ import app.cash.molecule.moleculeFlow
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.appnav.root.RootPresenter
|
import io.element.android.appnav.root.RootPresenter
|
||||||
import io.element.android.features.rageshake.impl.crash.DefaultCrashDetectionPresenter
|
import io.element.android.features.rageshake.api.crash.aCrashDetectionState
|
||||||
import io.element.android.features.rageshake.impl.detection.DefaultRageshakeDetectionPresenter
|
import io.element.android.features.rageshake.api.detection.aRageshakeDetectionState
|
||||||
import io.element.android.features.rageshake.impl.preferences.DefaultRageshakePreferencesPresenter
|
|
||||||
import io.element.android.features.rageshake.test.crash.FakeCrashDataStore
|
|
||||||
import io.element.android.features.rageshake.test.rageshake.FakeRageShake
|
|
||||||
import io.element.android.features.rageshake.test.rageshake.FakeRageshakeDataStore
|
|
||||||
import io.element.android.features.rageshake.test.screenshot.FakeScreenshotHolder
|
|
||||||
import io.element.android.features.share.api.ShareService
|
import io.element.android.features.share.api.ShareService
|
||||||
import io.element.android.features.share.test.FakeShareService
|
import io.element.android.features.share.test.FakeShareService
|
||||||
import io.element.android.libraries.matrix.test.FakeSdkMetadata
|
import io.element.android.libraries.matrix.test.FakeSdkMetadata
|
||||||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
|
||||||
import io.element.android.services.analytics.test.FakeAnalyticsService
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
import io.element.android.services.apperror.api.AppErrorState
|
import io.element.android.services.apperror.api.AppErrorState
|
||||||
import io.element.android.services.apperror.api.AppErrorStateService
|
import io.element.android.services.apperror.api.AppErrorStateService
|
||||||
|
|
@ -44,7 +38,6 @@ class RootPresenterTest {
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
presenter.present()
|
presenter.present()
|
||||||
}.test {
|
}.test {
|
||||||
skipItems(1)
|
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
assertThat(initialState.crashDetectionState.crashDetected).isFalse()
|
assertThat(initialState.crashDetectionState.crashDetected).isFalse()
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +54,7 @@ class RootPresenterTest {
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
presenter.present()
|
presenter.present()
|
||||||
}.test {
|
}.test {
|
||||||
skipItems(2)
|
skipItems(1)
|
||||||
lambda.assertions().isCalledOnce()
|
lambda.assertions().isCalledOnce()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,8 +69,6 @@ class RootPresenterTest {
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
presenter.present()
|
presenter.present()
|
||||||
}.test {
|
}.test {
|
||||||
skipItems(1)
|
|
||||||
|
|
||||||
val initialState = awaitItem()
|
val initialState = awaitItem()
|
||||||
assertThat(initialState.errorState).isInstanceOf(AppErrorState.Error::class.java)
|
assertThat(initialState.errorState).isInstanceOf(AppErrorState.Error::class.java)
|
||||||
val initialErrorState = initialState.errorState as AppErrorState.Error
|
val initialErrorState = initialState.errorState as AppErrorState.Error
|
||||||
|
|
@ -93,25 +84,9 @@ class RootPresenterTest {
|
||||||
appErrorService: AppErrorStateService = DefaultAppErrorStateService(),
|
appErrorService: AppErrorStateService = DefaultAppErrorStateService(),
|
||||||
shareService: ShareService = FakeShareService {},
|
shareService: ShareService = FakeShareService {},
|
||||||
): RootPresenter {
|
): RootPresenter {
|
||||||
val crashDataStore = FakeCrashDataStore()
|
|
||||||
val rageshakeDataStore = FakeRageshakeDataStore()
|
|
||||||
val rageshake = FakeRageShake()
|
|
||||||
val screenshotHolder = FakeScreenshotHolder()
|
|
||||||
val crashDetectionPresenter = DefaultCrashDetectionPresenter(
|
|
||||||
buildMeta = aBuildMeta(),
|
|
||||||
crashDataStore = crashDataStore
|
|
||||||
)
|
|
||||||
val rageshakeDetectionPresenter = DefaultRageshakeDetectionPresenter(
|
|
||||||
screenshotHolder = screenshotHolder,
|
|
||||||
rageShake = rageshake,
|
|
||||||
preferencesPresenter = DefaultRageshakePreferencesPresenter(
|
|
||||||
rageshake = rageshake,
|
|
||||||
rageshakeDataStore = rageshakeDataStore,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return RootPresenter(
|
return RootPresenter(
|
||||||
crashDetectionPresenter = crashDetectionPresenter,
|
crashDetectionPresenter = { aCrashDetectionState() },
|
||||||
rageshakeDetectionPresenter = rageshakeDetectionPresenter,
|
rageshakeDetectionPresenter = { aRageshakeDetectionState() },
|
||||||
appErrorStateService = appErrorService,
|
appErrorStateService = appErrorService,
|
||||||
analyticsService = FakeAnalyticsService(),
|
analyticsService = FakeAnalyticsService(),
|
||||||
shareService = shareService,
|
shareService = shareService,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
* Please see LICENSE in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.rageshake.impl.di
|
||||||
|
|
||||||
|
import com.squareup.anvil.annotations.ContributesTo
|
||||||
|
import dagger.Binds
|
||||||
|
import dagger.Module
|
||||||
|
import io.element.android.features.rageshake.api.crash.CrashDetectionPresenter
|
||||||
|
import io.element.android.features.rageshake.api.crash.CrashDetectionState
|
||||||
|
import io.element.android.features.rageshake.api.detection.RageshakeDetectionPresenter
|
||||||
|
import io.element.android.features.rageshake.api.detection.RageshakeDetectionState
|
||||||
|
import io.element.android.libraries.architecture.Presenter
|
||||||
|
import io.element.android.libraries.di.AppScope
|
||||||
|
|
||||||
|
@ContributesTo(AppScope::class)
|
||||||
|
@Module
|
||||||
|
interface RageshakeModule {
|
||||||
|
@Binds
|
||||||
|
fun bindRageshakeDetectionPresenter(presenter: RageshakeDetectionPresenter): Presenter<RageshakeDetectionState>
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
fun bindCrashDetectionPresenter(presenter: CrashDetectionPresenter): Presenter<CrashDetectionState>
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue