Repo created
This commit is contained in:
parent
75dc487a7a
commit
39c29d175b
6317 changed files with 388324 additions and 2 deletions
16
feature/notification/testing/build.gradle.kts
Normal file
16
feature/notification/testing/build.gradle.kts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
plugins {
|
||||
id(ThunderbirdPlugins.Library.kmpCompose)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "net.thunderbird.feature.notification.testing"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain.dependencies {
|
||||
implementation(projects.core.outcome)
|
||||
api(projects.feature.notification.api)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.icon
|
||||
|
||||
import net.thunderbird.feature.notification.api.ui.icon.SystemNotificationIcon
|
||||
|
||||
internal actual val EMPTY_SYSTEM_NOTIFICATION_ICON: SystemNotificationIcon = 0
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package net.thunderbird.feature.notification.testing.fake
|
||||
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.unit.dp
|
||||
import net.thunderbird.feature.notification.api.NotificationSeverity
|
||||
import net.thunderbird.feature.notification.api.content.AppNotification
|
||||
import net.thunderbird.feature.notification.api.content.InAppNotification
|
||||
import net.thunderbird.feature.notification.api.ui.action.NotificationAction
|
||||
import net.thunderbird.feature.notification.api.ui.icon.NotificationIcon
|
||||
import net.thunderbird.feature.notification.api.ui.style.InAppNotificationStyle
|
||||
|
||||
data class FakeInAppOnlyNotification(
|
||||
override val title: String = "fake title",
|
||||
override val contentText: String? = "fake content",
|
||||
override val severity: NotificationSeverity = NotificationSeverity.Information,
|
||||
override val icon: NotificationIcon = NotificationIcon(
|
||||
inAppNotificationIcon = ImageVector.Builder(
|
||||
defaultWidth = 0.dp,
|
||||
defaultHeight = 0.dp,
|
||||
viewportWidth = 0f,
|
||||
viewportHeight = 0f,
|
||||
).build(),
|
||||
),
|
||||
override val inAppNotificationStyles: List<InAppNotificationStyle> = listOf(),
|
||||
override val actions: Set<NotificationAction> = setOf(),
|
||||
) : AppNotification(), InAppNotification
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package net.thunderbird.feature.notification.testing.fake
|
||||
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.unit.dp
|
||||
import net.thunderbird.feature.notification.api.NotificationChannel
|
||||
import net.thunderbird.feature.notification.api.NotificationSeverity
|
||||
import net.thunderbird.feature.notification.api.content.AppNotification
|
||||
import net.thunderbird.feature.notification.api.content.InAppNotification
|
||||
import net.thunderbird.feature.notification.api.content.SystemNotification
|
||||
import net.thunderbird.feature.notification.api.ui.icon.NotificationIcon
|
||||
import net.thunderbird.feature.notification.testing.fake.icon.EMPTY_SYSTEM_NOTIFICATION_ICON
|
||||
|
||||
data class FakeNotification(
|
||||
override val title: String = "fake title",
|
||||
override val contentText: String? = "fake content",
|
||||
override val severity: NotificationSeverity = NotificationSeverity.Information,
|
||||
override val icon: NotificationIcon = NotificationIcon(
|
||||
systemNotificationIcon = EMPTY_SYSTEM_NOTIFICATION_ICON,
|
||||
inAppNotificationIcon = ImageVector.Builder(
|
||||
defaultWidth = 0.dp,
|
||||
defaultHeight = 0.dp,
|
||||
viewportWidth = 0f,
|
||||
viewportHeight = 0f,
|
||||
).build(),
|
||||
),
|
||||
override val channel: NotificationChannel = NotificationChannel.Messages(
|
||||
accountUuid = "",
|
||||
suffix = "",
|
||||
),
|
||||
) : AppNotification(), SystemNotification, InAppNotification
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package net.thunderbird.feature.notification.testing.fake
|
||||
|
||||
import kotlin.random.Random
|
||||
import net.thunderbird.feature.notification.api.NotificationId
|
||||
import net.thunderbird.feature.notification.api.NotificationRegistry
|
||||
import net.thunderbird.feature.notification.api.content.Notification
|
||||
|
||||
open class FakeNotificationRegistry : NotificationRegistry {
|
||||
override val registrar: Map<NotificationId, Notification>
|
||||
get() = TODO("Not yet implemented")
|
||||
|
||||
override fun get(notificationId: NotificationId): Notification? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun get(notification: Notification): NotificationId? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun register(notification: Notification): NotificationId {
|
||||
return NotificationId(value = Random.Default.nextInt())
|
||||
}
|
||||
|
||||
override fun unregister(notificationId: NotificationId) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun unregister(notification: Notification) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package net.thunderbird.feature.notification.testing.fake
|
||||
|
||||
import net.thunderbird.feature.notification.api.NotificationChannel
|
||||
import net.thunderbird.feature.notification.api.NotificationSeverity
|
||||
import net.thunderbird.feature.notification.api.content.AppNotification
|
||||
import net.thunderbird.feature.notification.api.content.SystemNotification
|
||||
import net.thunderbird.feature.notification.api.ui.icon.NotificationIcon
|
||||
import net.thunderbird.feature.notification.testing.fake.icon.EMPTY_SYSTEM_NOTIFICATION_ICON
|
||||
|
||||
data class FakeSystemOnlyNotification(
|
||||
override val title: String = "fake title",
|
||||
override val contentText: String? = "fake content",
|
||||
override val severity: NotificationSeverity = NotificationSeverity.Information,
|
||||
override val icon: NotificationIcon = NotificationIcon(
|
||||
systemNotificationIcon = EMPTY_SYSTEM_NOTIFICATION_ICON,
|
||||
),
|
||||
override val channel: NotificationChannel = NotificationChannel.Messages(
|
||||
accountUuid = "",
|
||||
suffix = "",
|
||||
),
|
||||
) : AppNotification(), SystemNotification
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.command
|
||||
|
||||
import net.thunderbird.core.outcome.Outcome
|
||||
import net.thunderbird.feature.notification.api.command.NotificationCommand
|
||||
import net.thunderbird.feature.notification.api.content.InAppNotification
|
||||
import net.thunderbird.feature.notification.api.receiver.NotificationNotifier
|
||||
import net.thunderbird.feature.notification.testing.fake.FakeInAppOnlyNotification
|
||||
import net.thunderbird.feature.notification.testing.fake.receiver.FakeInAppNotificationNotifier
|
||||
|
||||
class FakeInAppNotificationCommand(
|
||||
notification: InAppNotification = FakeInAppOnlyNotification(),
|
||||
notifier: NotificationNotifier<InAppNotification> = FakeInAppNotificationNotifier(),
|
||||
) : NotificationCommand<InAppNotification>(notification, notifier) {
|
||||
override suspend fun execute(): Outcome<Success<InAppNotification>, Failure<InAppNotification>> =
|
||||
error("not implemented")
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.command
|
||||
|
||||
import net.thunderbird.core.outcome.Outcome
|
||||
import net.thunderbird.feature.notification.api.command.NotificationCommand
|
||||
import net.thunderbird.feature.notification.api.content.SystemNotification
|
||||
import net.thunderbird.feature.notification.api.receiver.NotificationNotifier
|
||||
import net.thunderbird.feature.notification.testing.fake.FakeSystemOnlyNotification
|
||||
import net.thunderbird.feature.notification.testing.fake.receiver.FakeSystemNotificationNotifier
|
||||
|
||||
class FakeSystemNotificationCommand(
|
||||
notification: SystemNotification = FakeSystemOnlyNotification(),
|
||||
notifier: NotificationNotifier<SystemNotification> = FakeSystemNotificationNotifier(),
|
||||
) : NotificationCommand<SystemNotification>(notification, notifier) {
|
||||
override suspend fun execute(): Outcome<Success<SystemNotification>, Failure<SystemNotification>> =
|
||||
error("not implemented")
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.icon
|
||||
|
||||
import net.thunderbird.feature.notification.api.ui.icon.SystemNotificationIcon
|
||||
|
||||
internal expect val EMPTY_SYSTEM_NOTIFICATION_ICON: SystemNotificationIcon
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.receiver
|
||||
|
||||
import net.thunderbird.feature.notification.api.NotificationId
|
||||
import net.thunderbird.feature.notification.api.content.InAppNotification
|
||||
import net.thunderbird.feature.notification.api.receiver.NotificationNotifier
|
||||
|
||||
open class FakeInAppNotificationNotifier : NotificationNotifier<InAppNotification> {
|
||||
override suspend fun show(
|
||||
id: NotificationId,
|
||||
notification: InAppNotification,
|
||||
) = Unit
|
||||
|
||||
override fun dispose() = Unit
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.receiver
|
||||
|
||||
import net.thunderbird.feature.notification.api.NotificationId
|
||||
import net.thunderbird.feature.notification.api.content.SystemNotification
|
||||
import net.thunderbird.feature.notification.api.receiver.NotificationNotifier
|
||||
|
||||
class FakeSystemNotificationNotifier : NotificationNotifier<SystemNotification> {
|
||||
override suspend fun show(
|
||||
id: NotificationId,
|
||||
notification: SystemNotification,
|
||||
) = Unit
|
||||
|
||||
override fun dispose() = Unit
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.sender
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import net.thunderbird.core.outcome.Outcome
|
||||
import net.thunderbird.feature.notification.api.command.NotificationCommand.Failure
|
||||
import net.thunderbird.feature.notification.api.command.NotificationCommand.Success
|
||||
import net.thunderbird.feature.notification.api.content.Notification
|
||||
import net.thunderbird.feature.notification.api.sender.NotificationSender
|
||||
|
||||
class FakeNotificationSender(
|
||||
private val results: List<Outcome<Success<Notification>, Failure<Notification>>>,
|
||||
) : NotificationSender {
|
||||
override fun send(notification: Notification): Flow<Outcome<Success<Notification>, Failure<Notification>>> =
|
||||
results.asFlow()
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.ui.action
|
||||
|
||||
import net.thunderbird.feature.notification.api.ui.action.NotificationAction
|
||||
import net.thunderbird.feature.notification.api.ui.icon.NotificationIcon
|
||||
import net.thunderbird.feature.notification.testing.fake.icon.EMPTY_SYSTEM_NOTIFICATION_ICON
|
||||
|
||||
fun createFakeNotificationAction(title: String = "fake action"): NotificationAction.CustomAction =
|
||||
NotificationAction.CustomAction(
|
||||
title = title,
|
||||
icon = NotificationIcon(
|
||||
systemNotificationIcon = EMPTY_SYSTEM_NOTIFICATION_ICON,
|
||||
),
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package net.thunderbird.feature.notification.testing.fake.icon
|
||||
|
||||
import net.thunderbird.feature.notification.api.ui.icon.SystemNotificationIcon
|
||||
|
||||
internal actual val EMPTY_SYSTEM_NOTIFICATION_ICON: SystemNotificationIcon = 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue