Remove runCancellableScopeTest and runCancellableScopeTestWithTestScope, we can use TestScope.backgroundScope instead.
This commit is contained in:
parent
b9c9706c48
commit
f89463c3a1
7 changed files with 68 additions and 101 deletions
|
|
@ -13,12 +13,12 @@ import io.element.android.libraries.matrix.api.roomdirectory.RoomDirectoryList
|
|||
import io.element.android.libraries.matrix.impl.fixtures.factories.aRustRoomDescription
|
||||
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRoomDirectorySearch
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID_2
|
||||
import io.element.android.tests.testutils.runCancellableScopeTestWithTestScope
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.runCurrent
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.matrix.rustcomponents.sdk.RoomDirectorySearch
|
||||
import org.matrix.rustcomponents.sdk.RoomDirectorySearchEntryUpdate
|
||||
|
|
@ -26,15 +26,15 @@ import org.matrix.rustcomponents.sdk.RoomDirectorySearchEntryUpdate
|
|||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class RustRoomDirectoryListTest {
|
||||
@Test
|
||||
fun `check that the state emits the expected values`() = runCancellableScopeTestWithTestScope { testScope, cancellableScope ->
|
||||
fun `check that the state emits the expected values`() = runTest {
|
||||
val fakeRoomDirectorySearch = FakeRoomDirectorySearch()
|
||||
val mapper = RoomDescriptionMapper()
|
||||
val sut = testScope.createRustRoomDirectoryList(
|
||||
val sut = createRustRoomDirectoryList(
|
||||
roomDirectorySearch = fakeRoomDirectorySearch,
|
||||
scope = cancellableScope,
|
||||
scope = backgroundScope,
|
||||
)
|
||||
// Let the mxCallback be ready
|
||||
testScope.runCurrent()
|
||||
runCurrent()
|
||||
sut.state.test {
|
||||
sut.filter("", 20)
|
||||
fakeRoomDirectorySearch.emitResult(
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@
|
|||
package io.element.android.libraries.matrix.impl.roomdirectory
|
||||
|
||||
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustClient
|
||||
import io.element.android.tests.testutils.runCancellableScopeTestWithTestScope
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
class RustRoomDirectoryServiceTest {
|
||||
@Test
|
||||
fun test() = runCancellableScopeTestWithTestScope { testScope, cancellableScope ->
|
||||
fun test() = runTest {
|
||||
val client = FakeRustClient()
|
||||
val sut = RustRoomDirectoryService(
|
||||
client = client,
|
||||
sessionDispatcher = StandardTestDispatcher(testScope.testScheduler),
|
||||
sessionDispatcher = StandardTestDispatcher(testScheduler),
|
||||
)
|
||||
sut.createRoomDirectoryList(cancellableScope)
|
||||
sut.createRoomDirectoryList(backgroundScope)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ package io.element.android.libraries.matrix.impl.roomlist
|
|||
|
||||
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustRoomList
|
||||
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustRoomListService
|
||||
import io.element.android.tests.testutils.runCancellableScopeTest
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
|
||||
class RoomListFactoryTest {
|
||||
@Test
|
||||
fun `createRoomList should work`() = runCancellableScopeTest {
|
||||
fun `createRoomList should work`() = runTest {
|
||||
val sut = RoomListFactory(
|
||||
innerRoomListService = FakeRustRoomListService(),
|
||||
sessionCoroutineScope = it,
|
||||
sessionCoroutineScope = backgroundScope,
|
||||
)
|
||||
sut.createRoomList(
|
||||
pageSize = 10,
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ import com.google.common.truth.Truth.assertThat
|
|||
import io.element.android.libraries.matrix.api.roomlist.RoomListService
|
||||
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustRoomListService
|
||||
import io.element.android.libraries.matrix.impl.room.RoomSyncSubscriber
|
||||
import io.element.android.tests.testutils.runCancellableScopeTestWithTestScope
|
||||
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.runCurrent
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicator
|
||||
import org.matrix.rustcomponents.sdk.RoomListService as RustRoomListService
|
||||
|
|
@ -25,14 +25,14 @@ import org.matrix.rustcomponents.sdk.RoomListService as RustRoomListService
|
|||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class RustRoomListServiceTest {
|
||||
@Test
|
||||
fun `syncIndicator should emit the expected values`() = runCancellableScopeTestWithTestScope { testScope, cancellableScope ->
|
||||
fun `syncIndicator should emit the expected values`() = runTest {
|
||||
val roomListService = FakeRustRoomListService()
|
||||
val sut = testScope.createRustRoomListService(
|
||||
sessionCoroutineScope = cancellableScope,
|
||||
val sut = createRustRoomListService(
|
||||
sessionCoroutineScope = backgroundScope,
|
||||
roomListService = roomListService,
|
||||
)
|
||||
// Give time for mxCallback to setup
|
||||
testScope.runCurrent()
|
||||
runCurrent()
|
||||
sut.syncIndicator.test {
|
||||
assertThat(awaitItem()).isEqualTo(RoomListService.SyncIndicator.Hide)
|
||||
roomListService.emitRoomListServiceSyncIndicator(RoomListServiceSyncIndicator.SHOW)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue