Merge pull request #5343 from element-hq/feature/bma/testEntryPoint
Add test on DefaultSpaceEntryPoint
This commit is contained in:
commit
807b066520
195 changed files with 3010 additions and 1051 deletions
|
|
@ -24,6 +24,7 @@ import extension.koverDependencies
|
||||||
import extension.locales
|
import extension.locales
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
import extension.setupKover
|
import extension.setupKover
|
||||||
|
import extension.testCommonDependencies
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
|
@ -290,15 +291,9 @@ dependencies {
|
||||||
|
|
||||||
implementation(libs.matrix.emojibase.bindings)
|
implementation(libs.matrix.emojibase.bindings)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
|
|
||||||
koverDependencies()
|
koverDependencies()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
import extension.allFeaturesApi
|
import extension.allFeaturesApi
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("io.element.android-compose-library")
|
id("io.element.android-compose-library")
|
||||||
|
|
@ -48,12 +49,7 @@ dependencies {
|
||||||
implementation(projects.services.appnavstate.api)
|
implementation(projects.services.appnavstate.api)
|
||||||
implementation(projects.services.analytics.api)
|
implementation(projects.services.analytics.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.features.login.test)
|
testImplementation(projects.features.login.test)
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.oidc.test)
|
testImplementation(projects.libraries.oidc.test)
|
||||||
|
|
@ -61,11 +57,8 @@ dependencies {
|
||||||
testImplementation(projects.libraries.push.test)
|
testImplementation(projects.libraries.push.test)
|
||||||
testImplementation(projects.libraries.pushproviders.test)
|
testImplementation(projects.libraries.pushproviders.test)
|
||||||
testImplementation(projects.features.networkmonitor.test)
|
testImplementation(projects.features.networkmonitor.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(projects.features.rageshake.test)
|
testImplementation(projects.features.rageshake.test)
|
||||||
testImplementation(projects.services.appnavstate.test)
|
testImplementation(projects.services.appnavstate.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(libs.test.appyx.junit)
|
|
||||||
testImplementation(libs.test.arch.core)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -445,8 +445,7 @@ class LoggedInFlowNode(
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
NavTarget.Ftue -> {
|
NavTarget.Ftue -> {
|
||||||
ftueEntryPoint.nodeBuilder(this, buildContext)
|
ftueEntryPoint.createNode(this, buildContext)
|
||||||
.build()
|
|
||||||
}
|
}
|
||||||
NavTarget.RoomDirectorySearch -> {
|
NavTarget.RoomDirectorySearch -> {
|
||||||
roomDirectoryEntryPoint.nodeBuilder(this, buildContext)
|
roomDirectoryEntryPoint.nodeBuilder(this, buildContext)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,6 @@ package io.element.android.appnav.di
|
||||||
|
|
||||||
import io.element.android.libraries.matrix.api.room.JoinedRoom
|
import io.element.android.libraries.matrix.api.room.JoinedRoom
|
||||||
|
|
||||||
interface RoomComponentFactory {
|
fun interface RoomComponentFactory {
|
||||||
fun create(room: JoinedRoom): Any
|
fun create(room: JoinedRoom): Any
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ package io.element.android.features.analytics.api
|
||||||
|
|
||||||
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
|
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
|
||||||
|
|
||||||
interface AnalyticsEntryPoint : SimpleFeatureEntryPoint
|
fun interface AnalyticsEntryPoint : SimpleFeatureEntryPoint
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
* Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
@ -30,13 +31,7 @@ dependencies {
|
||||||
implementation(libs.androidx.datastore.preferences)
|
implementation(libs.androidx.datastore.preferences)
|
||||||
implementation(libs.androidx.browser)
|
implementation(libs.androidx.browser)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.analytics.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultAnalyticsEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node creation`() {
|
||||||
|
val entryPoint = DefaultAnalyticsEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
AnalyticsOptInNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
AnalyticsOptInPresenter(
|
||||||
|
buildMeta = aBuildMeta(),
|
||||||
|
analyticsService = FakeAnalyticsService()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null))
|
||||||
|
assertThat(result).isInstanceOf(AnalyticsOptInNode::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
* Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
@ -22,8 +23,5 @@ dependencies {
|
||||||
implementation(projects.libraries.core)
|
implementation(projects.libraries.core)
|
||||||
implementation(projects.libraries.architecture)
|
implementation(projects.libraries.architecture)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import extension.buildConfigFieldStr
|
import extension.buildConfigFieldStr
|
||||||
import extension.readLocalProperty
|
import extension.readLocalProperty
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -87,12 +88,7 @@ dependencies {
|
||||||
implementation(libs.element.call.embedded)
|
implementation(libs.element.call.embedded)
|
||||||
api(projects.features.call.api)
|
api(projects.features.call.api)
|
||||||
|
|
||||||
testImplementation(libs.coroutines.test)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(projects.features.call.test)
|
testImplementation(projects.features.call.test)
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testImplementation(projects.libraries.preferences.test)
|
testImplementation(projects.libraries.preferences.test)
|
||||||
|
|
@ -101,7 +97,4 @@ dependencies {
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.services.appnavstate.test)
|
testImplementation(projects.services.appnavstate.test)
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import io.element.android.libraries.architecture.NodeInputs
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.matrix.api.room.JoinedRoom
|
import io.element.android.libraries.matrix.api.room.JoinedRoom
|
||||||
|
|
||||||
interface ChangeRoomMemberRolesEntryPoint : FeatureEntryPoint {
|
fun interface ChangeRoomMemberRolesEntryPoint : FeatureEntryPoint {
|
||||||
fun builder(parentNode: Node, buildContext: BuildContext): Builder
|
fun builder(parentNode: Node, buildContext: BuildContext): Builder
|
||||||
|
|
||||||
interface Builder {
|
interface Builder {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2025 New Vector Ltd.
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
|
@ -37,15 +38,7 @@ dependencies {
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
implementation(projects.services.analytics.api)
|
implementation(projects.services.analytics.api)
|
||||||
|
|
||||||
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(libs.test.junit)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class ChangeRolesNode(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ChangeRoomMemberRolesListType.toRoomMemberRole() = when (this) {
|
internal fun ChangeRoomMemberRolesListType.toRoomMemberRole() = when (this) {
|
||||||
ChangeRoomMemberRolesListType.Admins -> RoomMember.Role.Admin
|
ChangeRoomMemberRolesListType.Admins -> RoomMember.Role.Admin
|
||||||
ChangeRoomMemberRolesListType.Moderators -> RoomMember.Role.Moderator
|
ChangeRoomMemberRolesListType.Moderators -> RoomMember.Role.Moderator
|
||||||
ChangeRoomMemberRolesListType.SelectNewOwnersWhenLeaving -> RoomMember.Role.Owner(isCreator = false)
|
ChangeRoomMemberRolesListType.SelectNewOwnersWhenLeaving -> RoomMember.Role.Owner(isCreator = false)
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class ChangeRolesPresenter(
|
||||||
private val analyticsService: AnalyticsService,
|
private val analyticsService: AnalyticsService,
|
||||||
) : Presenter<ChangeRolesState> {
|
) : Presenter<ChangeRolesState> {
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(role: RoomMember.Role): ChangeRolesPresenter
|
fun create(role: RoomMember.Role): ChangeRolesPresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.changeroommemberroles.impl
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.changeroommemberroes.api.ChangeRoomMemberRolesListType
|
||||||
|
import io.element.android.libraries.matrix.api.room.RoomMember
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class ChangeRolesNodeTest {
|
||||||
|
@Test
|
||||||
|
fun `test toRoomMemberRole`() {
|
||||||
|
assertThat(ChangeRoomMemberRolesListType.Admins.toRoomMemberRole())
|
||||||
|
.isEqualTo(RoomMember.Role.Admin)
|
||||||
|
assertThat(ChangeRoomMemberRolesListType.Moderators.toRoomMemberRole())
|
||||||
|
.isEqualTo(RoomMember.Role.Moderator)
|
||||||
|
assertThat(ChangeRoomMemberRolesListType.SelectNewOwnersWhenLeaving.toRoomMemberRole())
|
||||||
|
.isEqualTo(RoomMember.Role.Owner(false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,7 +37,6 @@ import kotlinx.collections.immutable.toPersistentMap
|
||||||
import kotlinx.coroutines.test.TestScope
|
import kotlinx.coroutines.test.TestScope
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.collections.plus
|
|
||||||
|
|
||||||
class ChangeRolesPresenterTest {
|
class ChangeRolesPresenterTest {
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -556,18 +555,18 @@ class ChangeRolesPresenterTest {
|
||||||
users = pairs.associate { (userId, role) -> userId to role.powerLevel }.toPersistentMap()
|
users = pairs.associate { (userId, role) -> userId to role.powerLevel }.toPersistentMap()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private fun TestScope.createChangeRolesPresenter(
|
|
||||||
role: RoomMember.Role = RoomMember.Role.Admin,
|
internal fun TestScope.createChangeRolesPresenter(
|
||||||
room: FakeJoinedRoom = FakeJoinedRoom(baseRoom = FakeBaseRoom(updateMembersResult = {})),
|
role: RoomMember.Role = RoomMember.Role.Admin,
|
||||||
dispatchers: CoroutineDispatchers = testCoroutineDispatchers(),
|
room: FakeJoinedRoom = FakeJoinedRoom(baseRoom = FakeBaseRoom(updateMembersResult = {})),
|
||||||
analyticsService: FakeAnalyticsService = FakeAnalyticsService(),
|
dispatchers: CoroutineDispatchers = testCoroutineDispatchers(),
|
||||||
): ChangeRolesPresenter {
|
analyticsService: FakeAnalyticsService = FakeAnalyticsService(),
|
||||||
return ChangeRolesPresenter(
|
): ChangeRolesPresenter {
|
||||||
role = role,
|
return ChangeRolesPresenter(
|
||||||
room = room,
|
role = role,
|
||||||
dispatchers = dispatchers,
|
room = room,
|
||||||
analyticsService = analyticsService,
|
dispatchers = dispatchers,
|
||||||
)
|
analyticsService = analyticsService,
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.changeroommemberroles.impl
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.changeroommemberroes.api.ChangeRoomMemberRolesListType
|
||||||
|
import io.element.android.libraries.matrix.test.room.FakeJoinedRoom
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class DefaultChangeRoomMemberRolesEntyPointTest {
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() = runTest {
|
||||||
|
val entryPoint = DefaultChangeRoomMemberRolesEntyPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
ChangeRoomMemberRolesRootNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
roomComponentFactory = { },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val room = FakeJoinedRoom()
|
||||||
|
val listType = ChangeRoomMemberRolesListType.Admins
|
||||||
|
val result = entryPoint.builder(parentNode, BuildContext.root(null))
|
||||||
|
.room(FakeJoinedRoom())
|
||||||
|
.listType(listType)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(ChangeRoomMemberRolesRootNode::class.java)
|
||||||
|
// Search for the Inputs plugin
|
||||||
|
val input = result.plugins.filterIsInstance<ChangeRoomMemberRolesRootNode.Inputs>().single()
|
||||||
|
assertThat(input.joinedRoom.roomId).isEqualTo(room.roomId)
|
||||||
|
assertThat(input.listType).isEqualTo(listType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -43,13 +44,7 @@ dependencies {
|
||||||
implementation(projects.features.invitepeople.api)
|
implementation(projects.features.invitepeople.api)
|
||||||
api(projects.features.createroom.api)
|
api(projects.features.createroom.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.mediapickers.test)
|
testImplementation(projects.libraries.mediapickers.test)
|
||||||
|
|
@ -58,7 +53,4 @@ dependencies {
|
||||||
testImplementation(projects.libraries.usersearch.test)
|
testImplementation(projects.libraries.usersearch.test)
|
||||||
testImplementation(projects.features.startchat.test)
|
testImplementation(projects.features.startchat.test)
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.createroom.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.createroom.api.CreateRoomEntryPoint
|
||||||
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultCreateRoomEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultCreateRoomEntryPoint()
|
||||||
|
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
CreateRoomFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : CreateRoomEntryPoint.Callback {
|
||||||
|
override fun onRoomCreated(roomId: RoomId) = lambdaError()
|
||||||
|
}
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -34,14 +35,6 @@ dependencies {
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
api(projects.features.deactivation.api)
|
api(projects.features.deactivation.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,10 @@ class AccountDeactivationPresenterTest {
|
||||||
assertThat(finalState2.accountDeactivationAction).isEqualTo(AsyncAction.Uninitialized)
|
assertThat(finalState2.accountDeactivationAction).isEqualTo(AsyncAction.Uninitialized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createPresenter(
|
|
||||||
matrixClient: MatrixClient = FakeMatrixClient(),
|
|
||||||
) = AccountDeactivationPresenter(
|
|
||||||
matrixClient = matrixClient,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun createPresenter(
|
||||||
|
matrixClient: MatrixClient = FakeMatrixClient(),
|
||||||
|
) = AccountDeactivationPresenter(
|
||||||
|
matrixClient = matrixClient,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.logout.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultAccountDeactivationEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultAccountDeactivationEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
AccountDeactivationNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenter = createPresenter(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null))
|
||||||
|
assertThat(result).isInstanceOf(AccountDeactivationNode::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -22,8 +23,6 @@ dependencies {
|
||||||
implementation(projects.libraries.architecture)
|
implementation(projects.libraries.architecture)
|
||||||
implementation(projects.libraries.matrix.api)
|
implementation(projects.libraries.matrix.api)
|
||||||
|
|
||||||
testImplementation(libs.coroutines.test)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.test.junit)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,6 @@
|
||||||
|
|
||||||
package io.element.android.features.ftue.api
|
package io.element.android.features.ftue.api
|
||||||
|
|
||||||
import com.bumble.appyx.core.modality.BuildContext
|
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
|
||||||
import com.bumble.appyx.core.node.Node
|
|
||||||
import io.element.android.libraries.architecture.FeatureEntryPoint
|
|
||||||
|
|
||||||
interface FtueEntryPoint : FeatureEntryPoint {
|
interface FtueEntryPoint : SimpleFeatureEntryPoint
|
||||||
fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder
|
|
||||||
|
|
||||||
interface NodeBuilder {
|
|
||||||
fun build(): Node
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
* Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
@ -46,14 +47,7 @@ dependencies {
|
||||||
implementation(projects.services.toolbox.api)
|
implementation(projects.services.toolbox.api)
|
||||||
implementation(projects.appconfig)
|
implementation(projects.appconfig)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.services.analytics.noop)
|
testImplementation(projects.services.analytics.noop)
|
||||||
|
|
@ -61,5 +55,4 @@ dependencies {
|
||||||
testImplementation(projects.libraries.preferences.test)
|
testImplementation(projects.libraries.preferences.test)
|
||||||
testImplementation(projects.features.lockscreen.test)
|
testImplementation(projects.features.lockscreen.test)
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ package io.element.android.features.ftue.impl
|
||||||
|
|
||||||
import com.bumble.appyx.core.modality.BuildContext
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
import com.bumble.appyx.core.node.Node
|
import com.bumble.appyx.core.node.Node
|
||||||
import com.bumble.appyx.core.plugin.Plugin
|
|
||||||
import dev.zacsweers.metro.AppScope
|
import dev.zacsweers.metro.AppScope
|
||||||
import dev.zacsweers.metro.ContributesBinding
|
import dev.zacsweers.metro.ContributesBinding
|
||||||
import dev.zacsweers.metro.Inject
|
import dev.zacsweers.metro.Inject
|
||||||
|
|
@ -19,13 +18,7 @@ import io.element.android.libraries.architecture.createNode
|
||||||
@ContributesBinding(AppScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
@Inject
|
@Inject
|
||||||
class DefaultFtueEntryPoint : FtueEntryPoint {
|
class DefaultFtueEntryPoint : FtueEntryPoint {
|
||||||
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): FtueEntryPoint.NodeBuilder {
|
override fun createNode(parentNode: Node, buildContext: BuildContext): Node {
|
||||||
val plugins = ArrayList<Plugin>()
|
return parentNode.createNode<FtueFlowNode>(buildContext)
|
||||||
|
|
||||||
return object : FtueEntryPoint.NodeBuilder {
|
|
||||||
override fun build(): Node {
|
|
||||||
return parentNode.createNode<FtueFlowNode>(buildContext, plugins)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.ftue.impl
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.lockscreen.api.LockScreenEntryPoint
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultFtueEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() = runTest {
|
||||||
|
val entryPoint = DefaultFtueEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
FtueFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
analyticsEntryPoint = { _, _ -> lambdaError() },
|
||||||
|
ftueState = createDefaultFtueService(),
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
lockScreenEntryPoint = object : LockScreenEntryPoint {
|
||||||
|
override fun nodeBuilder(
|
||||||
|
parentNode: com.bumble.appyx.core.node.Node,
|
||||||
|
buildContext: BuildContext,
|
||||||
|
navTarget: LockScreenEntryPoint.Target
|
||||||
|
): LockScreenEntryPoint.NodeBuilder {
|
||||||
|
lambdaError()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun pinUnlockIntent(context: Context): Intent {
|
||||||
|
lambdaError()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null))
|
||||||
|
assertThat(result).isInstanceOf(FtueFlowNode::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -226,22 +226,22 @@ class DefaultFtueServiceTest {
|
||||||
resetPermissionLambda.assertions().isCalledOnce()
|
resetPermissionLambda.assertions().isCalledOnce()
|
||||||
.with(value("android.permission.POST_NOTIFICATIONS"))
|
.with(value("android.permission.POST_NOTIFICATIONS"))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TestScope.createDefaultFtueService(
|
|
||||||
sessionVerificationService: SessionVerificationService = FakeSessionVerificationService(),
|
|
||||||
analyticsService: AnalyticsService = FakeAnalyticsService(),
|
|
||||||
permissionStateProvider: PermissionStateProvider = FakePermissionStateProvider(permissionGranted = false),
|
|
||||||
lockScreenService: LockScreenService = FakeLockScreenService(),
|
|
||||||
sessionPreferencesStore: SessionPreferencesStore = InMemorySessionPreferencesStore(),
|
|
||||||
// First version where notification permission is required
|
|
||||||
sdkIntVersion: Int = Build.VERSION_CODES.TIRAMISU,
|
|
||||||
) = DefaultFtueService(
|
|
||||||
sessionCoroutineScope = backgroundScope,
|
|
||||||
sessionVerificationService = sessionVerificationService,
|
|
||||||
sdkVersionProvider = FakeBuildVersionSdkIntProvider(sdkIntVersion),
|
|
||||||
analyticsService = analyticsService,
|
|
||||||
permissionStateProvider = permissionStateProvider,
|
|
||||||
lockScreenService = lockScreenService,
|
|
||||||
sessionPreferencesStore = sessionPreferencesStore,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun TestScope.createDefaultFtueService(
|
||||||
|
sessionVerificationService: SessionVerificationService = FakeSessionVerificationService(),
|
||||||
|
analyticsService: AnalyticsService = FakeAnalyticsService(),
|
||||||
|
permissionStateProvider: PermissionStateProvider = FakePermissionStateProvider(permissionGranted = false),
|
||||||
|
lockScreenService: LockScreenService = FakeLockScreenService(),
|
||||||
|
sessionPreferencesStore: SessionPreferencesStore = InMemorySessionPreferencesStore(),
|
||||||
|
// First version where notification permission is required
|
||||||
|
sdkIntVersion: Int = Build.VERSION_CODES.TIRAMISU,
|
||||||
|
) = DefaultFtueService(
|
||||||
|
sessionCoroutineScope = backgroundScope,
|
||||||
|
sessionVerificationService = sessionVerificationService,
|
||||||
|
sdkVersionProvider = FakeBuildVersionSdkIntProvider(sdkIntVersion),
|
||||||
|
analyticsService = analyticsService,
|
||||||
|
permissionStateProvider = permissionStateProvider,
|
||||||
|
lockScreenService = lockScreenService,
|
||||||
|
sessionPreferencesStore = sessionPreferencesStore,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -58,14 +59,7 @@ dependencies {
|
||||||
implementation(projects.libraries.previewutils)
|
implementation(projects.libraries.previewutils)
|
||||||
api(projects.features.home.api)
|
api(projects.features.home.api)
|
||||||
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
testImplementation(libs.test.junit)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.features.invite.test)
|
testImplementation(projects.features.invite.test)
|
||||||
testImplementation(projects.features.logout.test)
|
testImplementation(projects.features.logout.test)
|
||||||
testImplementation(projects.features.networkmonitor.test)
|
testImplementation(projects.features.networkmonitor.test)
|
||||||
|
|
@ -80,5 +74,4 @@ dependencies {
|
||||||
testImplementation(projects.libraries.push.test)
|
testImplementation(projects.libraries.push.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.home.impl
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.home.api.HomeEntryPoint
|
||||||
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class DefaultHomeEntryPointTest {
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultHomeEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
HomeFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
matrixClient = FakeMatrixClient(),
|
||||||
|
presenter = createHomePresenter(),
|
||||||
|
inviteFriendsUseCase = { lambdaError() },
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
acceptDeclineInviteView = { _, _, _, _ -> lambdaError() },
|
||||||
|
directLogoutView = { _ -> lambdaError() },
|
||||||
|
reportRoomEntryPoint = { _, _, _ -> lambdaError() },
|
||||||
|
declineInviteAndBlockUserEntryPoint = { _, _, _ -> lambdaError() },
|
||||||
|
changeRoomMemberRolesEntryPoint = { _, _ -> lambdaError() },
|
||||||
|
leaveRoomRenderer = { _, _, _ -> lambdaError() },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : HomeEntryPoint.Callback {
|
||||||
|
override fun onRoomClick(roomId: RoomId) = lambdaError()
|
||||||
|
override fun onStartChatClick() = lambdaError()
|
||||||
|
override fun onSettingsClick() = lambdaError()
|
||||||
|
override fun onSetUpRecoveryClick() = lambdaError()
|
||||||
|
override fun onSessionConfirmRecoveryKeyClick() = lambdaError()
|
||||||
|
override fun onRoomSettingsClick(roomId: RoomId) = lambdaError()
|
||||||
|
override fun onReportBugClick() = lambdaError()
|
||||||
|
}
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(HomeFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -175,24 +175,24 @@ class HomePresenterTest {
|
||||||
assertThat(finalState.showNavigationBar).isFalse()
|
assertThat(finalState.showNavigationBar).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createHomePresenter(
|
|
||||||
client: MatrixClient = FakeMatrixClient(),
|
|
||||||
syncService: SyncService = FakeSyncService(),
|
|
||||||
snackbarDispatcher: SnackbarDispatcher = SnackbarDispatcher(),
|
|
||||||
rageshakeFeatureAvailability: RageshakeFeatureAvailability = RageshakeFeatureAvailability { flowOf(false) },
|
|
||||||
indicatorService: IndicatorService = FakeIndicatorService(),
|
|
||||||
featureFlagService: FeatureFlagService = FakeFeatureFlagService(),
|
|
||||||
homeSpacesPresenter: Presenter<HomeSpacesState> = Presenter { aHomeSpacesState() },
|
|
||||||
) = HomePresenter(
|
|
||||||
client = client,
|
|
||||||
syncService = syncService,
|
|
||||||
snackbarDispatcher = snackbarDispatcher,
|
|
||||||
indicatorService = indicatorService,
|
|
||||||
logoutPresenter = { aDirectLogoutState() },
|
|
||||||
roomListPresenter = { aRoomListState() },
|
|
||||||
homeSpacesPresenter = homeSpacesPresenter,
|
|
||||||
rageshakeFeatureAvailability = rageshakeFeatureAvailability,
|
|
||||||
featureFlagService = featureFlagService,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun createHomePresenter(
|
||||||
|
client: MatrixClient = FakeMatrixClient(),
|
||||||
|
syncService: SyncService = FakeSyncService(),
|
||||||
|
snackbarDispatcher: SnackbarDispatcher = SnackbarDispatcher(),
|
||||||
|
rageshakeFeatureAvailability: RageshakeFeatureAvailability = RageshakeFeatureAvailability { flowOf(false) },
|
||||||
|
indicatorService: IndicatorService = FakeIndicatorService(),
|
||||||
|
featureFlagService: FeatureFlagService = FakeFeatureFlagService(),
|
||||||
|
homeSpacesPresenter: Presenter<HomeSpacesState> = Presenter { aHomeSpacesState() },
|
||||||
|
) = HomePresenter(
|
||||||
|
client = client,
|
||||||
|
syncService = syncService,
|
||||||
|
snackbarDispatcher = snackbarDispatcher,
|
||||||
|
indicatorService = indicatorService,
|
||||||
|
logoutPresenter = { aDirectLogoutState() },
|
||||||
|
roomListPresenter = { aRoomListState() },
|
||||||
|
homeSpacesPresenter = homeSpacesPresenter,
|
||||||
|
rageshakeFeatureAvailability = rageshakeFeatureAvailability,
|
||||||
|
featureFlagService = featureFlagService,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
|
||||||
interface AcceptDeclineInviteView {
|
fun interface AcceptDeclineInviteView {
|
||||||
@Composable
|
@Composable
|
||||||
fun Render(
|
fun Render(
|
||||||
state: AcceptDeclineInviteState,
|
state: AcceptDeclineInviteState,
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@ import com.bumble.appyx.core.node.Node
|
||||||
import io.element.android.features.invite.api.InviteData
|
import io.element.android.features.invite.api.InviteData
|
||||||
import io.element.android.libraries.architecture.FeatureEntryPoint
|
import io.element.android.libraries.architecture.FeatureEntryPoint
|
||||||
|
|
||||||
interface DeclineInviteAndBlockEntryPoint : FeatureEntryPoint {
|
fun interface DeclineInviteAndBlockEntryPoint : FeatureEntryPoint {
|
||||||
fun createNode(parentNode: Node, buildContext: BuildContext, inviteData: InviteData): Node
|
fun createNode(parentNode: Node, buildContext: BuildContext, inviteData: InviteData): Node
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
* Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
@ -36,17 +37,9 @@ dependencies {
|
||||||
implementation(projects.services.analytics.api)
|
implementation(projects.services.analytics.api)
|
||||||
implementation(projects.libraries.push.api)
|
implementation(projects.libraries.push.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.features.invite.test)
|
testImplementation(projects.features.invite.test)
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.push.test)
|
testImplementation(projects.libraries.push.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class DeclineAndBlockPresenter(
|
||||||
private val snackbarDispatcher: SnackbarDispatcher,
|
private val snackbarDispatcher: SnackbarDispatcher,
|
||||||
) : Presenter<DeclineAndBlockState> {
|
) : Presenter<DeclineAndBlockState> {
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(inviteData: InviteData): DeclineAndBlockPresenter
|
fun create(inviteData: InviteData): DeclineAndBlockPresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.features.invite.api.InviteData
|
import io.element.android.features.invite.api.InviteData
|
||||||
import io.element.android.features.invite.impl.DeclineInvite
|
import io.element.android.features.invite.impl.DeclineInvite
|
||||||
import io.element.android.features.invite.impl.fake.FakeDeclineInvite
|
import io.element.android.features.invite.impl.fake.FakeDeclineInvite
|
||||||
|
import io.element.android.features.invite.test.anInviteData
|
||||||
import io.element.android.libraries.architecture.AsyncAction
|
import io.element.android.libraries.architecture.AsyncAction
|
||||||
import io.element.android.libraries.designsystem.utils.snackbar.SnackbarDispatcher
|
import io.element.android.libraries.designsystem.utils.snackbar.SnackbarDispatcher
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||||
import io.element.android.libraries.matrix.test.A_ROOM_NAME
|
|
||||||
import io.element.android.tests.testutils.WarmUpRule
|
import io.element.android.tests.testutils.WarmUpRule
|
||||||
import io.element.android.tests.testutils.lambda.assert
|
import io.element.android.tests.testutils.lambda.assert
|
||||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||||
|
|
@ -148,28 +148,16 @@ class DeclineAndBlockPresenterTest {
|
||||||
.isCalledOnce()
|
.isCalledOnce()
|
||||||
.with(value(A_ROOM_ID), value(true), value(false), value(""))
|
.with(value(A_ROOM_ID), value(true), value(false), value(""))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private fun anInviteData(
|
|
||||||
roomId: RoomId = A_ROOM_ID,
|
internal fun createDeclineAndBlockPresenter(
|
||||||
name: String = A_ROOM_NAME,
|
inviteData: InviteData = anInviteData(),
|
||||||
isDm: Boolean = false,
|
declineInvite: DeclineInvite = FakeDeclineInvite(),
|
||||||
): InviteData {
|
snackbarDispatcher: SnackbarDispatcher = SnackbarDispatcher(),
|
||||||
return InviteData(
|
): DeclineAndBlockPresenter {
|
||||||
roomId = roomId,
|
return DeclineAndBlockPresenter(
|
||||||
roomName = name,
|
inviteData = inviteData,
|
||||||
isDm = isDm,
|
declineInvite = declineInvite,
|
||||||
)
|
snackbarDispatcher = snackbarDispatcher,
|
||||||
}
|
)
|
||||||
|
|
||||||
private fun createDeclineAndBlockPresenter(
|
|
||||||
inviteData: InviteData = anInviteData(),
|
|
||||||
declineInvite: DeclineInvite = FakeDeclineInvite(),
|
|
||||||
snackbarDispatcher: SnackbarDispatcher = SnackbarDispatcher(),
|
|
||||||
): DeclineAndBlockPresenter {
|
|
||||||
return DeclineAndBlockPresenter(
|
|
||||||
inviteData = inviteData,
|
|
||||||
declineInvite = declineInvite,
|
|
||||||
snackbarDispatcher = snackbarDispatcher,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.invite.impl.declineandblock
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.invite.test.anInviteData
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultDeclineAndBlockEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultDeclineAndBlockEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
DeclineAndBlockNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenterFactory = { inviteData -> createDeclineAndBlockPresenter() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val inviteData = anInviteData()
|
||||||
|
val result = entryPoint.createNode(
|
||||||
|
parentNode = parentNode,
|
||||||
|
buildContext = BuildContext.root(null),
|
||||||
|
inviteData = inviteData
|
||||||
|
)
|
||||||
|
assertThat(result).isInstanceOf(DeclineAndBlockNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(DeclineAndBlockNode.Inputs(inviteData))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -37,17 +38,8 @@ dependencies {
|
||||||
implementation(projects.services.apperror.api)
|
implementation(projects.services.apperror.api)
|
||||||
api(projects.features.invitepeople.api)
|
api(projects.features.invitepeople.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.usersearch.test)
|
testImplementation(projects.libraries.usersearch.test)
|
||||||
testImplementation(projects.services.apperror.test)
|
testImplementation(projects.services.apperror.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -38,16 +39,8 @@ dependencies {
|
||||||
implementation(projects.libraries.preferences.api)
|
implementation(projects.libraries.preferences.api)
|
||||||
implementation(projects.appconfig)
|
implementation(projects.appconfig)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.features.invite.test)
|
testImplementation(projects.features.invite.test)
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testImplementation(projects.libraries.preferences.test)
|
testImplementation(projects.libraries.preferences.test)
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ class JoinRoomPresenter(
|
||||||
private val buildMeta: BuildMeta,
|
private val buildMeta: BuildMeta,
|
||||||
private val seenInvitesStore: SeenInvitesStore,
|
private val seenInvitesStore: SeenInvitesStore,
|
||||||
) : Presenter<JoinRoomState> {
|
) : Presenter<JoinRoomState> {
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(
|
fun create(
|
||||||
roomId: RoomId,
|
roomId: RoomId,
|
||||||
roomIdOrAlias: RoomIdOrAlias,
|
roomIdOrAlias: RoomIdOrAlias,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.joinroom.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.core.node.Node
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import im.vector.app.features.analytics.plan.JoinedRoom
|
||||||
|
import io.element.android.features.invite.api.InviteData
|
||||||
|
import io.element.android.features.invite.api.declineandblock.DeclineInviteAndBlockEntryPoint
|
||||||
|
import io.element.android.features.joinroom.api.JoinRoomEntryPoint
|
||||||
|
import io.element.android.libraries.matrix.api.core.toRoomIdOrAlias
|
||||||
|
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import java.util.Optional
|
||||||
|
|
||||||
|
class DefaultJoinRoomEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultJoinRoomEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
JoinRoomFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenterFactory = { _, _, _, _, _ -> createJoinRoomPresenter() },
|
||||||
|
acceptDeclineInviteView = { _, _, _, _ -> lambdaError() },
|
||||||
|
declineAndBlockEntryPoint = object : DeclineInviteAndBlockEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext, inviteData: InviteData) = lambdaError()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val inputs = JoinRoomEntryPoint.Inputs(
|
||||||
|
roomId = A_ROOM_ID,
|
||||||
|
roomIdOrAlias = A_ROOM_ID.toRoomIdOrAlias(),
|
||||||
|
roomDescription = Optional.ofNullable(null),
|
||||||
|
serverNames = emptyList(),
|
||||||
|
trigger = JoinedRoom.Trigger.RoomDirectory,
|
||||||
|
)
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null), inputs)
|
||||||
|
assertThat(result).isInstanceOf(JoinRoomFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(inputs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1042,39 +1042,6 @@ class JoinRoomPresenterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createJoinRoomPresenter(
|
|
||||||
roomId: RoomId = A_ROOM_ID,
|
|
||||||
roomDescription: Optional<RoomDescription> = Optional.empty(),
|
|
||||||
serverNames: List<String> = emptyList(),
|
|
||||||
trigger: JoinedRoom.Trigger = JoinedRoom.Trigger.Invite,
|
|
||||||
matrixClient: MatrixClient = FakeMatrixClient(),
|
|
||||||
joinRoomLambda: (RoomIdOrAlias, List<String>, JoinedRoom.Trigger) -> Result<Unit> = { _, _, _ ->
|
|
||||||
Result.success(Unit)
|
|
||||||
},
|
|
||||||
knockRoom: KnockRoom = FakeKnockRoom(),
|
|
||||||
cancelKnockRoom: CancelKnockRoom = FakeCancelKnockRoom(),
|
|
||||||
forgetRoom: ForgetRoom = FakeForgetRoom(),
|
|
||||||
buildMeta: BuildMeta = aBuildMeta(applicationName = "AppName"),
|
|
||||||
acceptDeclineInvitePresenter: Presenter<AcceptDeclineInviteState> = Presenter { anAcceptDeclineInviteState() },
|
|
||||||
seenInvitesStore: SeenInvitesStore = InMemorySeenInvitesStore(),
|
|
||||||
): JoinRoomPresenter {
|
|
||||||
return JoinRoomPresenter(
|
|
||||||
roomId = roomId,
|
|
||||||
roomIdOrAlias = roomId.toRoomIdOrAlias(),
|
|
||||||
roomDescription = roomDescription,
|
|
||||||
serverNames = serverNames,
|
|
||||||
trigger = trigger,
|
|
||||||
matrixClient = matrixClient,
|
|
||||||
joinRoom = FakeJoinRoom(joinRoomLambda),
|
|
||||||
knockRoom = knockRoom,
|
|
||||||
cancelKnockRoom = cancelKnockRoom,
|
|
||||||
forgetRoom = forgetRoom,
|
|
||||||
buildMeta = buildMeta,
|
|
||||||
acceptDeclineInvitePresenter = acceptDeclineInvitePresenter,
|
|
||||||
seenInvitesStore = seenInvitesStore,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun aRoomDescription(
|
private fun aRoomDescription(
|
||||||
roomId: RoomId = A_ROOM_ID,
|
roomId: RoomId = A_ROOM_ID,
|
||||||
name: String? = A_ROOM_NAME,
|
name: String? = A_ROOM_NAME,
|
||||||
|
|
@ -1095,3 +1062,36 @@ class JoinRoomPresenterTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun createJoinRoomPresenter(
|
||||||
|
roomId: RoomId = A_ROOM_ID,
|
||||||
|
roomDescription: Optional<RoomDescription> = Optional.empty(),
|
||||||
|
serverNames: List<String> = emptyList(),
|
||||||
|
trigger: JoinedRoom.Trigger = JoinedRoom.Trigger.Invite,
|
||||||
|
matrixClient: MatrixClient = FakeMatrixClient(),
|
||||||
|
joinRoomLambda: (RoomIdOrAlias, List<String>, JoinedRoom.Trigger) -> Result<Unit> = { _, _, _ ->
|
||||||
|
Result.success(Unit)
|
||||||
|
},
|
||||||
|
knockRoom: KnockRoom = FakeKnockRoom(),
|
||||||
|
cancelKnockRoom: CancelKnockRoom = FakeCancelKnockRoom(),
|
||||||
|
forgetRoom: ForgetRoom = FakeForgetRoom(),
|
||||||
|
buildMeta: BuildMeta = aBuildMeta(applicationName = "AppName"),
|
||||||
|
acceptDeclineInvitePresenter: Presenter<AcceptDeclineInviteState> = Presenter { anAcceptDeclineInviteState() },
|
||||||
|
seenInvitesStore: SeenInvitesStore = InMemorySeenInvitesStore(),
|
||||||
|
): JoinRoomPresenter {
|
||||||
|
return JoinRoomPresenter(
|
||||||
|
roomId = roomId,
|
||||||
|
roomIdOrAlias = roomId.toRoomIdOrAlias(),
|
||||||
|
roomDescription = roomDescription,
|
||||||
|
serverNames = serverNames,
|
||||||
|
trigger = trigger,
|
||||||
|
matrixClient = matrixClient,
|
||||||
|
joinRoom = FakeJoinRoom(joinRoomLambda),
|
||||||
|
knockRoom = knockRoom,
|
||||||
|
cancelKnockRoom = cancelKnockRoom,
|
||||||
|
forgetRoom = forgetRoom,
|
||||||
|
buildMeta = buildMeta,
|
||||||
|
acceptDeclineInvitePresenter = acceptDeclineInvitePresenter,
|
||||||
|
seenInvitesStore = seenInvitesStore,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("io.element.android-compose-library")
|
id("io.element.android-compose-library")
|
||||||
|
|
@ -33,15 +34,7 @@ dependencies {
|
||||||
implementation(projects.libraries.designsystem)
|
implementation(projects.libraries.designsystem)
|
||||||
implementation(projects.libraries.featureflag.api)
|
implementation(projects.libraries.featureflag.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.knockrequests.impl.list
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultKnockRequestsListEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() = runTest {
|
||||||
|
val entryPoint = DefaultKnockRequestsListEntryPoint()
|
||||||
|
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
KnockRequestsListNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenter = createKnockRequestsListPresenter(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null))
|
||||||
|
assertThat(result).isInstanceOf(KnockRequestsListNode::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -286,19 +286,19 @@ class KnockRequestsListPresenterTest {
|
||||||
assert(acceptFailureLambda).isCalledOnce()
|
assert(acceptFailureLambda).isCalledOnce()
|
||||||
assert(acceptSuccessLambda).isCalledOnce()
|
assert(acceptSuccessLambda).isCalledOnce()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private fun TestScope.createKnockRequestsListPresenter(
|
|
||||||
canAccept: Boolean = true,
|
internal fun TestScope.createKnockRequestsListPresenter(
|
||||||
canDecline: Boolean = true,
|
canAccept: Boolean = true,
|
||||||
canBan: Boolean = true,
|
canDecline: Boolean = true,
|
||||||
knockRequestsFlow: Flow<List<KnockRequest>> = flowOf(emptyList())
|
canBan: Boolean = true,
|
||||||
): KnockRequestsListPresenter {
|
knockRequestsFlow: Flow<List<KnockRequest>> = flowOf(emptyList())
|
||||||
val knockRequestsService = KnockRequestsService(
|
): KnockRequestsListPresenter {
|
||||||
knockRequestsFlow = knockRequestsFlow,
|
val knockRequestsService = KnockRequestsService(
|
||||||
coroutineScope = backgroundScope,
|
knockRequestsFlow = knockRequestsFlow,
|
||||||
isKnockFeatureEnabledFlow = flowOf(true),
|
coroutineScope = backgroundScope,
|
||||||
permissionsFlow = flowOf(KnockRequestPermissions(canAccept, canDecline, canBan)),
|
isKnockFeatureEnabledFlow = flowOf(true),
|
||||||
)
|
permissionsFlow = flowOf(KnockRequestPermissions(canAccept, canDecline, canBan)),
|
||||||
return KnockRequestsListPresenter(knockRequestsService = knockRequestsService)
|
)
|
||||||
}
|
return KnockRequestsListPresenter(knockRequestsService = knockRequestsService)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
|
||||||
interface LeaveRoomRenderer {
|
fun interface LeaveRoomRenderer {
|
||||||
@Composable
|
@Composable
|
||||||
fun Render(
|
fun Render(
|
||||||
state: LeaveRoomState,
|
state: LeaveRoomState,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -26,13 +27,8 @@ dependencies {
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
implementation(projects.libraries.push.api)
|
implementation(projects.libraries.push.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.coroutines.core)
|
testImplementation(libs.coroutines.core)
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.push.test)
|
testImplementation(projects.libraries.push.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
package io.element.android.features.licenses.api
|
package io.element.android.features.licenses.api
|
||||||
|
|
||||||
import com.bumble.appyx.core.modality.BuildContext
|
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
|
||||||
import com.bumble.appyx.core.node.Node
|
|
||||||
|
|
||||||
interface OpenSourceLicensesEntryPoint {
|
interface OpenSourceLicensesEntryPoint : SimpleFeatureEntryPoint
|
||||||
fun getNode(node: Node, buildContext: BuildContext): Node
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -26,12 +27,8 @@ dependencies {
|
||||||
implementation(projects.libraries.core)
|
implementation(projects.libraries.core)
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
api(projects.features.licenses.api)
|
api(projects.features.licenses.api)
|
||||||
testImplementation(libs.test.junit)
|
|
||||||
testImplementation(libs.coroutines.test)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.coroutines.core)
|
testImplementation(libs.coroutines.core)
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import io.element.android.libraries.architecture.createNode
|
||||||
@ContributesBinding(AppScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
@Inject
|
@Inject
|
||||||
class DefaultOpenSourcesLicensesEntryPoint : OpenSourceLicensesEntryPoint {
|
class DefaultOpenSourcesLicensesEntryPoint : OpenSourceLicensesEntryPoint {
|
||||||
override fun getNode(node: Node, buildContext: BuildContext): Node {
|
override fun createNode(parentNode: Node, buildContext: BuildContext): Node {
|
||||||
return node.createNode<DependenciesFlowNode>(buildContext)
|
return parentNode.createNode<DependenciesFlowNode>(buildContext)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.licenses.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultOpenSourcesLicensesEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultOpenSourcesLicensesEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
DependenciesFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null))
|
||||||
|
assertThat(result).isInstanceOf(DependenciesFlowNode::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
import config.BuildTimeConfig
|
import config.BuildTimeConfig
|
||||||
import extension.buildConfigFieldStr
|
import extension.buildConfigFieldStr
|
||||||
import extension.readLocalProperty
|
import extension.readLocalProperty
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("io.element.android-compose-library")
|
id("io.element.android-compose-library")
|
||||||
|
|
@ -70,6 +71,5 @@ dependencies {
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
implementation(libs.coil.compose)
|
implementation(libs.coil.compose)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -37,17 +38,10 @@ dependencies {
|
||||||
implementation(projects.services.analytics.api)
|
implementation(projects.services.analytics.api)
|
||||||
implementation(libs.accompanist.permission)
|
implementation(libs.accompanist.permission)
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
testImplementation(libs.test.junit)
|
|
||||||
testImplementation(libs.coroutines.test)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.testtags)
|
testImplementation(projects.libraries.testtags)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.features.messages.test)
|
testImplementation(projects.features.messages.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ package io.element.android.features.location.impl.common.permissions
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
|
|
||||||
interface PermissionsPresenter : Presenter<PermissionsState> {
|
interface PermissionsPresenter : Presenter<PermissionsState> {
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(permissions: List<String>): PermissionsPresenter
|
fun create(permissions: List<String>): PermissionsPresenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class SendLocationPresenter(
|
||||||
private val buildMeta: BuildMeta,
|
private val buildMeta: BuildMeta,
|
||||||
) : Presenter<SendLocationState> {
|
) : Presenter<SendLocationState> {
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(timelineMode: Timeline.Mode): SendLocationPresenter
|
fun create(timelineMode: Timeline.Mode): SendLocationPresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ import io.element.android.services.analytics.api.AnalyticsService
|
||||||
@ContributesNode(RoomScope::class)
|
@ContributesNode(RoomScope::class)
|
||||||
@Inject
|
@Inject
|
||||||
class ShowLocationNode(
|
class ShowLocationNode(
|
||||||
presenterFactory: ShowLocationPresenter.Factory,
|
|
||||||
analyticsService: AnalyticsService,
|
|
||||||
@Assisted buildContext: BuildContext,
|
@Assisted buildContext: BuildContext,
|
||||||
@Assisted plugins: List<Plugin>,
|
@Assisted plugins: List<Plugin>,
|
||||||
|
presenterFactory: ShowLocationPresenter.Factory,
|
||||||
|
analyticsService: AnalyticsService,
|
||||||
) : Node(buildContext, plugins = plugins) {
|
) : Node(buildContext, plugins = plugins) {
|
||||||
init {
|
init {
|
||||||
lifecycle.subscribe(
|
lifecycle.subscribe(
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,14 @@ import io.element.android.libraries.core.meta.BuildMeta
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
class ShowLocationPresenter(
|
class ShowLocationPresenter(
|
||||||
|
@Assisted private val location: Location,
|
||||||
|
@Assisted private val description: String?,
|
||||||
permissionsPresenterFactory: PermissionsPresenter.Factory,
|
permissionsPresenterFactory: PermissionsPresenter.Factory,
|
||||||
private val locationActions: LocationActions,
|
private val locationActions: LocationActions,
|
||||||
private val buildMeta: BuildMeta,
|
private val buildMeta: BuildMeta,
|
||||||
@Assisted private val location: Location,
|
|
||||||
@Assisted private val description: String?
|
|
||||||
) : Presenter<ShowLocationState> {
|
) : Presenter<ShowLocationState> {
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(location: Location, description: String?): ShowLocationPresenter
|
fun create(location: Location, description: String?): ShowLocationPresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.location.impl.send
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.location.impl.common.actions.FakeLocationActions
|
||||||
|
import io.element.android.features.location.impl.common.permissions.FakePermissionsPresenter
|
||||||
|
import io.element.android.features.messages.test.FakeMessageComposerContext
|
||||||
|
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||||
|
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||||
|
import io.element.android.libraries.matrix.test.room.FakeJoinedRoom
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultSendLocationEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultSendLocationEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
SendLocationNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenterFactory = { timelineMode: Timeline.Mode ->
|
||||||
|
SendLocationPresenter(
|
||||||
|
permissionsPresenterFactory = { FakePermissionsPresenter() },
|
||||||
|
room = FakeJoinedRoom(),
|
||||||
|
timelineMode = timelineMode,
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
messageComposerContext = FakeMessageComposerContext(),
|
||||||
|
locationActions = FakeLocationActions(),
|
||||||
|
buildMeta = aBuildMeta(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val timelineMode = Timeline.Mode.Live
|
||||||
|
val result = entryPoint.builder(timelineMode)
|
||||||
|
.build(parentNode, BuildContext.root(null))
|
||||||
|
assertThat(result).isInstanceOf(SendLocationNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(SendLocationNode.Inputs(timelineMode))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.location.impl.show
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.location.api.Location
|
||||||
|
import io.element.android.features.location.api.ShowLocationEntryPoint
|
||||||
|
import io.element.android.features.location.impl.common.actions.FakeLocationActions
|
||||||
|
import io.element.android.features.location.impl.common.permissions.FakePermissionsPresenter
|
||||||
|
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultShowLocationEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultShowLocationEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
ShowLocationNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenterFactory = { location: Location, description: String? ->
|
||||||
|
ShowLocationPresenter(
|
||||||
|
permissionsPresenterFactory = { FakePermissionsPresenter() },
|
||||||
|
locationActions = FakeLocationActions(),
|
||||||
|
buildMeta = aBuildMeta(),
|
||||||
|
location = location,
|
||||||
|
description = description,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val inputs = ShowLocationEntryPoint.Inputs(
|
||||||
|
location = Location(37.4219983, -122.084, 10f),
|
||||||
|
description = "My location",
|
||||||
|
)
|
||||||
|
val result = entryPoint.createNode(
|
||||||
|
parentNode,
|
||||||
|
BuildContext.root(null),
|
||||||
|
inputs = inputs,
|
||||||
|
)
|
||||||
|
assertThat(result).isInstanceOf(ShowLocationNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(inputs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,10 +37,10 @@ class ShowLocationPresenterTest {
|
||||||
permissionsPresenterFactory = object : PermissionsPresenter.Factory {
|
permissionsPresenterFactory = object : PermissionsPresenter.Factory {
|
||||||
override fun create(permissions: List<String>): PermissionsPresenter = fakePermissionsPresenter
|
override fun create(permissions: List<String>): PermissionsPresenter = fakePermissionsPresenter
|
||||||
},
|
},
|
||||||
fakeLocationActions,
|
locationActions = fakeLocationActions,
|
||||||
fakeBuildMeta,
|
buildMeta = fakeBuildMeta,
|
||||||
location,
|
location = location,
|
||||||
A_DESCRIPTION,
|
description = A_DESCRIPTION,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ package io.element.android.features.location.test
|
||||||
import io.element.android.features.location.api.LocationService
|
import io.element.android.features.location.api.LocationService
|
||||||
|
|
||||||
class FakeLocationService(
|
class FakeLocationService(
|
||||||
private val isServiceAvailable: Boolean,
|
private val isServiceAvailable: Boolean = false,
|
||||||
) : LocationService {
|
) : LocationService {
|
||||||
override fun isServiceAvailable() = isServiceAvailable
|
override fun isServiceAvailable() = isServiceAvailable
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
* Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
@ -44,21 +45,12 @@ dependencies {
|
||||||
implementation(libs.androidx.datastore.preferences)
|
implementation(libs.androidx.datastore.preferences)
|
||||||
implementation(libs.androidx.biometric)
|
implementation(libs.androidx.biometric)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testImplementation(libs.androidx.test.ext.junit)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(projects.libraries.cryptography.test)
|
testImplementation(projects.libraries.cryptography.test)
|
||||||
testImplementation(projects.libraries.cryptography.impl)
|
testImplementation(projects.libraries.cryptography.impl)
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testImplementation(projects.libraries.sessionStorage.test)
|
testImplementation(projects.libraries.sessionStorage.test)
|
||||||
testImplementation(projects.services.appnavstate.test)
|
testImplementation(projects.services.appnavstate.test)
|
||||||
testImplementation(projects.features.logout.test)
|
testImplementation(projects.features.logout.test)
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.lockscreen.impl
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.lockscreen.impl.unlock.activity.PinUnlockActivity
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class DefaultLockScreenEntryPointIntentTest {
|
||||||
|
@Test
|
||||||
|
fun `test pin unlock intent`() {
|
||||||
|
val entryPoint = DefaultLockScreenEntryPoint()
|
||||||
|
val result = entryPoint.pinUnlockIntent(InstrumentationRegistry.getInstrumentation().context)
|
||||||
|
assertThat(result.component?.className).isEqualTo(PinUnlockActivity::class.qualifiedName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.lockscreen.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.lockscreen.api.LockScreenEntryPoint
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultLockScreenEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder Setup`() {
|
||||||
|
val entryPoint = DefaultLockScreenEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
LockScreenFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : LockScreenEntryPoint.Callback {
|
||||||
|
override fun onSetupDone() = lambdaError()
|
||||||
|
}
|
||||||
|
val navTarget = LockScreenEntryPoint.Target.Setup
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null), navTarget)
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(LockScreenFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(LockScreenFlowNode.Inputs(LockScreenFlowNode.NavTarget.Setup))
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder Settings`() {
|
||||||
|
val entryPoint = DefaultLockScreenEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
LockScreenFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : LockScreenEntryPoint.Callback {
|
||||||
|
override fun onSetupDone() = lambdaError()
|
||||||
|
}
|
||||||
|
val navTarget = LockScreenEntryPoint.Target.Settings
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null), navTarget)
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(LockScreenFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(LockScreenFlowNode.Inputs(LockScreenFlowNode.NavTarget.Settings))
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -48,14 +49,7 @@ dependencies {
|
||||||
implementation(libs.serialization.json)
|
implementation(libs.serialization.json)
|
||||||
api(projects.features.login.api)
|
api(projects.features.login.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testImplementation(libs.androidx.test.ext.junit)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.features.login.test)
|
testImplementation(projects.features.login.test)
|
||||||
testImplementation(projects.features.enterprise.test)
|
testImplementation(projects.features.enterprise.test)
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
|
|
@ -63,6 +57,4 @@ dependencies {
|
||||||
testImplementation(projects.libraries.oidc.test)
|
testImplementation(projects.libraries.oidc.test)
|
||||||
testImplementation(projects.libraries.permissions.test)
|
testImplementation(projects.libraries.permissions.test)
|
||||||
testImplementation(projects.libraries.wellknown.test)
|
testImplementation(projects.libraries.wellknown.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.login.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.enterprise.test.FakeEnterpriseService
|
||||||
|
import io.element.android.features.login.api.LoginEntryPoint
|
||||||
|
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
|
||||||
|
import io.element.android.libraries.oidc.test.customtab.FakeOidcActionFlow
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultLoginEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultLoginEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
LoginFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
accountProviderDataSource = AccountProviderDataSource(FakeEnterpriseService()),
|
||||||
|
oidcActionFlow = FakeOidcActionFlow(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : LoginEntryPoint.Callback {
|
||||||
|
override fun onReportProblem() = lambdaError()
|
||||||
|
}
|
||||||
|
val params = LoginEntryPoint.Params(
|
||||||
|
accountProvider = "ac",
|
||||||
|
loginHint = "lh",
|
||||||
|
)
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.params(params)
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(LoginFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(LoginFlowNode.Params(params.accountProvider, params.loginHint))
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ package io.element.android.features.logout.api.direct
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
interface DirectLogoutView {
|
fun interface DirectLogoutView {
|
||||||
@Composable
|
@Composable
|
||||||
fun Render(state: DirectLogoutState)
|
fun Render(state: DirectLogoutState)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -35,15 +36,7 @@ dependencies {
|
||||||
implementation(projects.libraries.dateformatter.api)
|
implementation(projects.libraries.dateformatter.api)
|
||||||
api(projects.features.logout.api)
|
api(projects.features.logout.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.logout.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.logout.api.LogoutEntryPoint
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultLogoutEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultLogoutEntryPoint()
|
||||||
|
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
LogoutNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenter = createLogoutPresenter(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : LogoutEntryPoint.Callback {
|
||||||
|
override fun onChangeRecoveryKeyClick() = lambdaError()
|
||||||
|
}
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(LogoutNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -225,12 +225,12 @@ class LogoutPresenterTest {
|
||||||
skipItems(2)
|
skipItems(2)
|
||||||
return awaitItem()
|
return awaitItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createLogoutPresenter(
|
|
||||||
matrixClient: MatrixClient = FakeMatrixClient(),
|
|
||||||
encryptionService: EncryptionService = FakeEncryptionService(),
|
|
||||||
): LogoutPresenter = LogoutPresenter(
|
|
||||||
matrixClient = matrixClient,
|
|
||||||
encryptionService = encryptionService,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun createLogoutPresenter(
|
||||||
|
matrixClient: MatrixClient = FakeMatrixClient(),
|
||||||
|
encryptionService: EncryptionService = FakeEncryptionService(),
|
||||||
|
): LogoutPresenter = LogoutPresenter(
|
||||||
|
matrixClient = matrixClient,
|
||||||
|
encryptionService = encryptionService,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -70,11 +71,7 @@ dependencies {
|
||||||
implementation(projects.features.knockrequests.api)
|
implementation(projects.features.knockrequests.api)
|
||||||
implementation(projects.features.roommembermoderation.api)
|
implementation(projects.features.roommembermoderation.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.dateformatter.test)
|
testImplementation(projects.libraries.dateformatter.test)
|
||||||
testImplementation(projects.libraries.push.test)
|
testImplementation(projects.libraries.push.test)
|
||||||
|
|
@ -83,7 +80,6 @@ dependencies {
|
||||||
testImplementation(projects.features.messages.test)
|
testImplementation(projects.features.messages.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testImplementation(projects.libraries.mediaupload.test)
|
testImplementation(projects.libraries.mediaupload.test)
|
||||||
testImplementation(projects.libraries.mediapickers.test)
|
testImplementation(projects.libraries.mediapickers.test)
|
||||||
|
|
@ -93,10 +89,6 @@ dependencies {
|
||||||
testImplementation(projects.libraries.mediaplayer.test)
|
testImplementation(projects.libraries.mediaplayer.test)
|
||||||
testImplementation(projects.libraries.mediaviewer.test)
|
testImplementation(projects.libraries.mediaviewer.test)
|
||||||
testImplementation(projects.libraries.testtags)
|
testImplementation(projects.libraries.testtags)
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.features.poll.test)
|
testImplementation(projects.features.poll.test)
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testImplementation(projects.libraries.eventformatter.test)
|
testImplementation(projects.libraries.eventformatter.test)
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.messages.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.core.node.Node
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.call.api.CallType
|
||||||
|
import io.element.android.features.call.api.ElementCallEntryPoint
|
||||||
|
import io.element.android.features.knockrequests.api.list.KnockRequestsListEntryPoint
|
||||||
|
import io.element.android.features.location.api.SendLocationEntryPoint
|
||||||
|
import io.element.android.features.location.api.ShowLocationEntryPoint
|
||||||
|
import io.element.android.features.location.test.FakeLocationService
|
||||||
|
import io.element.android.features.messages.api.MessagesEntryPoint
|
||||||
|
import io.element.android.features.messages.impl.pinned.banner.createPinnedEventsTimelineProvider
|
||||||
|
import io.element.android.features.messages.impl.timeline.createTimelineController
|
||||||
|
import io.element.android.features.poll.api.create.CreatePollEntryPoint
|
||||||
|
import io.element.android.libraries.dateformatter.test.FakeDateFormatter
|
||||||
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
|
import io.element.android.libraries.matrix.api.permalink.PermalinkData
|
||||||
|
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||||
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
|
import io.element.android.libraries.matrix.test.A_USER_ID
|
||||||
|
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||||
|
import io.element.android.libraries.matrix.test.room.FakeBaseRoom
|
||||||
|
import io.element.android.libraries.matrix.ui.messages.RoomMemberProfilesCache
|
||||||
|
import io.element.android.libraries.matrix.ui.messages.RoomNamesCache
|
||||||
|
import io.element.android.libraries.mediaviewer.api.MediaViewerEntryPoint
|
||||||
|
import io.element.android.libraries.textcomposer.mentions.MentionSpanTheme
|
||||||
|
import io.element.android.libraries.textcomposer.mentions.MentionSpanUpdater
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultMessagesEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() = runTest {
|
||||||
|
val entryPoint = DefaultMessagesEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
MessagesFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
matrixClient = FakeMatrixClient(),
|
||||||
|
sendLocationEntryPoint = object : SendLocationEntryPoint {
|
||||||
|
override fun builder(timelineMode: Timeline.Mode) = lambdaError()
|
||||||
|
},
|
||||||
|
showLocationEntryPoint = object : ShowLocationEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext, inputs: ShowLocationEntryPoint.Inputs) = lambdaError()
|
||||||
|
},
|
||||||
|
createPollEntryPoint = object : CreatePollEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
elementCallEntryPoint = object : ElementCallEntryPoint {
|
||||||
|
override fun startCall(callType: CallType) = lambdaError()
|
||||||
|
override suspend fun handleIncomingCall(
|
||||||
|
callType: CallType.RoomCall,
|
||||||
|
eventId: EventId,
|
||||||
|
senderId: UserId,
|
||||||
|
roomName: String?,
|
||||||
|
senderName: String?,
|
||||||
|
avatarUrl: String?,
|
||||||
|
timestamp: Long,
|
||||||
|
expirationTimestamp: Long,
|
||||||
|
notificationChannelId: String,
|
||||||
|
textContent: String?,
|
||||||
|
) = lambdaError()
|
||||||
|
},
|
||||||
|
mediaViewerEntryPoint = object : MediaViewerEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
locationService = FakeLocationService(),
|
||||||
|
room = FakeBaseRoom(),
|
||||||
|
roomMemberProfilesCache = RoomMemberProfilesCache(),
|
||||||
|
roomNamesCache = RoomNamesCache(),
|
||||||
|
mentionSpanUpdater = object : MentionSpanUpdater {
|
||||||
|
override fun updateMentionSpans(text: CharSequence) = text
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
override fun rememberMentionSpans(text: CharSequence) = text
|
||||||
|
},
|
||||||
|
mentionSpanTheme = MentionSpanTheme(A_USER_ID),
|
||||||
|
pinnedEventsTimelineProvider = createPinnedEventsTimelineProvider(),
|
||||||
|
timelineController = createTimelineController(),
|
||||||
|
knockRequestsListEntryPoint = object : KnockRequestsListEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
dateFormatter = FakeDateFormatter(),
|
||||||
|
coroutineDispatchers = testCoroutineDispatchers(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : MessagesEntryPoint.Callback {
|
||||||
|
override fun onRoomDetailsClick() = lambdaError()
|
||||||
|
override fun onUserDataClick(userId: UserId) = lambdaError()
|
||||||
|
override fun onPermalinkClick(data: PermalinkData, pushToBackstack: Boolean) = lambdaError()
|
||||||
|
override fun onForwardedToSingleRoom(roomId: RoomId) = lambdaError()
|
||||||
|
}
|
||||||
|
val initialTarget = MessagesEntryPoint.InitialTarget.Messages(focusedEventId = AN_EVENT_ID)
|
||||||
|
val params = MessagesEntryPoint.Params(initialTarget)
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.params(params)
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(MessagesFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(MessagesEntryPoint.Params(initialTarget))
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test initial target to nav target mapping`() {
|
||||||
|
assertThat(MessagesEntryPoint.InitialTarget.Messages(focusedEventId = AN_EVENT_ID).toNavTarget())
|
||||||
|
.isEqualTo(MessagesFlowNode.NavTarget.Messages(AN_EVENT_ID))
|
||||||
|
assertThat(MessagesEntryPoint.InitialTarget.PinnedMessages.toNavTarget())
|
||||||
|
.isEqualTo(MessagesFlowNode.NavTarget.PinnedMessagesList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -178,10 +178,9 @@ class PinnedMessagesBannerPresenterTest {
|
||||||
),
|
),
|
||||||
syncService: SyncService = FakeSyncService(),
|
syncService: SyncService = FakeSyncService(),
|
||||||
): PinnedMessagesBannerPresenter {
|
): PinnedMessagesBannerPresenter {
|
||||||
val timelineProvider = PinnedEventsTimelineProvider(
|
val timelineProvider = createPinnedEventsTimelineProvider(
|
||||||
room = room,
|
room = room,
|
||||||
syncService = syncService,
|
syncService = syncService,
|
||||||
dispatchers = testCoroutineDispatchers(),
|
|
||||||
)
|
)
|
||||||
timelineProvider.launchIn(backgroundScope)
|
timelineProvider.launchIn(backgroundScope)
|
||||||
|
|
||||||
|
|
@ -192,3 +191,12 @@ class PinnedMessagesBannerPresenterTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun TestScope.createPinnedEventsTimelineProvider(
|
||||||
|
room: JoinedRoom = FakeJoinedRoom(),
|
||||||
|
syncService: SyncService = FakeSyncService(),
|
||||||
|
) = PinnedEventsTimelineProvider(
|
||||||
|
room = room,
|
||||||
|
syncService = syncService,
|
||||||
|
dispatchers = testCoroutineDispatchers(),
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -217,3 +217,13 @@ class TimelineControllerTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun createTimelineController(
|
||||||
|
room: FakeJoinedRoom = FakeJoinedRoom(liveTimeline = FakeTimeline()),
|
||||||
|
liveTimeline: Timeline = FakeTimeline(name = "live"),
|
||||||
|
): TimelineController {
|
||||||
|
return TimelineController(
|
||||||
|
room = room,
|
||||||
|
liveTimeline = liveTimeline
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -29,15 +30,9 @@ dependencies {
|
||||||
implementation(projects.libraries.sessionStorage.api)
|
implementation(projects.libraries.sessionStorage.api)
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.sessionStorage.test)
|
testImplementation(projects.libraries.sessionStorage.test)
|
||||||
testImplementation(projects.libraries.preferences.test)
|
testImplementation(projects.libraries.preferences.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(projects.features.rageshake.test)
|
testImplementation(projects.features.rageshake.test)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,6 @@
|
||||||
|
|
||||||
package io.element.android.features.poll.api.history
|
package io.element.android.features.poll.api.history
|
||||||
|
|
||||||
import com.bumble.appyx.core.modality.BuildContext
|
import io.element.android.libraries.architecture.SimpleFeatureEntryPoint
|
||||||
import com.bumble.appyx.core.node.Node
|
|
||||||
import io.element.android.libraries.architecture.FeatureEntryPoint
|
|
||||||
|
|
||||||
interface PollHistoryEntryPoint : FeatureEntryPoint {
|
interface PollHistoryEntryPoint : SimpleFeatureEntryPoint
|
||||||
fun createNode(parentNode: Node, buildContext: BuildContext): Node
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
* Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
@ -35,18 +36,10 @@ dependencies {
|
||||||
implementation(projects.libraries.dateformatter.api)
|
implementation(projects.libraries.dateformatter.api)
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.features.messages.test)
|
testImplementation(projects.features.messages.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(projects.libraries.dateformatter.test)
|
testImplementation(projects.libraries.dateformatter.test)
|
||||||
testImplementation(projects.features.poll.test)
|
testImplementation(projects.features.poll.test)
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class CreatePollPresenter(
|
||||||
@Assisted private val timelineMode: Timeline.Mode,
|
@Assisted private val timelineMode: Timeline.Mode,
|
||||||
) : Presenter<CreatePollState> {
|
) : Presenter<CreatePollState> {
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(
|
fun create(
|
||||||
timelineMode: Timeline.Mode,
|
timelineMode: Timeline.Mode,
|
||||||
backNavigator: () -> Unit,
|
backNavigator: () -> Unit,
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class PollRepository(
|
||||||
@Assisted private val timelineMode: Timeline.Mode,
|
@Assisted private val timelineMode: Timeline.Mode,
|
||||||
) {
|
) {
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(
|
fun create(
|
||||||
timelineMode: Timeline.Mode,
|
timelineMode: Timeline.Mode,
|
||||||
): PollRepository
|
): PollRepository
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.poll.impl.create
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.messages.test.FakeMessageComposerContext
|
||||||
|
import io.element.android.features.poll.api.create.CreatePollEntryPoint
|
||||||
|
import io.element.android.features.poll.api.create.CreatePollMode
|
||||||
|
import io.element.android.features.poll.impl.data.PollRepository
|
||||||
|
import io.element.android.libraries.matrix.api.timeline.Timeline
|
||||||
|
import io.element.android.libraries.matrix.test.room.FakeJoinedRoom
|
||||||
|
import io.element.android.libraries.matrix.test.timeline.LiveTimelineProvider
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultCreatePollEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultCreatePollEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
CreatePollNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenterFactory = { timelineMode: Timeline.Mode, backNavigator: () -> Unit, mode: CreatePollMode ->
|
||||||
|
CreatePollPresenter(
|
||||||
|
repositoryFactory = {
|
||||||
|
val room = FakeJoinedRoom()
|
||||||
|
PollRepository(room, LiveTimelineProvider(room), timelineMode)
|
||||||
|
},
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
messageComposerContext = FakeMessageComposerContext(),
|
||||||
|
navigateUp = backNavigator,
|
||||||
|
mode = mode,
|
||||||
|
timelineMode = timelineMode,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val params = CreatePollEntryPoint.Params(
|
||||||
|
timelineMode = Timeline.Mode.Live,
|
||||||
|
mode = CreatePollMode.NewPoll,
|
||||||
|
)
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.params(params)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(CreatePollNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(CreatePollNode.Inputs(timelineMode = params.timelineMode, mode = params.mode))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.poll.impl.history
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.core.node.Node
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.poll.api.create.CreatePollEntryPoint
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultPollHistoryEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() = runTest {
|
||||||
|
val entryPoint = DefaultPollHistoryEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
PollHistoryFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
createPollEntryPoint = object : CreatePollEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null))
|
||||||
|
assertThat(result).isInstanceOf(PollHistoryFlowNode::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -151,23 +151,23 @@ class PollHistoryPresenterTest {
|
||||||
assert(paginateLambda).isCalledExactly(2)
|
assert(paginateLambda).isCalledExactly(2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private fun TestScope.createPollHistoryPresenter(
|
|
||||||
room: FakeJoinedRoom = FakeJoinedRoom(),
|
internal fun TestScope.createPollHistoryPresenter(
|
||||||
endPollAction: EndPollAction = FakeEndPollAction(),
|
room: FakeJoinedRoom = FakeJoinedRoom(),
|
||||||
sendPollResponseAction: SendPollResponseAction = FakeSendPollResponseAction(),
|
endPollAction: EndPollAction = FakeEndPollAction(),
|
||||||
pollHistoryItemFactory: PollHistoryItemsFactory = PollHistoryItemsFactory(
|
sendPollResponseAction: SendPollResponseAction = FakeSendPollResponseAction(),
|
||||||
pollContentStateFactory = DefaultPollContentStateFactory(FakeMatrixClient()),
|
pollHistoryItemFactory: PollHistoryItemsFactory = PollHistoryItemsFactory(
|
||||||
dateFormatter = FakeDateFormatter(),
|
pollContentStateFactory = DefaultPollContentStateFactory(FakeMatrixClient()),
|
||||||
dispatchers = testCoroutineDispatchers(),
|
dateFormatter = FakeDateFormatter(),
|
||||||
),
|
dispatchers = testCoroutineDispatchers(),
|
||||||
): PollHistoryPresenter {
|
),
|
||||||
return PollHistoryPresenter(
|
): PollHistoryPresenter {
|
||||||
sessionCoroutineScope = this,
|
return PollHistoryPresenter(
|
||||||
sendPollResponseAction = sendPollResponseAction,
|
sessionCoroutineScope = this,
|
||||||
endPollAction = endPollAction,
|
sendPollResponseAction = sendPollResponseAction,
|
||||||
pollHistoryItemFactory = pollHistoryItemFactory,
|
endPollAction = endPollAction,
|
||||||
room = room,
|
pollHistoryItemFactory = pollHistoryItemFactory,
|
||||||
)
|
room = room,
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import config.BuildTimeConfig
|
import config.BuildTimeConfig
|
||||||
import extension.buildConfigFieldStr
|
import extension.buildConfigFieldStr
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -91,13 +92,7 @@ dependencies {
|
||||||
implementation(platform(libs.network.okhttp.bom))
|
implementation(platform(libs.network.okhttp.bom))
|
||||||
implementation(libs.network.okhttp)
|
implementation(libs.network.okhttp)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testImplementation(projects.libraries.mediapickers.test)
|
testImplementation(projects.libraries.mediapickers.test)
|
||||||
|
|
@ -114,7 +109,4 @@ dependencies {
|
||||||
testImplementation(projects.libraries.pushproviders.test)
|
testImplementation(projects.libraries.pushproviders.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,7 @@ class PreferencesFlowNode(
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
is NavTarget.OssLicenses -> {
|
is NavTarget.OssLicenses -> {
|
||||||
openSourceLicensesEntryPoint.getNode(this, buildContext)
|
openSourceLicensesEntryPoint.createNode(this, buildContext)
|
||||||
}
|
}
|
||||||
NavTarget.AccountDeactivation -> {
|
NavTarget.AccountDeactivation -> {
|
||||||
accountDeactivationEntryPoint.createNode(this, buildContext)
|
accountDeactivationEntryPoint.createNode(this, buildContext)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.preferences.impl
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.core.node.Node
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.deactivation.api.AccountDeactivationEntryPoint
|
||||||
|
import io.element.android.features.licenses.api.OpenSourceLicensesEntryPoint
|
||||||
|
import io.element.android.features.lockscreen.api.LockScreenEntryPoint
|
||||||
|
import io.element.android.features.logout.api.LogoutEntryPoint
|
||||||
|
import io.element.android.features.preferences.api.PreferencesEntryPoint
|
||||||
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
import io.element.android.libraries.matrix.api.core.SessionId
|
||||||
|
import io.element.android.libraries.troubleshoot.api.NotificationTroubleShootEntryPoint
|
||||||
|
import io.element.android.libraries.troubleshoot.api.PushHistoryEntryPoint
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultPreferencesEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultPreferencesEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
PreferencesFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
lockScreenEntryPoint = object : LockScreenEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext, navTarget: LockScreenEntryPoint.Target) = lambdaError()
|
||||||
|
override fun pinUnlockIntent(context: Context) = lambdaError()
|
||||||
|
},
|
||||||
|
notificationTroubleShootEntryPoint = object : NotificationTroubleShootEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
pushHistoryEntryPoint = object : PushHistoryEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
logoutEntryPoint = object : LogoutEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
openSourceLicensesEntryPoint = object : OpenSourceLicensesEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
accountDeactivationEntryPoint = object : AccountDeactivationEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : PreferencesEntryPoint.Callback {
|
||||||
|
override fun onOpenBugReport() = lambdaError()
|
||||||
|
override fun onSecureBackupClick() = lambdaError()
|
||||||
|
override fun onOpenRoomNotificationSettings(roomId: RoomId) = lambdaError()
|
||||||
|
override fun navigateTo(sessionId: SessionId, roomId: RoomId, eventId: EventId) = lambdaError()
|
||||||
|
}
|
||||||
|
val params = PreferencesEntryPoint.Params(
|
||||||
|
initialElement = PreferencesEntryPoint.InitialTarget.NotificationSettings,
|
||||||
|
)
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.params(params)
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(PreferencesFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(params)
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test initial target to nav target mapping`() {
|
||||||
|
assertThat(PreferencesEntryPoint.InitialTarget.Root.toNavTarget())
|
||||||
|
.isEqualTo(PreferencesFlowNode.NavTarget.Root)
|
||||||
|
assertThat(PreferencesEntryPoint.InitialTarget.NotificationSettings.toNavTarget())
|
||||||
|
.isEqualTo(PreferencesFlowNode.NavTarget.NotificationSettings)
|
||||||
|
assertThat(PreferencesEntryPoint.InitialTarget.NotificationTroubleshoot.toNavTarget())
|
||||||
|
.isEqualTo(PreferencesFlowNode.NavTarget.TroubleshootNotifications)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2022-2024 New Vector Ltd.
|
* Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
@ -45,19 +46,12 @@ dependencies {
|
||||||
implementation(libs.coil)
|
implementation(libs.coil)
|
||||||
implementation(libs.coil.compose)
|
implementation(libs.coil.compose)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs)
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(projects.features.enterprise.test)
|
testImplementation(projects.features.enterprise.test)
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.sessionStorage.test)
|
testImplementation(projects.libraries.sessionStorage.test)
|
||||||
testImplementation(projects.features.rageshake.test)
|
testImplementation(projects.features.rageshake.test)
|
||||||
testImplementation(projects.libraries.preferences.test)
|
testImplementation(projects.libraries.preferences.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(projects.services.toolbox.test)
|
testImplementation(projects.services.toolbox.test)
|
||||||
testImplementation(libs.network.mockwebserver)
|
testImplementation(libs.network.mockwebserver)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,15 +225,15 @@ class BugReportPresenterTest {
|
||||||
assertThat(awaitItem().sending).isEqualTo(AsyncAction.Uninitialized)
|
assertThat(awaitItem().sending).isEqualTo(AsyncAction.Uninitialized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun TestScope.createPresenter(
|
|
||||||
bugReporter: BugReporter = FakeBugReporter(),
|
|
||||||
crashDataStore: CrashDataStore = FakeCrashDataStore(),
|
|
||||||
screenshotHolder: ScreenshotHolder = FakeScreenshotHolder(),
|
|
||||||
) = BugReportPresenter(
|
|
||||||
bugReporter = bugReporter,
|
|
||||||
crashDataStore = crashDataStore,
|
|
||||||
screenshotHolder = screenshotHolder,
|
|
||||||
appCoroutineScope = this,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun TestScope.createPresenter(
|
||||||
|
bugReporter: BugReporter = FakeBugReporter(),
|
||||||
|
crashDataStore: CrashDataStore = FakeCrashDataStore(),
|
||||||
|
screenshotHolder: ScreenshotHolder = FakeScreenshotHolder(),
|
||||||
|
) = BugReportPresenter(
|
||||||
|
bugReporter = bugReporter,
|
||||||
|
crashDataStore = crashDataStore,
|
||||||
|
screenshotHolder = screenshotHolder,
|
||||||
|
appCoroutineScope = this,
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.rageshake.impl.bugreport
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.rageshake.api.bugreport.BugReportEntryPoint
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultBugReportEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() = runTest {
|
||||||
|
val entryPoint = DefaultBugReportEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
BugReportNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenter = createPresenter(),
|
||||||
|
bugReporter = FakeBugReporter(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : BugReportEntryPoint.Callback {
|
||||||
|
override fun onBugReportSent() = lambdaError()
|
||||||
|
override fun onViewLogs(basePath: String) = lambdaError()
|
||||||
|
}
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(BugReportNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,6 @@ import com.bumble.appyx.core.node.Node
|
||||||
import io.element.android.libraries.architecture.FeatureEntryPoint
|
import io.element.android.libraries.architecture.FeatureEntryPoint
|
||||||
import io.element.android.libraries.matrix.api.core.RoomId
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
|
||||||
interface ReportRoomEntryPoint : FeatureEntryPoint {
|
fun interface ReportRoomEntryPoint : FeatureEntryPoint {
|
||||||
fun createNode(parentNode: Node, buildContext: BuildContext, roomId: RoomId): Node
|
fun createNode(parentNode: Node, buildContext: BuildContext, roomId: RoomId): Node
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("io.element.android-compose-library")
|
id("io.element.android-compose-library")
|
||||||
|
|
@ -32,14 +33,6 @@ dependencies {
|
||||||
implementation(projects.libraries.designsystem)
|
implementation(projects.libraries.designsystem)
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class ReportRoomPresenter(
|
||||||
private val reportRoom: ReportRoom,
|
private val reportRoom: ReportRoom,
|
||||||
) : Presenter<ReportRoomState> {
|
) : Presenter<ReportRoomState> {
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(roomId: RoomId): ReportRoomPresenter
|
fun create(roomId: RoomId): ReportRoomPresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.reportroom.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultReportRoomEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultReportRoomEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
ReportRoomNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenterFactory = { roomId ->
|
||||||
|
assertThat(roomId).isEqualTo(A_ROOM_ID)
|
||||||
|
createReportRoomPresenter()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val result = entryPoint.createNode(parentNode, BuildContext.root(null), A_ROOM_ID)
|
||||||
|
assertThat(result).isInstanceOf(ReportRoomNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(ReportRoomNode.Inputs(A_ROOM_ID))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -141,11 +141,11 @@ class ReportRoomPresenterTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fun createReportRoomPresenter(
|
|
||||||
roomId: RoomId = A_ROOM_ID,
|
internal fun createReportRoomPresenter(
|
||||||
reportRoom: ReportRoom = FakeReportRoom()
|
roomId: RoomId = A_ROOM_ID,
|
||||||
): ReportRoomPresenter {
|
reportRoom: ReportRoom = FakeReportRoom()
|
||||||
return ReportRoomPresenter(roomId, reportRoom)
|
): ReportRoomPresenter {
|
||||||
}
|
return ReportRoomPresenter(roomId, reportRoom)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -33,14 +34,6 @@ dependencies {
|
||||||
implementation(projects.libraries.designsystem)
|
implementation(projects.libraries.designsystem)
|
||||||
implementation(projects.libraries.uiStrings)
|
implementation(projects.libraries.uiStrings)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class RoomAliasResolverPresenter(
|
||||||
@Assisted private val roomAlias: RoomAlias,
|
@Assisted private val roomAlias: RoomAlias,
|
||||||
private val matrixClient: MatrixClient,
|
private val matrixClient: MatrixClient,
|
||||||
) : Presenter<RoomAliasResolverState> {
|
) : Presenter<RoomAliasResolverState> {
|
||||||
interface Factory {
|
fun interface Factory {
|
||||||
fun create(
|
fun create(
|
||||||
roomAlias: RoomAlias,
|
roomAlias: RoomAlias,
|
||||||
): RoomAliasResolverPresenter
|
): RoomAliasResolverPresenter
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.roomaliasresolver.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.roomaliasesolver.api.RoomAliasResolverEntryPoint
|
||||||
|
import io.element.android.libraries.matrix.api.room.alias.ResolvedRoomAlias
|
||||||
|
import io.element.android.libraries.matrix.test.A_ROOM_ALIAS
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultRoomAliasResolverEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultRoomAliasResolverEntryPoint()
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
RoomAliasResolverNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
presenterFactory = { alias ->
|
||||||
|
assertThat(alias).isEqualTo(A_ROOM_ALIAS)
|
||||||
|
createPresenter(
|
||||||
|
alias,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : RoomAliasResolverEntryPoint.Callback {
|
||||||
|
override fun onAliasResolved(data: ResolvedRoomAlias) = lambdaError()
|
||||||
|
}
|
||||||
|
val params = RoomAliasResolverEntryPoint.Params(
|
||||||
|
roomAlias = A_ROOM_ALIAS
|
||||||
|
)
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.params(params)
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(RoomAliasResolverNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(params)
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -79,16 +79,16 @@ class RoomAliasHelperPresenterTest {
|
||||||
assertThat(retryState.resolveState.errorOrNull()).isEqualTo(AN_EXCEPTION)
|
assertThat(retryState.resolveState.errorOrNull()).isEqualTo(AN_EXCEPTION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createPresenter(
|
|
||||||
roomAlias: RoomAlias = A_ROOM_ALIAS,
|
|
||||||
matrixClient: MatrixClient = FakeMatrixClient(),
|
|
||||||
) = RoomAliasResolverPresenter(
|
|
||||||
roomAlias = roomAlias,
|
|
||||||
matrixClient = matrixClient,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun createPresenter(
|
||||||
|
roomAlias: RoomAlias = A_ROOM_ALIAS,
|
||||||
|
matrixClient: MatrixClient = FakeMatrixClient(),
|
||||||
|
) = RoomAliasResolverPresenter(
|
||||||
|
roomAlias = roomAlias,
|
||||||
|
matrixClient = matrixClient,
|
||||||
|
)
|
||||||
|
|
||||||
internal fun aResolvedRoomAlias(
|
internal fun aResolvedRoomAlias(
|
||||||
roomId: RoomId = A_ROOM_ID,
|
roomId: RoomId = A_ROOM_ID,
|
||||||
servers: List<String> = A_SERVER_LIST,
|
servers: List<String> = A_SERVER_LIST,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -26,15 +27,8 @@ dependencies {
|
||||||
implementation(projects.libraries.matrix.api)
|
implementation(projects.libraries.matrix.api)
|
||||||
implementation(projects.libraries.matrixui)
|
implementation(projects.libraries.matrixui)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.features.call.test)
|
testImplementation(projects.features.call.test)
|
||||||
testImplementation(projects.features.enterprise.test)
|
testImplementation(projects.features.enterprise.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2023, 2024 New Vector Ltd.
|
* Copyright 2023, 2024 New Vector Ltd.
|
||||||
|
|
@ -58,13 +59,7 @@ dependencies {
|
||||||
implementation(projects.features.changeroommemberroles.api)
|
implementation(projects.features.changeroommemberroles.api)
|
||||||
implementation(projects.features.invitepeople.api)
|
implementation(projects.features.invitepeople.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(libs.test.mockk)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.libraries.mediaupload.test)
|
testImplementation(projects.libraries.mediaupload.test)
|
||||||
testImplementation(projects.libraries.mediapickers.test)
|
testImplementation(projects.libraries.mediapickers.test)
|
||||||
|
|
@ -72,9 +67,6 @@ dependencies {
|
||||||
testImplementation(projects.libraries.preferences.test)
|
testImplementation(projects.libraries.preferences.test)
|
||||||
testImplementation(projects.libraries.usersearch.test)
|
testImplementation(projects.libraries.usersearch.test)
|
||||||
testImplementation(projects.libraries.featureflag.test)
|
testImplementation(projects.libraries.featureflag.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
testImplementation(projects.features.startchat.test)
|
testImplementation(projects.features.startchat.test)
|
||||||
testImplementation(projects.services.analytics.test)
|
testImplementation(projects.services.analytics.test)
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.features.roomdetails.impl
|
||||||
|
|
||||||
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
|
import com.bumble.appyx.core.node.Node
|
||||||
|
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import io.element.android.features.call.api.CallType
|
||||||
|
import io.element.android.features.call.api.ElementCallEntryPoint
|
||||||
|
import io.element.android.features.changeroommemberroes.api.ChangeRoomMemberRolesEntryPoint
|
||||||
|
import io.element.android.features.knockrequests.api.list.KnockRequestsListEntryPoint
|
||||||
|
import io.element.android.features.messages.api.MessagesEntryPoint
|
||||||
|
import io.element.android.features.poll.api.history.PollHistoryEntryPoint
|
||||||
|
import io.element.android.features.reportroom.api.ReportRoomEntryPoint
|
||||||
|
import io.element.android.features.roomdetails.api.RoomDetailsEntryPoint
|
||||||
|
import io.element.android.features.verifysession.api.OutgoingVerificationEntryPoint
|
||||||
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
|
import io.element.android.libraries.matrix.api.core.RoomId
|
||||||
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
|
import io.element.android.libraries.matrix.api.permalink.PermalinkData
|
||||||
|
import io.element.android.libraries.matrix.test.A_USER_ID
|
||||||
|
import io.element.android.libraries.matrix.test.room.FakeJoinedRoom
|
||||||
|
import io.element.android.libraries.mediaviewer.api.MediaGalleryEntryPoint
|
||||||
|
import io.element.android.libraries.mediaviewer.api.MediaViewerEntryPoint
|
||||||
|
import io.element.android.services.analytics.test.FakeAnalyticsService
|
||||||
|
import io.element.android.tests.testutils.lambda.lambdaError
|
||||||
|
import io.element.android.tests.testutils.node.TestParentNode
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class DefaultRoomDetailsEntryPointTest {
|
||||||
|
@get:Rule
|
||||||
|
val instantTaskExecutorRule = InstantTaskExecutorRule()
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val mainDispatcherRule = MainDispatcherRule()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test node builder`() {
|
||||||
|
val entryPoint = DefaultRoomDetailsEntryPoint()
|
||||||
|
|
||||||
|
val parentNode = TestParentNode.create { buildContext, plugins ->
|
||||||
|
RoomDetailsFlowNode(
|
||||||
|
buildContext = buildContext,
|
||||||
|
plugins = plugins,
|
||||||
|
pollHistoryEntryPoint = object : PollHistoryEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
elementCallEntryPoint = object : ElementCallEntryPoint {
|
||||||
|
override fun startCall(callType: CallType) = lambdaError()
|
||||||
|
override suspend fun handleIncomingCall(
|
||||||
|
callType: CallType.RoomCall,
|
||||||
|
eventId: EventId,
|
||||||
|
senderId: UserId,
|
||||||
|
roomName: String?,
|
||||||
|
senderName: String?,
|
||||||
|
avatarUrl: String?,
|
||||||
|
timestamp: Long,
|
||||||
|
expirationTimestamp: Long,
|
||||||
|
notificationChannelId: String,
|
||||||
|
textContent: String?
|
||||||
|
) = lambdaError()
|
||||||
|
},
|
||||||
|
room = FakeJoinedRoom(),
|
||||||
|
analyticsService = FakeAnalyticsService(),
|
||||||
|
messagesEntryPoint = object : MessagesEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
knockRequestsListEntryPoint = object : KnockRequestsListEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
mediaViewerEntryPoint = object : MediaViewerEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
mediaGalleryEntryPoint = object : MediaGalleryEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
outgoingVerificationEntryPoint = object : OutgoingVerificationEntryPoint {
|
||||||
|
override fun nodeBuilder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
reportRoomEntryPoint = object : ReportRoomEntryPoint {
|
||||||
|
override fun createNode(parentNode: Node, buildContext: BuildContext, roomId: RoomId) = lambdaError()
|
||||||
|
},
|
||||||
|
changeRoomMemberRolesEntryPoint = object : ChangeRoomMemberRolesEntryPoint {
|
||||||
|
override fun builder(parentNode: Node, buildContext: BuildContext) = lambdaError()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val callback = object : RoomDetailsEntryPoint.Callback {
|
||||||
|
override fun onOpenGlobalNotificationSettings() = lambdaError()
|
||||||
|
override fun onOpenRoom(roomId: RoomId, serverNames: List<String>) = lambdaError()
|
||||||
|
override fun onPermalinkClick(data: PermalinkData, pushToBackstack: Boolean) = lambdaError()
|
||||||
|
override fun onForwardedToSingleRoom(roomId: RoomId) = lambdaError()
|
||||||
|
}
|
||||||
|
val params = RoomDetailsEntryPoint.Params(
|
||||||
|
initialElement = RoomDetailsEntryPoint.InitialTarget.RoomDetails,
|
||||||
|
)
|
||||||
|
val result = entryPoint.nodeBuilder(parentNode, BuildContext.root(null))
|
||||||
|
.params(params)
|
||||||
|
.callback(callback)
|
||||||
|
.build()
|
||||||
|
assertThat(result).isInstanceOf(RoomDetailsFlowNode::class.java)
|
||||||
|
assertThat(result.plugins).contains(params)
|
||||||
|
assertThat(result.plugins).contains(callback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test initial target to nav target mapping`() {
|
||||||
|
assertThat(RoomDetailsEntryPoint.InitialTarget.RoomDetails.toNavTarget())
|
||||||
|
.isEqualTo(RoomDetailsFlowNode.NavTarget.RoomDetails)
|
||||||
|
assertThat(RoomDetailsEntryPoint.InitialTarget.RoomMemberDetails(A_USER_ID).toNavTarget())
|
||||||
|
.isEqualTo(RoomDetailsFlowNode.NavTarget.RoomMemberDetails(A_USER_ID))
|
||||||
|
assertThat(RoomDetailsEntryPoint.InitialTarget.RoomNotificationSettings.toNavTarget())
|
||||||
|
.isEqualTo(RoomDetailsFlowNode.NavTarget.RoomNotificationSettings(showUserDefinedSettingStyle = true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import extension.setupDependencyInjection
|
import extension.setupDependencyInjection
|
||||||
|
import extension.testCommonDependencies
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2024 New Vector Ltd.
|
* Copyright 2024 New Vector Ltd.
|
||||||
|
|
@ -35,14 +36,6 @@ dependencies {
|
||||||
implementation(projects.libraries.testtags)
|
implementation(projects.libraries.testtags)
|
||||||
implementation(projects.services.analytics.api)
|
implementation(projects.services.analytics.api)
|
||||||
|
|
||||||
testImplementation(libs.test.junit)
|
testCommonDependencies(libs, true)
|
||||||
testImplementation(libs.androidx.compose.ui.test.junit)
|
|
||||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
|
||||||
testImplementation(libs.test.robolectric)
|
|
||||||
testImplementation(libs.coroutines.test)
|
|
||||||
testImplementation(libs.molecule.runtime)
|
|
||||||
testImplementation(libs.test.truth)
|
|
||||||
testImplementation(libs.test.turbine)
|
|
||||||
testImplementation(projects.libraries.matrix.test)
|
testImplementation(projects.libraries.matrix.test)
|
||||||
testImplementation(projects.tests.testutils)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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