Add test on RustRoomDirectoryService
This commit is contained in:
@@ -19,8 +19,8 @@ import kotlin.coroutines.CoroutineContext
|
||||
class RoomDirectorySearchProcessor(
|
||||
private val roomDescriptions: MutableSharedFlow<List<RoomDescription>>,
|
||||
private val coroutineContext: CoroutineContext,
|
||||
private val roomDescriptionMapper: RoomDescriptionMapper,
|
||||
) {
|
||||
private val roomDescriptionMapper: RoomDescriptionMapper = RoomDescriptionMapper()
|
||||
private val mutex = Mutex()
|
||||
|
||||
suspend fun postUpdates(updates: List<RoomDirectorySearchEntryUpdate>) {
|
||||
|
||||
@@ -28,7 +28,7 @@ class RustRoomDirectoryList(
|
||||
) : RoomDirectoryList {
|
||||
private val hasMoreToLoad = MutableStateFlow(true)
|
||||
private val items = MutableSharedFlow<List<RoomDescription>>(replay = 1)
|
||||
private val processor = RoomDirectorySearchProcessor(items, coroutineContext, RoomDescriptionMapper())
|
||||
private val processor = RoomDirectorySearchProcessor(items, coroutineContext)
|
||||
|
||||
init {
|
||||
launchIn(coroutineScope)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* 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.libraries.matrix.impl.fixtures.fakes
|
||||
|
||||
import org.matrix.rustcomponents.sdk.NoPointer
|
||||
import org.matrix.rustcomponents.sdk.RoomDirectorySearch
|
||||
|
||||
class FakeRoomDirectorySearch : RoomDirectorySearch(NoPointer)
|
||||
@@ -17,6 +17,7 @@ import org.matrix.rustcomponents.sdk.NoPointer
|
||||
import org.matrix.rustcomponents.sdk.NotificationClient
|
||||
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
||||
import org.matrix.rustcomponents.sdk.NotificationSettings
|
||||
import org.matrix.rustcomponents.sdk.RoomDirectorySearch
|
||||
import org.matrix.rustcomponents.sdk.Session
|
||||
import org.matrix.rustcomponents.sdk.SyncServiceBuilder
|
||||
import org.matrix.rustcomponents.sdk.TaskHandle
|
||||
@@ -39,4 +40,5 @@ class FakeRustClient(
|
||||
override fun cachedAvatarUrl(): String? = null
|
||||
override suspend fun restoreSession(session: Session) = Unit
|
||||
override fun syncService(): SyncServiceBuilder = FakeRustSyncServiceBuilder()
|
||||
override fun roomDirectorySearch(): RoomDirectorySearch = FakeRoomDirectorySearch()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.libraries.matrix.impl.roomdirectory
|
||||
|
||||
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustClient
|
||||
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
class RustRoomDirectoryServiceTest {
|
||||
@Test
|
||||
fun test() = runTest {
|
||||
val client = FakeRustClient()
|
||||
val sut = RustRoomDirectoryService(
|
||||
client = client,
|
||||
sessionDispatcher = testCoroutineDispatchers().io,
|
||||
)
|
||||
sut.createRoomDirectoryList(this)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user