Add test for MessageComposerPresenter

This commit is contained in:
Benoit Marty 2023-02-08 09:56:55 +01:00
parent 21084c26b2
commit f736b48a92
7 changed files with 205 additions and 7 deletions

View file

@ -24,6 +24,8 @@ class StableCharSequence(val charSequence: CharSequence) {
override fun hashCode() = hash
override fun equals(other: Any?) = other is StableCharSequence && other.hash == hash
override fun toString(): String = "StableCharSequence(\"$charSequence\")"
}
fun CharSequence.toStableCharSequence() = StableCharSequence(this)

View file

@ -21,6 +21,7 @@ import io.element.android.libraries.matrix.core.RoomId
import io.element.android.libraries.matrix.room.MatrixRoom
import io.element.android.libraries.matrix.timeline.MatrixTimeline
import io.element.android.libraries.matrixtest.timeline.FakeMatrixTimeline
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
@ -51,7 +52,8 @@ class FakeMatrixRoom(
}
override suspend fun sendMessage(message: String): Result<Unit> {
TODO("Not yet implemented")
delay(100)
return Result.success(Unit)
}
override suspend fun editMessage(originalEventId: EventId, message: String): Result<Unit> {

View file

@ -22,14 +22,14 @@ 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"
const val A_MESSAGE = "Hello world!"
fun aRoomSummaryFilled(
roomId: RoomId = A_ROOM_ID,
name: String = A_ROOM_NAME,
isDirect: Boolean = false,
avatarURLString: String? = null,
lastMessage: CharSequence? = A_LAST_MESSAGE,
lastMessage: CharSequence? = A_MESSAGE,
lastMessageTimestamp: Long? = null,
unreadNotificationCount: Int = 2,
) = RoomSummary.Filled(
@ -49,7 +49,7 @@ fun aRoomSummaryDetail(
name: String = A_ROOM_NAME,
isDirect: Boolean = false,
avatarURLString: String? = null,
lastMessage: CharSequence? = A_LAST_MESSAGE,
lastMessage: CharSequence? = A_MESSAGE,
lastMessageTimestamp: Long? = null,
unreadNotificationCount: Int = 2,
) = RoomSummaryDetails(

View file

@ -24,6 +24,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emptyFlow
import org.matrix.rustcomponents.sdk.TimelineListener
const val A_SENDER_NAME = "Alice"
const val AN_EVENT_ID_VALUE = "!anEventId"
val AN_EVENT_ID = EventId(AN_EVENT_ID_VALUE)