Create Fake classes in test modules

This commit is contained in:
Benoit Marty 2025-10-30 18:32:31 +01:00
parent 0303ac502a
commit 187479849d
62 changed files with 798 additions and 327 deletions

View file

@ -9,13 +9,12 @@ package io.element.android.libraries.mediaviewer.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.libraries.matrix.api.core.EventId
import io.element.android.libraries.mediaviewer.api.MediaGalleryEntryPoint
import io.element.android.libraries.mediaviewer.api.MediaViewerEntryPoint
import io.element.android.libraries.mediaviewer.impl.gallery.root.MediaGalleryFlowNode
import io.element.android.libraries.mediaviewer.test.FakeMediaViewerEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
import io.element.android.tests.testutils.node.TestParentNode
import org.junit.Rule
@ -35,15 +34,7 @@ class DefaultMediaGalleryEntryPointTest {
MediaGalleryFlowNode(
buildContext = buildContext,
plugins = plugins,
mediaViewerEntryPoint = object : MediaViewerEntryPoint {
override fun createParamsForAvatar(filename: String, avatarUrl: String) = lambdaError()
context(parentNode: Node)
override fun createNode(
buildContext: BuildContext,
params: MediaViewerEntryPoint.Params,
callback: MediaViewerEntryPoint.Callback,
) = lambdaError()
},
mediaViewerEntryPoint = FakeMediaViewerEntryPoint(),
)
}
val callback = object : MediaGalleryEntryPoint.Callback {

View file

@ -0,0 +1,21 @@
/*
* 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.libraries.mediaviewer.test
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import io.element.android.libraries.mediaviewer.api.MediaGalleryEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
class FakeMediaGalleryEntryPoint : MediaGalleryEntryPoint {
context(parentNode: Node)
override fun createNode(
buildContext: BuildContext,
callback: MediaGalleryEntryPoint.Callback,
): Node = lambdaError()
}

View file

@ -0,0 +1,24 @@
/*
* 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.libraries.mediaviewer.test
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import io.element.android.libraries.mediaviewer.api.MediaViewerEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
class FakeMediaViewerEntryPoint : MediaViewerEntryPoint {
override fun createParamsForAvatar(filename: String, avatarUrl: String) = lambdaError()
context(parentNode: Node)
override fun createNode(
buildContext: BuildContext,
params: MediaViewerEntryPoint.Params,
callback: MediaViewerEntryPoint.Callback,
): Node = lambdaError()
}

View file

@ -0,0 +1,19 @@
/*
* 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.
*/
plugins {
id("io.element.android-library")
}
android {
namespace = "io.element.android.libraries.roomselect.test"
}
dependencies {
implementation(projects.libraries.architecture)
implementation(projects.libraries.roomselect.api)
implementation(projects.tests.testutils)
}

View file

@ -0,0 +1,22 @@
/*
* 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.libraries.roomselect.test
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import io.element.android.libraries.roomselect.api.RoomSelectEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
class FakeRoomSelectEntryPoint : RoomSelectEntryPoint {
context(parentNode: Node)
override fun createNode(
buildContext: BuildContext,
params: RoomSelectEntryPoint.Params,
callback: RoomSelectEntryPoint.Callback,
): Node = lambdaError()
}

View file

@ -13,6 +13,7 @@ android {
}
dependencies {
implementation(projects.libraries.architecture)
implementation(projects.libraries.troubleshoot.api)
implementation(projects.tests.testutils)
implementation(libs.coroutines.test)

View file

@ -0,0 +1,21 @@
/*
* 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.libraries.troubleshoot.test
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import io.element.android.libraries.troubleshoot.api.NotificationTroubleShootEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
class FakeNotificationTroubleShootEntryPoint : NotificationTroubleShootEntryPoint {
context(parentNode: Node)
override fun createNode(
buildContext: BuildContext,
callback: NotificationTroubleShootEntryPoint.Callback,
): Node = lambdaError()
}

View file

@ -0,0 +1,21 @@
/*
* 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.libraries.troubleshoot.test
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import io.element.android.libraries.troubleshoot.api.PushHistoryEntryPoint
import io.element.android.tests.testutils.lambda.lambdaError
class FakePushHistoryEntryPoint : PushHistoryEntryPoint {
context(parentNode: Node)
override fun createNode(
buildContext: BuildContext,
callback: PushHistoryEntryPoint.Callback,
): Node = lambdaError()
}