Merge branch 'develop' into feature/bma/push
This commit is contained in:
commit
1a33f6fc50
31 changed files with 502 additions and 49 deletions
|
|
@ -19,6 +19,7 @@ package io.element.android.libraries.matrix.test
|
|||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.media.MediaResolver
|
||||
import io.element.android.libraries.matrix.api.notification.NotificationService
|
||||
import io.element.android.libraries.matrix.api.pusher.PushersService
|
||||
|
|
@ -44,12 +45,25 @@ class FakeMatrixClient(
|
|||
private val notificationService: FakeNotificationService = FakeNotificationService(),
|
||||
) : MatrixClient {
|
||||
|
||||
private var createDmResult: Result<RoomId> = Result.success(A_ROOM_ID)
|
||||
private var createDmFailure: Throwable? = null
|
||||
private var findDmResult: MatrixRoom? = FakeMatrixRoom()
|
||||
private var logoutFailure: Throwable? = null
|
||||
|
||||
override fun getRoom(roomId: RoomId): MatrixRoom? {
|
||||
return FakeMatrixRoom(roomId)
|
||||
}
|
||||
|
||||
override suspend fun createDM(userId: UserId): Result<RoomId> {
|
||||
delay(100)
|
||||
createDmFailure?.let { throw it }
|
||||
return createDmResult
|
||||
}
|
||||
|
||||
override fun findDM(userId: UserId): MatrixRoom? {
|
||||
return findDmResult
|
||||
}
|
||||
|
||||
override fun startSync() = Unit
|
||||
|
||||
override fun stopSync() = Unit
|
||||
|
|
@ -58,10 +72,6 @@ class FakeMatrixClient(
|
|||
return FakeMediaResolver()
|
||||
}
|
||||
|
||||
fun givenLogoutError(failure: Throwable) {
|
||||
logoutFailure = failure
|
||||
}
|
||||
|
||||
override suspend fun logout() {
|
||||
delay(100)
|
||||
logoutFailure?.let { throw it }
|
||||
|
|
@ -96,4 +106,22 @@ class FakeMatrixClient(
|
|||
override fun roomMembershipObserver(): RoomMembershipObserver {
|
||||
return RoomMembershipObserver(A_SESSION_ID)
|
||||
}
|
||||
|
||||
// Mocks
|
||||
|
||||
fun givenLogoutError(failure: Throwable?) {
|
||||
logoutFailure = failure
|
||||
}
|
||||
|
||||
fun givenCreateDmResult(result: Result<RoomId>) {
|
||||
createDmResult = result
|
||||
}
|
||||
|
||||
fun givenCreateDmError(failure: Throwable?) {
|
||||
createDmFailure = failure
|
||||
}
|
||||
|
||||
fun givenFindDmResult(result: MatrixRoom?) {
|
||||
findDmResult = result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue