From 4bb33fc36a6cb5b7238378b663214169fcaf512d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 27 Apr 2026 17:06:49 +0200 Subject: [PATCH] Use test extension on presenters. --- .../impl/pip/PictureInPicturePresenterTest.kt | 24 +++++------------- .../call/ui/CallScreenPresenterTest.kt | 25 ++++++------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/features/call/impl/src/test/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenterTest.kt b/features/call/impl/src/test/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenterTest.kt index 97aa63947b..c3d7fdf17b 100644 --- a/features/call/impl/src/test/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenterTest.kt +++ b/features/call/impl/src/test/kotlin/io/element/android/features/call/impl/pip/PictureInPicturePresenterTest.kt @@ -8,11 +8,9 @@ package io.element.android.features.call.impl.pip -import app.cash.molecule.RecompositionMode -import app.cash.molecule.moleculeFlow -import app.cash.turbine.test import com.google.common.truth.Truth.assertThat import io.element.android.tests.testutils.lambda.lambdaRecorder +import io.element.android.tests.testutils.test import kotlinx.coroutines.test.runTest import org.junit.Test @@ -20,9 +18,7 @@ class PictureInPicturePresenterTest { @Test fun `when pip is not supported, the state value supportPip is false`() = runTest { val presenter = createPictureInPicturePresenter(supportPip = false) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() assertThat(initialState.supportPip).isFalse() } @@ -35,9 +31,7 @@ class PictureInPicturePresenterTest { supportPip = true, pipView = FakePipView(setPipParamsResult = { }), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() assertThat(initialState.supportPip).isTrue() } @@ -53,9 +47,7 @@ class PictureInPicturePresenterTest { enterPipModeResult = enterPipModeResult, ), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() assertThat(initialState.isInPictureInPicture).isFalse() initialState.eventSink(PictureInPictureEvent.EnterPictureInPicture) @@ -80,9 +72,7 @@ class PictureInPicturePresenterTest { handUpResult = handUpResult ), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() initialState.eventSink(PictureInPictureEvent.SetPipController(FakePipController(canEnterPipResult = { false }))) initialState.eventSink(PictureInPictureEvent.EnterPictureInPicture) @@ -102,9 +92,7 @@ class PictureInPicturePresenterTest { enterPipModeResult = enterPipModeResult ), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() initialState.eventSink( PictureInPictureEvent.SetPipController( diff --git a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt index 99f10b46fc..276e6670f1 100644 --- a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt +++ b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt @@ -39,6 +39,7 @@ import io.element.android.services.toolbox.api.systemclock.SystemClock import io.element.android.tests.testutils.WarmUpRule import io.element.android.tests.testutils.lambda.lambdaRecorder import io.element.android.tests.testutils.lambda.value +import io.element.android.tests.testutils.test import io.element.android.tests.testutils.testCoroutineDispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.cancelAndJoin @@ -71,9 +72,7 @@ class CallScreenPresenterTest { screenTracker = FakeScreenTracker(analyticsLambda), activeCallManager = FakeActiveCallManager(joinedCallResult = joinedCallLambda), ) - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { // Wait until the URL is loaded advanceTimeBy(1.seconds) skipItems(1) @@ -102,9 +101,7 @@ class CallScreenPresenterTest { screenTracker = FakeScreenTracker {}, ) val messageInterceptor = FakeWidgetMessageInterceptor() - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { // Give it time to load the URL and WidgetDriver advanceTimeBy(1.seconds) @@ -135,9 +132,7 @@ class CallScreenPresenterTest { screenTracker = FakeScreenTracker {}, ) val messageInterceptor = FakeWidgetMessageInterceptor() - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() // Give it time to load the URL and WidgetDriver @@ -169,9 +164,7 @@ class CallScreenPresenterTest { screenTracker = FakeScreenTracker {}, ) val messageInterceptor = FakeWidgetMessageInterceptor() - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { val initialState = awaitItem() // Give it time to load the URL and WidgetDriver @@ -204,9 +197,7 @@ class CallScreenPresenterTest { screenTracker = FakeScreenTracker {}, ) val messageInterceptor = FakeWidgetMessageInterceptor() - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { // Give it time to load the URL and WidgetDriver advanceTimeBy(1.seconds) skipItems(2) @@ -241,9 +232,7 @@ class CallScreenPresenterTest { screenTracker = FakeScreenTracker {}, ) val messageInterceptor = FakeWidgetMessageInterceptor() - moleculeFlow(RecompositionMode.Immediate) { - presenter.present() - }.test { + presenter.test { // Give it time to load the URL and WidgetDriver advanceTimeBy(1.seconds) skipItems(2)