Move NotUsedPresenter to the testutils module

The fake presenter was declared in RootFlowNodeTest, so other tests could
not use it. Move it to the testutils module, in a new presenter package,
along with MutablePresenter.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benoit Marty
2026-08-20 15:51:30 +02:00
parent d71f691d75
commit e85c5041a4
3 changed files with 21 additions and 10 deletions
@@ -43,7 +43,6 @@ import io.element.android.features.signedout.test.FakeSignedOutEntryPoint
import io.element.android.libraries.accountselect.test.FakeAccountSelectEntryPoint
import io.element.android.libraries.architecture.AssistedNodeFactory
import io.element.android.libraries.architecture.NodeFactoriesBindings
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.di.DependencyInjectionGraphOwner
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
import io.element.android.libraries.matrix.test.FakeSdkMetadata
@@ -58,6 +57,7 @@ import io.element.android.libraries.sessionstorage.test.InMemorySessionStore
import io.element.android.services.analytics.test.FakeAnalyticsService
import io.element.android.services.analytics.test.watchers.FakeAnalyticsColdStartWatcher
import io.element.android.services.apperror.test.FakeAppErrorStateService
import io.element.android.tests.testutils.presenter.NotUsedPresenter
import io.element.android.tests.testutils.robolectric.RobolectricTest
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
@@ -194,14 +194,6 @@ private val A_LOGIN_ENTRY_POINT_PARAMS = LoginEntryPoint.Params(
loginHint = A_LOGIN_PARAMS.loginHint,
)
/**
* The presenters are only used when the [Node] is rendered, which does not happen in these tests.
*/
private class NotUsedPresenter<T> : Presenter<T> {
@Composable
override fun present(): T = error("Not used")
}
private class FakeNodeFactoriesBindings(
private val nodeFactories: Map<KClass<out Node>, AssistedNodeFactory<*>>,
) : NodeFactoriesBindings {
@@ -6,7 +6,7 @@
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.tests.testutils
package io.element.android.tests.testutils.presenter
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2026 Element Creations Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.tests.testutils.presenter
import androidx.compose.runtime.Composable
import io.element.android.libraries.architecture.Presenter
/**
* A presenter that cannot be used, util for testing Nodes.
*/
class NotUsedPresenter<T> : Presenter<T> {
@Composable
override fun present(): T = error("Not used")
}