Add test on RustRoomDirectoryService
This commit is contained in:
parent
8a7f657741
commit
f1a1a2cf48
5 changed files with 42 additions and 2 deletions
|
|
@ -19,8 +19,8 @@ import kotlin.coroutines.CoroutineContext
|
||||||
class RoomDirectorySearchProcessor(
|
class RoomDirectorySearchProcessor(
|
||||||
private val roomDescriptions: MutableSharedFlow<List<RoomDescription>>,
|
private val roomDescriptions: MutableSharedFlow<List<RoomDescription>>,
|
||||||
private val coroutineContext: CoroutineContext,
|
private val coroutineContext: CoroutineContext,
|
||||||
private val roomDescriptionMapper: RoomDescriptionMapper,
|
|
||||||
) {
|
) {
|
||||||
|
private val roomDescriptionMapper: RoomDescriptionMapper = RoomDescriptionMapper()
|
||||||
private val mutex = Mutex()
|
private val mutex = Mutex()
|
||||||
|
|
||||||
suspend fun postUpdates(updates: List<RoomDirectorySearchEntryUpdate>) {
|
suspend fun postUpdates(updates: List<RoomDirectorySearchEntryUpdate>) {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class RustRoomDirectoryList(
|
||||||
) : RoomDirectoryList {
|
) : RoomDirectoryList {
|
||||||
private val hasMoreToLoad = MutableStateFlow(true)
|
private val hasMoreToLoad = MutableStateFlow(true)
|
||||||
private val items = MutableSharedFlow<List<RoomDescription>>(replay = 1)
|
private val items = MutableSharedFlow<List<RoomDescription>>(replay = 1)
|
||||||
private val processor = RoomDirectorySearchProcessor(items, coroutineContext, RoomDescriptionMapper())
|
private val processor = RoomDirectorySearchProcessor(items, coroutineContext)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
launchIn(coroutineScope)
|
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.NotificationClient
|
||||||
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
|
||||||
import org.matrix.rustcomponents.sdk.NotificationSettings
|
import org.matrix.rustcomponents.sdk.NotificationSettings
|
||||||
|
import org.matrix.rustcomponents.sdk.RoomDirectorySearch
|
||||||
import org.matrix.rustcomponents.sdk.Session
|
import org.matrix.rustcomponents.sdk.Session
|
||||||
import org.matrix.rustcomponents.sdk.SyncServiceBuilder
|
import org.matrix.rustcomponents.sdk.SyncServiceBuilder
|
||||||
import org.matrix.rustcomponents.sdk.TaskHandle
|
import org.matrix.rustcomponents.sdk.TaskHandle
|
||||||
|
|
@ -39,4 +40,5 @@ class FakeRustClient(
|
||||||
override fun cachedAvatarUrl(): String? = null
|
override fun cachedAvatarUrl(): String? = null
|
||||||
override suspend fun restoreSession(session: Session) = Unit
|
override suspend fun restoreSession(session: Session) = Unit
|
||||||
override fun syncService(): SyncServiceBuilder = FakeRustSyncServiceBuilder()
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue