Merge branch 'develop' into feature/fga/join_space
This commit is contained in:
commit
c4308e9810
446 changed files with 5669 additions and 2617 deletions
|
|
@ -90,7 +90,6 @@ class FakeMatrixClient(
|
|||
private val canDeactivateAccountResult: () -> Boolean = { lambdaError() },
|
||||
private val deactivateAccountResult: (String, Boolean) -> Result<Unit> = { _, _ -> lambdaError() },
|
||||
private val currentSlidingSyncVersionLambda: () -> Result<SlidingSyncVersion> = { lambdaError() },
|
||||
private val availableSlidingSyncVersionsLambda: () -> Result<List<SlidingSyncVersion>> = { lambdaError() },
|
||||
private val ignoreUserResult: (UserId) -> Result<Unit> = { lambdaError() },
|
||||
private var unIgnoreUserResult: (UserId) -> Result<Unit> = { Result.success(Unit) },
|
||||
private val canReportRoomLambda: () -> Boolean = { false },
|
||||
|
|
@ -339,10 +338,6 @@ class FakeMatrixClient(
|
|||
return currentSlidingSyncVersionLambda()
|
||||
}
|
||||
|
||||
override suspend fun availableSlidingSyncVersions(): Result<List<SlidingSyncVersion>> {
|
||||
return availableSlidingSyncVersionsLambda()
|
||||
}
|
||||
|
||||
override suspend fun canReportRoom(): Boolean {
|
||||
return canReportRoomLambda()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ const val A_USER_NAME_2 = "Bob"
|
|||
const val A_PASSWORD = "password"
|
||||
const val A_PASSPHRASE = "passphrase"
|
||||
const val A_SECRET = "secret"
|
||||
const val AN_APPLICATION_NAME = "AppName"
|
||||
|
||||
val A_USER_ID = UserId("@alice:server.org")
|
||||
val A_USER_ID_2 = UserId("@bob:server.org")
|
||||
|
|
|
|||
|
|
@ -19,14 +19,11 @@ import io.element.android.libraries.matrix.api.core.SessionId
|
|||
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||
import io.element.android.libraries.matrix.test.A_USER_ID
|
||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||
import io.element.android.libraries.sessionstorage.api.LoggedInState
|
||||
import io.element.android.tests.testutils.lambda.lambdaError
|
||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
|
||||
val A_OIDC_DATA = OidcDetails(url = "a-url")
|
||||
|
||||
|
|
@ -44,14 +41,6 @@ class FakeMatrixAuthenticationService(
|
|||
private var matrixClient: MatrixClient? = null
|
||||
private var onAuthenticationListener: ((MatrixClient) -> Unit)? = null
|
||||
|
||||
var getLatestSessionIdLambda: (() -> SessionId?) = { null }
|
||||
|
||||
override fun loggedInStateFlow(): Flow<LoggedInState> {
|
||||
return flowOf(LoggedInState.NotLoggedIn)
|
||||
}
|
||||
|
||||
override suspend fun getLatestSessionId(): SessionId? = getLatestSessionIdLambda()
|
||||
|
||||
override suspend fun restoreSession(sessionId: SessionId): Result<MatrixClient> {
|
||||
matrixClientResult?.let {
|
||||
return it.invoke(sessionId)
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import io.element.android.libraries.matrix.test.A_SESSION_ID
|
|||
import io.element.android.tests.testutils.lambda.lambdaError
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
|
|
@ -77,6 +79,12 @@ class FakeBaseRoom(
|
|||
_roomInfoFlow.tryEmit(roomInfo)
|
||||
}
|
||||
|
||||
private val declineCallFlowMap: MutableMap<EventId, MutableSharedFlow<UserId>> = mutableMapOf()
|
||||
|
||||
suspend fun givenDecliner(userId: UserId, forNotificationEventId: EventId) {
|
||||
declineCallFlowMap[forNotificationEventId]?.emit(userId)
|
||||
}
|
||||
|
||||
override val membersStateFlow: MutableStateFlow<RoomMembersState> = MutableStateFlow(RoomMembersState.Unknown)
|
||||
|
||||
override suspend fun updateMembers() = updateMembersResult()
|
||||
|
|
@ -222,6 +230,15 @@ class FakeBaseRoom(
|
|||
|
||||
override suspend fun reportRoom(reason: String?) = reportRoomResult(reason)
|
||||
|
||||
override suspend fun declineCall(notificationEventId: EventId): Result<Unit> {
|
||||
return Result.success(Unit)
|
||||
}
|
||||
|
||||
override suspend fun subscribeToCallDecline(notificationEventId: EventId): Flow<UserId> {
|
||||
val flow = declineCallFlowMap.getOrPut(notificationEventId, { MutableSharedFlow() })
|
||||
return flow
|
||||
}
|
||||
|
||||
override fun predecessorRoom(): PredecessorRoom? = predecessorRoomResult()
|
||||
|
||||
fun givenUpdateMembersResult(result: () -> Unit) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ fun aRoomMember(
|
|||
membership: RoomMembershipState = RoomMembershipState.JOIN,
|
||||
isNameAmbiguous: Boolean = false,
|
||||
powerLevel: Long = 0L,
|
||||
normalizedPowerLevel: Long = 0L,
|
||||
isIgnored: Boolean = false,
|
||||
role: RoomMember.Role = RoomMember.Role.User,
|
||||
membershipChangeReason: String? = null,
|
||||
|
|
@ -30,7 +29,6 @@ fun aRoomMember(
|
|||
membership = membership,
|
||||
isNameAmbiguous = isNameAmbiguous,
|
||||
powerLevel = powerLevel,
|
||||
normalizedPowerLevel = normalizedPowerLevel,
|
||||
isIgnored = isIgnored,
|
||||
role = role,
|
||||
membershipChangeReason = membershipChangeReason,
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ class FakeSpaceRoomList(
|
|||
initialSpaceRoomList: SpaceRoomList.PaginationStatus = SpaceRoomList.PaginationStatus.Loading,
|
||||
private val paginateResult: () -> Result<Unit> = { lambdaError() },
|
||||
) : SpaceRoomList {
|
||||
private val _currentSpaceFlow: MutableStateFlow<Optional<SpaceRoom>> = MutableStateFlow(Optional.ofNullable(initialSpaceFlowValue))
|
||||
override fun currentSpaceFlow() = _currentSpaceFlow.asStateFlow()
|
||||
private val currentSpaceMutableStateFlow: MutableStateFlow<Optional<SpaceRoom>> = MutableStateFlow(Optional.ofNullable(initialSpaceFlowValue))
|
||||
override fun currentSpaceFlow(): StateFlow<Optional<SpaceRoom>> = currentSpaceMutableStateFlow.asStateFlow()
|
||||
|
||||
fun emitCurrentSpace(value: SpaceRoom?) {
|
||||
_currentSpaceFlow.value = Optional.ofNullable(value)
|
||||
currentSpaceMutableStateFlow.value = Optional.ofNullable(value)
|
||||
}
|
||||
|
||||
private val _spaceRoomsFlow: MutableStateFlow<List<SpaceRoom>> = MutableStateFlow(initialSpaceRoomsValue)
|
||||
|
|
|
|||
|
|
@ -304,9 +304,9 @@ class FakeTimeline(
|
|||
)
|
||||
}
|
||||
|
||||
var toggleReactionLambda: (emoji: String, eventOrTransactionId: EventOrTransactionId) -> Result<Unit> = { _, _ -> lambdaError() }
|
||||
var toggleReactionLambda: (emoji: String, eventOrTransactionId: EventOrTransactionId) -> Result<Boolean> = { _, _ -> lambdaError() }
|
||||
|
||||
override suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Unit> = simulateLongTask {
|
||||
override suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Boolean> = simulateLongTask {
|
||||
toggleReactionLambda(
|
||||
emoji,
|
||||
eventOrTransactionId,
|
||||
|
|
|
|||
|
|
@ -11,12 +11,18 @@ import io.element.android.libraries.matrix.api.widget.CallWidgetSettingsProvider
|
|||
import io.element.android.libraries.matrix.api.widget.MatrixWidgetSettings
|
||||
|
||||
class FakeCallWidgetSettingsProvider(
|
||||
private val provideFn: (String, String, Boolean, Boolean) -> MatrixWidgetSettings = { _, _, _, _ -> MatrixWidgetSettings("id", true, "url") }
|
||||
private val provideFn: (String, String, Boolean, Boolean, Boolean) -> MatrixWidgetSettings = { _, _, _, _, _ -> MatrixWidgetSettings("id", true, "url") }
|
||||
) : CallWidgetSettingsProvider {
|
||||
val providedBaseUrls = mutableListOf<String>()
|
||||
|
||||
override suspend fun provide(baseUrl: String, widgetId: String, encrypted: Boolean, direct: Boolean): MatrixWidgetSettings {
|
||||
override suspend fun provide(
|
||||
baseUrl: String,
|
||||
widgetId: String,
|
||||
encrypted: Boolean,
|
||||
direct: Boolean,
|
||||
hasActiveCall: Boolean
|
||||
): MatrixWidgetSettings {
|
||||
providedBaseUrls += baseUrl
|
||||
return provideFn(baseUrl, widgetId, encrypted, direct)
|
||||
return provideFn(baseUrl, widgetId, encrypted, direct, hasActiveCall)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue