Add some tests on RoomFlowNode
This commit is contained in:
parent
747467deb9
commit
a166636060
14 changed files with 240 additions and 31 deletions
|
|
@ -27,4 +27,5 @@ android {
|
|||
dependencies {
|
||||
api(projects.libraries.matrix.api)
|
||||
api(projects.services.appnavstate.api)
|
||||
implementation(libs.coroutines.core)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,27 +23,31 @@ import io.element.android.libraries.matrix.api.core.SpaceId
|
|||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
import io.element.android.services.appnavstate.api.AppNavigationState
|
||||
|
||||
const val A_SESSION_OWNER = "aSessionOwner"
|
||||
const val A_SPACE_OWNER = "aSpaceOwner"
|
||||
const val A_ROOM_OWNER = "aRoomOwner"
|
||||
const val A_THREAD_OWNER = "aThreadOwner"
|
||||
|
||||
fun anAppNavigationState(
|
||||
sessionId: SessionId? = null,
|
||||
spaceId: SpaceId? = MAIN_SPACE,
|
||||
roomId: RoomId? = null,
|
||||
threadId: ThreadId? = null,
|
||||
owner: String = "a-owner",
|
||||
): AppNavigationState {
|
||||
if (sessionId == null) {
|
||||
return AppNavigationState.Root
|
||||
}
|
||||
val session = AppNavigationState.Session(owner, sessionId)
|
||||
val session = AppNavigationState.Session(A_SESSION_OWNER, sessionId)
|
||||
if (spaceId == null) {
|
||||
return session
|
||||
}
|
||||
val space = AppNavigationState.Space(owner, spaceId, session)
|
||||
val space = AppNavigationState.Space(A_SPACE_OWNER, spaceId, session)
|
||||
if (roomId == null) {
|
||||
return space
|
||||
}
|
||||
val room = AppNavigationState.Room(owner, roomId, space)
|
||||
val room = AppNavigationState.Room(A_ROOM_OWNER, roomId, space)
|
||||
if (threadId == null) {
|
||||
return room
|
||||
}
|
||||
return AppNavigationState.Thread(owner, threadId, room)
|
||||
return AppNavigationState.Thread(A_THREAD_OWNER, threadId, room)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* 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.services.appnavstate.test
|
||||
|
||||
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.SpaceId
|
||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
import io.element.android.services.appnavstate.api.AppNavigationState
|
||||
import io.element.android.services.appnavstate.api.AppNavigationStateService
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
class NoopAppNavigationStateService : AppNavigationStateService {
|
||||
|
||||
private val currentAppNavigationState: MutableStateFlow<AppNavigationState> =
|
||||
MutableStateFlow(AppNavigationState.Root)
|
||||
override val appNavigationStateFlow: StateFlow<AppNavigationState> = currentAppNavigationState
|
||||
|
||||
override fun onNavigateToSession(owner: String, sessionId: SessionId) = Unit
|
||||
override fun onLeavingSession(owner: String) = Unit
|
||||
|
||||
override fun onNavigateToSpace(owner: String, spaceId: SpaceId) = Unit
|
||||
|
||||
override fun onLeavingSpace(owner: String) = Unit
|
||||
|
||||
override fun onNavigateToRoom(owner: String, roomId: RoomId) = Unit
|
||||
|
||||
override fun onLeavingRoom(owner: String) = Unit
|
||||
|
||||
override fun onNavigateToThread(owner: String, threadId: ThreadId) = Unit
|
||||
|
||||
override fun onLeavingThread(owner: String) = Unit
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue