Merge pull request #1634 from vector-im/feature/bma/codeCoverage
Code coverage
This commit is contained in:
commit
c04f95e974
141 changed files with 444 additions and 60 deletions
|
|
@ -198,6 +198,8 @@ koverMerged {
|
|||
// We do not cover Nodes (normally covered by maestro, but code coverage is not computed with maestro)
|
||||
"*Node",
|
||||
"*Node$*",
|
||||
// Exclude `:libraries:matrix:impl` module, it contains only wrappers to access the Rust Matrix SDK api, so it is not really relevant to unit test it: there is no logic to test.
|
||||
"io.element.android.libraries.matrix.impl.*",
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package io.element.android.features.messages.impl
|
|||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.features.messages.impl.actionlist.anActionListState
|
||||
import io.element.android.features.messages.impl.messagecomposer.AttachmentsState
|
||||
import io.element.android.features.messages.impl.messagecomposer.aMessageComposerState
|
||||
import io.element.android.features.messages.impl.timeline.aTimelineItemList
|
||||
import io.element.android.features.messages.impl.timeline.aTimelineState
|
||||
|
|
@ -32,6 +33,7 @@ import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
|||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.textcomposer.model.MessageComposerMode
|
||||
import io.element.android.wysiwyg.compose.RichTextEditorState
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
|
||||
open class MessagesStateProvider : PreviewParameterProvider<MessagesState> {
|
||||
|
|
@ -47,6 +49,20 @@ open class MessagesStateProvider : PreviewParameterProvider<MessagesState> {
|
|||
roomAvatar = Async.Uninitialized,
|
||||
),
|
||||
aMessagesState().copy(composerState = aMessageComposerState().copy(showTextFormatting = true)),
|
||||
aMessagesState().copy(
|
||||
enableVoiceMessages = true,
|
||||
voiceMessageComposerState = aVoiceMessageComposerState(showPermissionRationaleDialog = true),
|
||||
),
|
||||
aMessagesState().copy(
|
||||
composerState = aMessageComposerState().copy(
|
||||
attachmentsState = AttachmentsState.Sending.Processing(persistentListOf())
|
||||
),
|
||||
),
|
||||
aMessagesState().copy(
|
||||
composerState = aMessageComposerState().copy(
|
||||
attachmentsState = AttachmentsState.Sending.Uploading(0.33f)
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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.features.messages.impl.timeline.components.customreaction
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.ripple.rememberRipple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.emojibasebindings.Emoji
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.libraries.theme.ElementTheme
|
||||
|
||||
@Composable
|
||||
fun EmojiItem(
|
||||
item: Emoji,
|
||||
isSelected: Boolean,
|
||||
onEmojiSelected: (Emoji) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val backgroundColor = if (isSelected) {
|
||||
ElementTheme.colors.bgActionPrimaryRest
|
||||
} else {
|
||||
Color.Transparent
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
.size(40.dp)
|
||||
.background(backgroundColor, CircleShape)
|
||||
.clickable(
|
||||
enabled = true,
|
||||
onClick = { onEmojiSelected(item) },
|
||||
indication = rememberRipple(bounded = false, radius = 20.dp),
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = item.unicode,
|
||||
style = ElementTheme.typography.fontHeadingSmRegular,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun EmojiItemPreview() = ElementPreview {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
for (isSelected in listOf(true, false)) {
|
||||
EmojiItem(
|
||||
item = Emoji(
|
||||
hexcode = "",
|
||||
label = "",
|
||||
tags = null,
|
||||
shortcodes = emptyList(),
|
||||
unicode = "👍",
|
||||
skins = null
|
||||
),
|
||||
isSelected = isSelected,
|
||||
onEmojiSelected = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,31 +17,22 @@
|
|||
package io.element.android.features.messages.impl.timeline.components.customreaction
|
||||
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.ripple.rememberRipple
|
||||
import androidx.compose.material3.SecondaryTabRow
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
|
@ -52,8 +43,6 @@ import io.element.android.emojibasebindings.EmojibaseStore
|
|||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.libraries.theme.ElementTheme
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -101,31 +90,12 @@ fun EmojiPicker(
|
|||
contentPadding = PaddingValues(vertical = 10.dp, horizontal = 16.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
|
||||
items(emojis, key = { it.unicode }) { item ->
|
||||
val backgroundColor = if (selectedEmojis.contains(item.unicode)) {
|
||||
ElementTheme.colors.bgActionPrimaryRest
|
||||
} else {
|
||||
Color.Transparent
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.background(backgroundColor, CircleShape)
|
||||
.clickable(
|
||||
enabled = true,
|
||||
onClick = { onEmojiSelected(item) },
|
||||
indication = rememberRipple(bounded = false, radius = 20.dp),
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = item.unicode,
|
||||
style = ElementTheme.typography.fontHeadingSmRegular,
|
||||
)
|
||||
}
|
||||
EmojiItem(
|
||||
item = item,
|
||||
isSelected = selectedEmojis.contains(item.unicode),
|
||||
onEmojiSelected = onEmojiSelected
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ internal open class VoiceMessageComposerStateProvider : PreviewParameterProvider
|
|||
|
||||
internal fun aVoiceMessageComposerState(
|
||||
voiceMessageState: VoiceMessageState = VoiceMessageState.Idle,
|
||||
showPermissionRationaleDialog: Boolean = false,
|
||||
) = VoiceMessageComposerState(
|
||||
voiceMessageState = voiceMessageState,
|
||||
showPermissionRationaleDialog = false,
|
||||
showPermissionRationaleDialog = showPermissionRationaleDialog,
|
||||
eventSink = {},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,11 @@ open class RoomDetailsStateProvider : PreviewParameterProvider<RoomDetailsState>
|
|||
aDmRoomDetailsState().copy(roomName = "Daniel"),
|
||||
aDmRoomDetailsState(isDmMemberIgnored = true).copy(roomName = "Daniel"),
|
||||
aRoomDetailsState().copy(canInvite = true),
|
||||
aRoomDetailsState().copy(canEdit = true),
|
||||
aRoomDetailsState().copy(
|
||||
canEdit = true,
|
||||
// Also test the roomNotificationSettings ALL_MESSAGES in the same screenshot. Icon 'Mute' should be displayed
|
||||
roomNotificationSettings = RoomNotificationSettings(mode = RoomNotificationMode.ALL_MESSAGES, isDefault = true)
|
||||
),
|
||||
// Add other state here
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package io.element.android.features.roomdetails.impl
|
|||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||
|
|
@ -76,7 +75,6 @@ import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
|||
import io.element.android.libraries.theme.ElementTheme
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
||||
@OptIn(ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
fun RoomDetailsView(
|
||||
state: RoomDetailsState,
|
||||
|
|
|
|||
|
|
@ -43,9 +43,11 @@ val A_USER_ID_10 = UserId("@walter:server.org")
|
|||
val A_SESSION_ID: SessionId = A_USER_ID
|
||||
val A_SESSION_ID_2: SessionId = A_USER_ID_2
|
||||
val A_SPACE_ID = SpaceId("!aSpaceId:domain")
|
||||
val A_SPACE_ID_2 = SpaceId("!aSpaceId2:domain")
|
||||
val A_ROOM_ID = RoomId("!aRoomId:domain")
|
||||
val A_ROOM_ID_2 = RoomId("!aRoomId2:domain")
|
||||
val A_THREAD_ID = ThreadId("\$aThreadId")
|
||||
val A_THREAD_ID_2 = ThreadId("\$aThreadId2")
|
||||
val AN_EVENT_ID = EventId("\$anEventId")
|
||||
val AN_EVENT_ID_2 = EventId("\$anEventId2")
|
||||
val A_TRANSACTION_ID = TransactionId("aTransactionId")
|
||||
|
|
|
|||
|
|
@ -18,9 +18,14 @@ package io.element.android.services.appnavstate.impl
|
|||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID_2
|
||||
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||
import io.element.android.libraries.matrix.test.A_SESSION_ID_2
|
||||
import io.element.android.libraries.matrix.test.A_SPACE_ID
|
||||
import io.element.android.libraries.matrix.test.A_SPACE_ID_2
|
||||
import io.element.android.libraries.matrix.test.A_THREAD_ID
|
||||
import io.element.android.libraries.matrix.test.A_THREAD_ID_2
|
||||
import io.element.android.services.appnavstate.api.AppNavigationStateService
|
||||
import io.element.android.services.appnavstate.api.NavigationState
|
||||
import io.element.android.services.appnavstate.test.A_ROOM_OWNER
|
||||
import io.element.android.services.appnavstate.test.A_SESSION_OWNER
|
||||
|
|
@ -32,31 +37,48 @@ import kotlinx.coroutines.flow.first
|
|||
import org.junit.Test
|
||||
|
||||
class DefaultNavigationStateServiceTest {
|
||||
private val navigationStateRoot = NavigationState.Root
|
||||
private val navigationStateSession = NavigationState.Session(
|
||||
owner = A_SESSION_OWNER,
|
||||
sessionId = A_SESSION_ID
|
||||
)
|
||||
private val navigationStateSpace = NavigationState.Space(
|
||||
owner = A_SPACE_OWNER,
|
||||
spaceId = A_SPACE_ID,
|
||||
parentSession = navigationStateSession
|
||||
)
|
||||
private val navigationStateRoom = NavigationState.Room(
|
||||
owner = A_ROOM_OWNER,
|
||||
roomId = A_ROOM_ID,
|
||||
parentSpace = navigationStateSpace
|
||||
)
|
||||
private val navigationStateThread = NavigationState.Thread(
|
||||
owner = A_THREAD_OWNER,
|
||||
threadId = A_THREAD_ID,
|
||||
parentRoom = navigationStateRoom
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testNavigation() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
service.onNavigateToSession(A_SESSION_OWNER, A_SESSION_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
service.onNavigateToSpace(A_SPACE_OWNER, A_SPACE_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
service.onNavigateToRoom(A_ROOM_OWNER, A_ROOM_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
service.onNavigateToThread(A_THREAD_OWNER, A_THREAD_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(
|
||||
NavigationState.Thread(
|
||||
A_THREAD_OWNER, A_THREAD_ID,
|
||||
NavigationState.Room(
|
||||
A_ROOM_OWNER,
|
||||
A_ROOM_ID,
|
||||
NavigationState.Space(
|
||||
A_SPACE_OWNER,
|
||||
A_SPACE_ID,
|
||||
NavigationState.Session(
|
||||
A_SESSION_OWNER,
|
||||
A_SESSION_ID
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateThread)
|
||||
// Leaving the states
|
||||
service.onLeavingThread(A_THREAD_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
service.onLeavingRoom(A_ROOM_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
service.onLeavingSpace(A_SPACE_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
service.onLeavingSession(A_SESSION_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -66,6 +88,258 @@ class DefaultNavigationStateServiceTest {
|
|||
assertThat(service.appNavigationState.value.navigationState).isEqualTo(NavigationState.Root)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnNavigateToThread() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root (no effect)
|
||||
service.onNavigateToThread(A_THREAD_OWNER, A_THREAD_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From session (no effect)
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
service.onNavigateToThread(A_THREAD_OWNER, A_THREAD_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From space (no effect)
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
service.onNavigateToThread(A_THREAD_OWNER, A_THREAD_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
// From room
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
service.onNavigateToThread(A_THREAD_OWNER, A_THREAD_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateThread)
|
||||
// From thread
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
// Navigate to another thread
|
||||
service.onNavigateToThread(A_THREAD_OWNER, A_THREAD_ID_2)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateThread.copy(threadId = A_THREAD_ID_2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnNavigateToRoom() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root (no effect)
|
||||
service.onNavigateToRoom(A_ROOM_OWNER, A_ROOM_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From session (no effect)
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
service.onNavigateToRoom(A_ROOM_OWNER, A_ROOM_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From space
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
service.onNavigateToRoom(A_ROOM_OWNER, A_ROOM_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
// From room
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
// Navigate to another room
|
||||
service.onNavigateToRoom(A_ROOM_OWNER, A_ROOM_ID_2)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom.copy(roomId = A_ROOM_ID_2))
|
||||
// From thread
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
service.onNavigateToRoom(A_ROOM_OWNER, A_ROOM_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnNavigateToSpace() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root (no effect)
|
||||
service.onNavigateToSpace(A_SPACE_OWNER, A_SPACE_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From session
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
service.onNavigateToSpace(A_SPACE_OWNER, A_SPACE_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
// From space
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
// Navigate to another space
|
||||
service.onNavigateToSpace(A_SPACE_OWNER, A_SPACE_ID_2)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace.copy(spaceId = A_SPACE_ID_2))
|
||||
// From room (no effect)
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
service.onNavigateToSpace(A_SPACE_OWNER, A_SPACE_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
// From thread (no effect)
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
service.onNavigateToSpace(A_SPACE_OWNER, A_SPACE_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnNavigateToSession() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root
|
||||
service.onNavigateToSession(A_SESSION_OWNER, A_SESSION_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From session
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
// Navigate to another session
|
||||
service.onNavigateToSession(A_SESSION_OWNER, A_SESSION_ID_2)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession.copy(sessionId = A_SESSION_ID_2))
|
||||
// From space
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
service.onNavigateToSession(A_SESSION_OWNER, A_SESSION_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From room
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
service.onNavigateToSession(A_SESSION_OWNER, A_SESSION_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From thread
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
service.onNavigateToSession(A_SESSION_OWNER, A_SESSION_ID)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnLeavingThread() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root (no effect)
|
||||
service.onLeavingThread(A_THREAD_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From session (no effect)
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
service.onLeavingThread(A_THREAD_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From space (no effect)
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
service.onLeavingThread(A_THREAD_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
// From room (no effect)
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
service.onLeavingThread(A_THREAD_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
// From thread
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
service.onLeavingThread(A_THREAD_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnLeavingRoom() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root (no effect)
|
||||
service.onLeavingRoom(A_ROOM_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From session (no effect)
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
service.onLeavingRoom(A_ROOM_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From space (no effect)
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
service.onLeavingRoom(A_ROOM_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
// From room
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
service.onLeavingRoom(A_ROOM_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
// From thread (no effect)
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
service.onLeavingRoom(A_ROOM_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateThread)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnLeavingSpace() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root (no effect)
|
||||
service.onLeavingSpace(A_SPACE_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From session (no effect)
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
service.onLeavingSpace(A_SPACE_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From space
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
service.onLeavingSpace(A_SPACE_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSession)
|
||||
// From room (no effect)
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
service.onLeavingSpace(A_SPACE_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
// From thread (no effect)
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
service.onLeavingSpace(A_SPACE_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateThread)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnLeavingSession() = runCancellableScopeTest { scope ->
|
||||
val service = createStateService(scope)
|
||||
// From root
|
||||
service.onLeavingSession(A_SESSION_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From session
|
||||
service.reset()
|
||||
service.navigateToSession()
|
||||
service.onLeavingSession(A_SESSION_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoot)
|
||||
// From space (no effect)
|
||||
service.reset()
|
||||
service.navigateToSpace()
|
||||
service.onLeavingSession(A_SESSION_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateSpace)
|
||||
// From room (no effect)
|
||||
service.reset()
|
||||
service.navigateToRoom()
|
||||
service.onLeavingSession(A_SESSION_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateRoom)
|
||||
// From thread (no effect)
|
||||
service.reset()
|
||||
service.navigateToThread()
|
||||
service.onLeavingSession(A_SESSION_OWNER)
|
||||
assertThat(service.appNavigationState.first().navigationState).isEqualTo(navigationStateThread)
|
||||
}
|
||||
|
||||
private fun AppNavigationStateService.reset() {
|
||||
navigateToSession()
|
||||
onLeavingSession(A_SESSION_OWNER)
|
||||
}
|
||||
|
||||
private fun AppNavigationStateService.navigateToSession() {
|
||||
onNavigateToSession(A_SESSION_OWNER, A_SESSION_ID)
|
||||
}
|
||||
|
||||
private fun AppNavigationStateService.navigateToSpace() {
|
||||
navigateToSession()
|
||||
onNavigateToSpace(A_SPACE_OWNER, A_SPACE_ID)
|
||||
}
|
||||
|
||||
private fun AppNavigationStateService.navigateToRoom() {
|
||||
navigateToSpace()
|
||||
onNavigateToRoom(A_ROOM_OWNER, A_ROOM_ID)
|
||||
}
|
||||
|
||||
private fun AppNavigationStateService.navigateToThread() {
|
||||
navigateToRoom()
|
||||
onNavigateToThread(A_THREAD_OWNER, A_THREAD_ID)
|
||||
}
|
||||
|
||||
private fun createStateService(
|
||||
coroutineScope: CoroutineScope
|
||||
) = DefaultAppNavigationStateService(FakeAppForegroundStateService(), coroutineScope)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a97571d655893966be7749c851787ec8173b871a912f8e74f6932e54d524e452
|
||||
size 9263
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:99b040639102d5ed77fe2b5dfcf550395668348d711ec8da45e95584b8be9778
|
||||
size 9117
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue