mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Provide MutableStateFlow in the constructor of the fake class.
This commit is contained in:
+2
-8
@@ -12,11 +12,5 @@ import io.element.android.features.call.api.CurrentCallService
|
|||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
|
||||||
class FakeCurrentCallService(
|
class FakeCurrentCallService(
|
||||||
initialValue: CurrentCall = CurrentCall.None,
|
override val currentCall: MutableStateFlow<CurrentCall> = MutableStateFlow(CurrentCall.None),
|
||||||
) : CurrentCallService {
|
) : CurrentCallService
|
||||||
override val currentCall = MutableStateFlow(initialValue)
|
|
||||||
|
|
||||||
fun setCurrentCall(value: CurrentCall) {
|
|
||||||
currentCall.value = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+5
-3
@@ -16,6 +16,7 @@ import io.element.android.libraries.matrix.api.room.MatrixRoom
|
|||||||
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
||||||
import io.element.android.libraries.matrix.test.room.aRoomInfo
|
import io.element.android.libraries.matrix.test.room.aRoomInfo
|
||||||
import io.element.android.tests.testutils.test
|
import io.element.android.tests.testutils.test
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
@@ -112,7 +113,7 @@ class RoomCallStatePresenterTest {
|
|||||||
}
|
}
|
||||||
val presenter = createRoomCallStatePresenter(
|
val presenter = createRoomCallStatePresenter(
|
||||||
matrixRoom = room,
|
matrixRoom = room,
|
||||||
currentCallService = FakeCurrentCallService(initialValue = CurrentCall.RoomCall(room.roomId)),
|
currentCallService = FakeCurrentCallService(MutableStateFlow(CurrentCall.RoomCall(room.roomId))),
|
||||||
)
|
)
|
||||||
presenter.test {
|
presenter.test {
|
||||||
skipItems(1)
|
skipItems(1)
|
||||||
@@ -138,7 +139,8 @@ class RoomCallStatePresenterTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val currentCallService = FakeCurrentCallService(initialValue = CurrentCall.RoomCall(room.roomId))
|
val currentCall = MutableStateFlow<CurrentCall>(CurrentCall.RoomCall(room.roomId))
|
||||||
|
val currentCallService = FakeCurrentCallService(currentCall = currentCall)
|
||||||
val presenter = createRoomCallStatePresenter(
|
val presenter = createRoomCallStatePresenter(
|
||||||
matrixRoom = room,
|
matrixRoom = room,
|
||||||
currentCallService = currentCallService
|
currentCallService = currentCallService
|
||||||
@@ -152,7 +154,7 @@ class RoomCallStatePresenterTest {
|
|||||||
isUserLocallyInTheCall = true,
|
isUserLocallyInTheCall = true,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
currentCallService.setCurrentCall(CurrentCall.None)
|
currentCall.value = CurrentCall.None
|
||||||
assertThat(awaitItem()).isEqualTo(
|
assertThat(awaitItem()).isEqualTo(
|
||||||
RoomCallState.OnGoing(
|
RoomCallState.OnGoing(
|
||||||
canJoinCall = true,
|
canJoinCall = true,
|
||||||
|
|||||||
Reference in New Issue
Block a user