Enable testFixtures - but not supported by AGP yet, so put files in module matrixtest
This commit is contained in:
parent
cb158acf00
commit
feac348c89
9 changed files with 157 additions and 4 deletions
|
|
@ -28,7 +28,10 @@ import io.element.android.libraries.matrixtest.room.FakeMatrixRoom
|
|||
import io.element.android.libraries.matrixtest.room.InMemoryRoomSummaryDataSource
|
||||
import org.matrix.rustcomponents.sdk.MediaSource
|
||||
|
||||
class FakeMatrixClient(override val sessionId: SessionId) : MatrixClient {
|
||||
class FakeMatrixClient(
|
||||
override val sessionId: SessionId,
|
||||
val roomSummaryDataSource: RoomSummaryDataSource = InMemoryRoomSummaryDataSource()
|
||||
) : MatrixClient {
|
||||
|
||||
override fun getRoom(roomId: RoomId): MatrixRoom? {
|
||||
return FakeMatrixRoom(roomId)
|
||||
|
|
@ -39,7 +42,7 @@ class FakeMatrixClient(override val sessionId: SessionId) : MatrixClient {
|
|||
override fun stopSync() = Unit
|
||||
|
||||
override fun roomSummaryDataSource(): RoomSummaryDataSource {
|
||||
return InMemoryRoomSummaryDataSource()
|
||||
return roomSummaryDataSource
|
||||
}
|
||||
|
||||
override fun mediaResolver(): MediaResolver {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrixtest.core
|
||||
|
||||
import io.element.android.libraries.matrix.core.RoomId
|
||||
|
||||
const val A_ROOM_ID_VALUE = "!aRoomId"
|
||||
val A_ROOM_ID = RoomId(A_ROOM_ID_VALUE)
|
||||
|
|
@ -23,8 +23,14 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
|
||||
class InMemoryRoomSummaryDataSource : RoomSummaryDataSource {
|
||||
|
||||
private val roomSummariesFlow = MutableStateFlow<List<RoomSummary>>(emptyList())
|
||||
|
||||
suspend fun postRoomSummary(roomSummaries: List<RoomSummary>) {
|
||||
roomSummariesFlow.emit(roomSummaries)
|
||||
}
|
||||
|
||||
override fun roomSummaries(): StateFlow<List<RoomSummary>> {
|
||||
return MutableStateFlow(emptyList())
|
||||
return roomSummariesFlow
|
||||
}
|
||||
|
||||
override fun setSlidingSyncRange(range: IntRange) = Unit
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2023 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrixtest.room
|
||||
|
||||
import io.element.android.libraries.matrix.core.RoomId
|
||||
import io.element.android.libraries.matrix.room.RoomSummary
|
||||
import io.element.android.libraries.matrix.room.RoomSummaryDetails
|
||||
import io.element.android.libraries.matrixtest.core.A_ROOM_ID
|
||||
|
||||
const val A_ROOM_NAME = "aRoomName"
|
||||
const val A_LAST_MESSAGE = "Last message"
|
||||
|
||||
fun aRoomSummaryFilled(
|
||||
roomId: RoomId = A_ROOM_ID,
|
||||
name: String = A_ROOM_NAME,
|
||||
isDirect: Boolean = false,
|
||||
avatarURLString: String? = null,
|
||||
lastMessage: CharSequence? = A_LAST_MESSAGE,
|
||||
lastMessageTimestamp: Long? = null,
|
||||
unreadNotificationCount: Int = 2,
|
||||
) = RoomSummary.Filled(
|
||||
aRoomSummaryDetail(
|
||||
roomId = roomId,
|
||||
name = name,
|
||||
isDirect = isDirect,
|
||||
avatarURLString = avatarURLString,
|
||||
lastMessage = lastMessage,
|
||||
lastMessageTimestamp = lastMessageTimestamp,
|
||||
unreadNotificationCount = unreadNotificationCount,
|
||||
)
|
||||
)
|
||||
|
||||
fun aRoomSummaryDetail(
|
||||
roomId: RoomId = A_ROOM_ID,
|
||||
name: String = A_ROOM_NAME,
|
||||
isDirect: Boolean = false,
|
||||
avatarURLString: String? = null,
|
||||
lastMessage: CharSequence? = A_LAST_MESSAGE,
|
||||
lastMessageTimestamp: Long? = null,
|
||||
unreadNotificationCount: Int = 2,
|
||||
) = RoomSummaryDetails(
|
||||
roomId = roomId,
|
||||
name = name,
|
||||
isDirect = isDirect,
|
||||
avatarURLString = avatarURLString,
|
||||
lastMessage = lastMessage,
|
||||
lastMessageTimestamp = lastMessageTimestamp,
|
||||
unreadNotificationCount = unreadNotificationCount,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue