Use aNotificationData and aNotifiableMessageEvent
And cleanup existing tests.
This commit is contained in:
parent
9f713e54b1
commit
c4d3fcaa35
8 changed files with 134 additions and 149 deletions
|
|
@ -11,8 +11,10 @@ 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.core.UserId
|
||||||
import io.element.android.libraries.matrix.api.room.RoomMember
|
import io.element.android.libraries.matrix.api.room.RoomMember
|
||||||
import io.element.android.libraries.matrix.api.room.StateEventType
|
import io.element.android.libraries.matrix.api.room.StateEventType
|
||||||
|
import io.element.android.libraries.matrix.test.AN_AVATAR_URL
|
||||||
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.libraries.matrix.test.A_ROOM_NAME
|
||||||
|
import io.element.android.libraries.matrix.test.A_ROOM_TOPIC
|
||||||
import io.element.android.libraries.matrix.test.notificationsettings.FakeNotificationSettingsService
|
import io.element.android.libraries.matrix.test.notificationsettings.FakeNotificationSettingsService
|
||||||
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
||||||
import io.element.android.libraries.matrix.test.room.aRoomInfo
|
import io.element.android.libraries.matrix.test.room.aRoomInfo
|
||||||
|
|
@ -22,8 +24,8 @@ fun aMatrixRoom(
|
||||||
roomId: RoomId = A_ROOM_ID,
|
roomId: RoomId = A_ROOM_ID,
|
||||||
displayName: String = A_ROOM_NAME,
|
displayName: String = A_ROOM_NAME,
|
||||||
rawName: String? = displayName,
|
rawName: String? = displayName,
|
||||||
topic: String? = "A topic",
|
topic: String? = A_ROOM_TOPIC,
|
||||||
avatarUrl: String? = "https://matrix.org/avatar.jpg",
|
avatarUrl: String? = AN_AVATAR_URL,
|
||||||
isEncrypted: Boolean = true,
|
isEncrypted: Boolean = true,
|
||||||
isPublic: Boolean = true,
|
isPublic: Boolean = true,
|
||||||
isDirect: Boolean = false,
|
isDirect: Boolean = false,
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,10 @@ import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||||
import io.element.android.libraries.matrix.api.room.MatrixRoomMembersState
|
import io.element.android.libraries.matrix.api.room.MatrixRoomMembersState
|
||||||
import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
||||||
import io.element.android.libraries.matrix.api.room.StateEventType
|
import io.element.android.libraries.matrix.api.room.StateEventType
|
||||||
|
import io.element.android.libraries.matrix.test.AN_AVATAR_URL
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
|
import io.element.android.libraries.matrix.test.A_ROOM_NAME
|
||||||
|
import io.element.android.libraries.matrix.test.A_ROOM_TOPIC
|
||||||
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||||
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
||||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||||
|
|
@ -129,7 +132,12 @@ class RoomDetailsPresenterTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - initial state is updated with roomInfo if it exists`() = runTest {
|
fun `present - initial state is updated with roomInfo if it exists`() = runTest {
|
||||||
val roomInfo = aRoomInfo(name = "A room name", topic = "A topic", avatarUrl = "https://matrix.org/avatar.jpg", pinnedEventIds = listOf(AN_EVENT_ID))
|
val roomInfo = aRoomInfo(
|
||||||
|
name = A_ROOM_NAME,
|
||||||
|
topic = A_ROOM_TOPIC,
|
||||||
|
avatarUrl = AN_AVATAR_URL,
|
||||||
|
pinnedEventIds = listOf(AN_EVENT_ID),
|
||||||
|
)
|
||||||
val room = aMatrixRoom(
|
val room = aMatrixRoom(
|
||||||
canInviteResult = { Result.success(true) },
|
canInviteResult = { Result.success(true) },
|
||||||
canUserJoinCallResult = { Result.success(true) },
|
canUserJoinCallResult = { Result.success(true) },
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
||||||
import io.element.android.libraries.matrix.api.room.RoomNotificationSettings
|
import io.element.android.libraries.matrix.api.room.RoomNotificationSettings
|
||||||
|
|
||||||
const val A_USER_NAME = "alice"
|
const val A_USER_NAME = "alice"
|
||||||
|
const val A_USER_NAME_2 = "Bob"
|
||||||
const val A_PASSWORD = "password"
|
const val A_PASSWORD = "password"
|
||||||
const val A_PASSPHRASE = "passphrase"
|
const val A_PASSPHRASE = "passphrase"
|
||||||
const val A_SECRET = "secret"
|
const val A_SECRET = "secret"
|
||||||
|
|
@ -55,6 +56,7 @@ val A_UNIQUE_ID = UniqueId("aUniqueId")
|
||||||
val A_UNIQUE_ID_2 = UniqueId("aUniqueId2")
|
val A_UNIQUE_ID_2 = UniqueId("aUniqueId2")
|
||||||
|
|
||||||
const val A_ROOM_NAME = "A room name"
|
const val A_ROOM_NAME = "A room name"
|
||||||
|
const val A_ROOM_TOPIC = "A room topic"
|
||||||
const val A_ROOM_RAW_NAME = "A room raw name"
|
const val A_ROOM_RAW_NAME = "A room raw name"
|
||||||
const val A_MESSAGE = "Hello world!"
|
const val A_MESSAGE = "Hello world!"
|
||||||
const val A_REPLY = "OK, I'll be there!"
|
const val A_REPLY = "OK, I'll be there!"
|
||||||
|
|
@ -80,3 +82,5 @@ val AN_EXCEPTION = Exception(A_FAILURE_REASON)
|
||||||
const val A_RECOVERY_KEY = "1234 5678"
|
const val A_RECOVERY_KEY = "1234 5678"
|
||||||
|
|
||||||
val A_SERVER_LIST = listOf("server1", "server2")
|
val A_SERVER_LIST = listOf("server1", "server2")
|
||||||
|
|
||||||
|
const val A_TIMESTAMP = 567L
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,18 @@ import io.element.android.libraries.matrix.api.notification.NotificationContent
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationData
|
import io.element.android.libraries.matrix.api.notification.NotificationData
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
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.libraries.matrix.test.A_TIMESTAMP
|
||||||
|
import io.element.android.libraries.matrix.test.A_USER_NAME_2
|
||||||
|
|
||||||
fun aNotificationData(
|
fun aNotificationData(
|
||||||
senderDisplayName: String?,
|
content: NotificationContent = NotificationContent.MessageLike.RoomEncrypted,
|
||||||
senderIsNameAmbiguous: Boolean,
|
isDirect: Boolean = false,
|
||||||
|
hasMention: Boolean = false,
|
||||||
|
timestamp: Long = A_TIMESTAMP,
|
||||||
|
senderDisplayName: String? = A_USER_NAME_2,
|
||||||
|
senderIsNameAmbiguous: Boolean = false,
|
||||||
|
roomDisplayName: String? = A_ROOM_NAME
|
||||||
): NotificationData {
|
): NotificationData {
|
||||||
return NotificationData(
|
return NotificationData(
|
||||||
eventId = AN_EVENT_ID,
|
eventId = AN_EVENT_ID,
|
||||||
|
|
@ -23,13 +31,13 @@ fun aNotificationData(
|
||||||
senderDisplayName = senderDisplayName,
|
senderDisplayName = senderDisplayName,
|
||||||
senderIsNameAmbiguous = senderIsNameAmbiguous,
|
senderIsNameAmbiguous = senderIsNameAmbiguous,
|
||||||
roomAvatarUrl = null,
|
roomAvatarUrl = null,
|
||||||
roomDisplayName = null,
|
roomDisplayName = roomDisplayName,
|
||||||
isDirect = false,
|
isDirect = isDirect,
|
||||||
isDm = false,
|
isDm = false,
|
||||||
isEncrypted = false,
|
isEncrypted = false,
|
||||||
isNoisy = false,
|
isNoisy = false,
|
||||||
timestamp = 0L,
|
timestamp = timestamp,
|
||||||
content = NotificationContent.MessageLike.RoomEncrypted,
|
content = content,
|
||||||
hasMention = false,
|
hasMention = hasMention,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ package io.element.android.libraries.push.impl.notifications
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
|
||||||
import io.element.android.libraries.matrix.api.media.MediaSource
|
import io.element.android.libraries.matrix.api.media.MediaSource
|
||||||
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
||||||
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
import io.element.android.libraries.matrix.api.notification.NotificationContent
|
||||||
|
|
@ -33,13 +32,18 @@ import io.element.android.libraries.matrix.test.AN_EVENT_ID_2
|
||||||
import io.element.android.libraries.matrix.test.AN_EXCEPTION
|
import io.element.android.libraries.matrix.test.AN_EXCEPTION
|
||||||
import io.element.android.libraries.matrix.test.A_REDACTION_REASON
|
import io.element.android.libraries.matrix.test.A_REDACTION_REASON
|
||||||
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.libraries.matrix.test.A_SESSION_ID
|
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||||
|
import io.element.android.libraries.matrix.test.A_TIMESTAMP
|
||||||
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
||||||
|
import io.element.android.libraries.matrix.test.A_USER_NAME_2
|
||||||
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
import io.element.android.libraries.matrix.test.FakeMatrixClient
|
||||||
import io.element.android.libraries.matrix.test.FakeMatrixClientProvider
|
import io.element.android.libraries.matrix.test.FakeMatrixClientProvider
|
||||||
import io.element.android.libraries.matrix.test.notification.FakeNotificationService
|
import io.element.android.libraries.matrix.test.notification.FakeNotificationService
|
||||||
|
import io.element.android.libraries.matrix.test.notification.aNotificationData
|
||||||
import io.element.android.libraries.matrix.test.permalink.FakePermalinkParser
|
import io.element.android.libraries.matrix.test.permalink.FakePermalinkParser
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationMediaRepo
|
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationMediaRepo
|
||||||
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.FallbackNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
||||||
|
|
@ -88,17 +92,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message text`() = runTest {
|
fun `resolve event message text`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = TextMessageType(body = "Hello world", formatted = null)
|
messageType = TextMessageType(body = "Hello world", formatted = null)
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Hello world")
|
aNotifiableMessageEvent(body = "Hello world")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +112,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message with mention`() = runTest {
|
fun `resolve event message with mention`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = TextMessageType(body = "Hello world", formatted = null)
|
messageType = TextMessageType(body = "Hello world", formatted = null)
|
||||||
|
|
@ -119,7 +123,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Hello world", hasMentionOrReply = true)
|
aNotifiableMessageEvent(body = "Hello world", hasMentionOrReply = true)
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +132,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve HTML formatted event message text takes plain text version`() = runTest {
|
fun `resolve HTML formatted event message text takes plain text version`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = TextMessageType(
|
messageType = TextMessageType(
|
||||||
|
|
@ -138,13 +142,13 @@ class DefaultNotifiableEventResolverTest {
|
||||||
format = MessageFormat.HTML,
|
format = MessageFormat.HTML,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Hello world")
|
aNotifiableMessageEvent(body = "Hello world")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +157,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve incorrectly formatted event message text uses fallback`() = runTest {
|
fun `resolve incorrectly formatted event message text uses fallback`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = TextMessageType(
|
messageType = TextMessageType(
|
||||||
|
|
@ -163,13 +167,13 @@ class DefaultNotifiableEventResolverTest {
|
||||||
format = MessageFormat.UNKNOWN,
|
format = MessageFormat.UNKNOWN,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Hello world")
|
aNotifiableMessageEvent(body = "Hello world")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -178,17 +182,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message audio`() = runTest {
|
fun `resolve event message audio`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = AudioMessageType(body = "Audio", MediaSource("url"), null)
|
messageType = AudioMessageType(body = "Audio", MediaSource("url"), null)
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Audio")
|
aNotifiableMessageEvent(body = "Audio")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -197,17 +201,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message video`() = runTest {
|
fun `resolve event message video`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = VideoMessageType(body = "Video", null, null, MediaSource("url"), null)
|
messageType = VideoMessageType(body = "Video", null, null, MediaSource("url"), null)
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Video")
|
aNotifiableMessageEvent(body = "Video")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -216,17 +220,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message voice`() = runTest {
|
fun `resolve event message voice`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = VoiceMessageType(body = "Voice", MediaSource("url"), null, null)
|
messageType = VoiceMessageType(body = "Voice", MediaSource("url"), null, null)
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Voice message")
|
aNotifiableMessageEvent(body = "Voice message")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -235,17 +239,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message image`() = runTest {
|
fun `resolve event message image`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = ImageMessageType("Image", null, null, MediaSource("url"), null),
|
messageType = ImageMessageType("Image", null, null, MediaSource("url"), null),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Image")
|
aNotifiableMessageEvent(body = "Image")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -254,17 +258,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message sticker`() = runTest {
|
fun `resolve event message sticker`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = StickerMessageType("Sticker", MediaSource("url"), null),
|
messageType = StickerMessageType("Sticker", MediaSource("url"), null),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Sticker")
|
aNotifiableMessageEvent(body = "Sticker")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -273,17 +277,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message file`() = runTest {
|
fun `resolve event message file`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = FileMessageType("File", MediaSource("url"), null),
|
messageType = FileMessageType("File", MediaSource("url"), null),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "File")
|
aNotifiableMessageEvent(body = "File")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -292,17 +296,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message location`() = runTest {
|
fun `resolve event message location`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = LocationMessageType("Location", "geo:1,2", null),
|
messageType = LocationMessageType("Location", "geo:1,2", null),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Location")
|
aNotifiableMessageEvent(body = "Location")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -311,17 +315,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message notice`() = runTest {
|
fun `resolve event message notice`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = NoticeMessageType("Notice", null),
|
messageType = NoticeMessageType("Notice", null),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Notice")
|
aNotifiableMessageEvent(body = "Notice")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -330,17 +334,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve event message emote`() = runTest {
|
fun `resolve event message emote`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomMessage(
|
content = NotificationContent.MessageLike.RoomMessage(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
messageType = EmoteMessageType("is happy", null),
|
messageType = EmoteMessageType("is happy", null),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "* Bob is happy")
|
aNotifiableMessageEvent(body = "* Bob is happy")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -349,17 +353,17 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve poll`() = runTest {
|
fun `resolve poll`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.Poll(
|
content = NotificationContent.MessageLike.Poll(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
question = "A question"
|
question = "A question"
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
val result = sut.resolveEvent(A_SESSION_ID, A_ROOM_ID, AN_EVENT_ID)
|
||||||
val expectedResult = ResolvedPushEvent.Event(
|
val expectedResult = ResolvedPushEvent.Event(
|
||||||
createNotifiableMessageEvent(body = "Poll: A question")
|
aNotifiableMessageEvent(body = "Poll: A question")
|
||||||
)
|
)
|
||||||
assertThat(result).isEqualTo(expectedResult)
|
assertThat(result).isEqualTo(expectedResult)
|
||||||
}
|
}
|
||||||
|
|
@ -368,7 +372,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve RoomMemberContent invite room`() = runTest {
|
fun `resolve RoomMemberContent invite room`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.StateEvent.RoomMemberContent(
|
content = NotificationContent.StateEvent.RoomMemberContent(
|
||||||
userId = A_USER_ID_2,
|
userId = A_USER_ID_2,
|
||||||
membershipState = RoomMembershipState.INVITE
|
membershipState = RoomMembershipState.INVITE
|
||||||
|
|
@ -385,7 +389,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve invite room`() = runTest {
|
fun `resolve invite room`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.Invite(
|
content = NotificationContent.Invite(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
),
|
),
|
||||||
|
|
@ -401,7 +405,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
eventId = AN_EVENT_ID,
|
eventId = AN_EVENT_ID,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
canBeReplaced = true,
|
canBeReplaced = true,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
noisy = false,
|
noisy = false,
|
||||||
title = null,
|
title = null,
|
||||||
description = "Bob invited you to join the room",
|
description = "Bob invited you to join the room",
|
||||||
|
|
@ -419,7 +423,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve invite direct`() = runTest {
|
fun `resolve invite direct`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.Invite(
|
content = NotificationContent.Invite(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
),
|
),
|
||||||
|
|
@ -435,7 +439,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
eventId = AN_EVENT_ID,
|
eventId = AN_EVENT_ID,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
canBeReplaced = true,
|
canBeReplaced = true,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
noisy = false,
|
noisy = false,
|
||||||
title = null,
|
title = null,
|
||||||
description = "Bob invited you to chat",
|
description = "Bob invited you to chat",
|
||||||
|
|
@ -453,7 +457,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve invite direct, no display name`() = runTest {
|
fun `resolve invite direct, no display name`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.Invite(
|
content = NotificationContent.Invite(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
),
|
),
|
||||||
|
|
@ -470,7 +474,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
eventId = AN_EVENT_ID,
|
eventId = AN_EVENT_ID,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
canBeReplaced = true,
|
canBeReplaced = true,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
noisy = false,
|
noisy = false,
|
||||||
title = null,
|
title = null,
|
||||||
description = "@bob:server.org invited you to chat",
|
description = "@bob:server.org invited you to chat",
|
||||||
|
|
@ -488,7 +492,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve invite direct, ambiguous display name`() = runTest {
|
fun `resolve invite direct, ambiguous display name`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.Invite(
|
content = NotificationContent.Invite(
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
),
|
),
|
||||||
|
|
@ -505,7 +509,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
eventId = AN_EVENT_ID,
|
eventId = AN_EVENT_ID,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
canBeReplaced = true,
|
canBeReplaced = true,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
noisy = false,
|
noisy = false,
|
||||||
title = null,
|
title = null,
|
||||||
description = "Bob (@bob:server.org) invited you to join the room",
|
description = "Bob (@bob:server.org) invited you to join the room",
|
||||||
|
|
@ -523,7 +527,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve RoomMemberContent other`() = runTest {
|
fun `resolve RoomMemberContent other`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.StateEvent.RoomMemberContent(
|
content = NotificationContent.StateEvent.RoomMemberContent(
|
||||||
userId = A_USER_ID_2,
|
userId = A_USER_ID_2,
|
||||||
membershipState = RoomMembershipState.JOIN
|
membershipState = RoomMembershipState.JOIN
|
||||||
|
|
@ -539,7 +543,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve RoomEncrypted`() = runTest {
|
fun `resolve RoomEncrypted`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomEncrypted
|
content = NotificationContent.MessageLike.RoomEncrypted
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -565,8 +569,8 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve CallInvite`() = runTest {
|
fun `resolve CallInvite`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallInvite(A_USER_ID_2)
|
content = NotificationContent.MessageLike.CallInvite(A_USER_ID_2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -581,11 +585,11 @@ class DefaultNotifiableEventResolverTest {
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
noisy = false,
|
noisy = false,
|
||||||
timestamp = A_TIMESTAMP,
|
timestamp = A_TIMESTAMP,
|
||||||
senderDisambiguatedDisplayName = "Bob",
|
senderDisambiguatedDisplayName = A_USER_NAME_2,
|
||||||
body = "Call in progress (unsupported)",
|
body = "Call in progress (unsupported)",
|
||||||
imageUriString = null,
|
imageUriString = null,
|
||||||
threadId = null,
|
threadId = null,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
roomAvatarPath = null,
|
roomAvatarPath = null,
|
||||||
senderAvatarPath = null,
|
senderAvatarPath = null,
|
||||||
soundName = null,
|
soundName = null,
|
||||||
|
|
@ -603,7 +607,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
val timestamp = DefaultSystemClock().epochMillis()
|
val timestamp = DefaultSystemClock().epochMillis()
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallNotify(
|
content = NotificationContent.MessageLike.CallNotify(
|
||||||
A_USER_ID_2,
|
A_USER_ID_2,
|
||||||
CallNotifyType.RING
|
CallNotifyType.RING
|
||||||
|
|
@ -618,14 +622,14 @@ class DefaultNotifiableEventResolverTest {
|
||||||
roomId = A_ROOM_ID,
|
roomId = A_ROOM_ID,
|
||||||
eventId = AN_EVENT_ID,
|
eventId = AN_EVENT_ID,
|
||||||
senderId = A_USER_ID_2,
|
senderId = A_USER_ID_2,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
description = "Incoming call",
|
description = "Incoming call",
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
canBeReplaced = true,
|
canBeReplaced = true,
|
||||||
isRedacted = false,
|
isRedacted = false,
|
||||||
isUpdated = false,
|
isUpdated = false,
|
||||||
senderDisambiguatedDisplayName = "Bob",
|
senderDisambiguatedDisplayName = A_USER_NAME_2,
|
||||||
senderAvatarUrl = null,
|
senderAvatarUrl = null,
|
||||||
callNotifyType = CallNotifyType.RING,
|
callNotifyType = CallNotifyType.RING,
|
||||||
)
|
)
|
||||||
|
|
@ -638,7 +642,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve CallNotify - ring but timed out displays the same as notify`() = runTest {
|
fun `resolve CallNotify - ring but timed out displays the same as notify`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallNotify(
|
content = NotificationContent.MessageLike.CallNotify(
|
||||||
A_USER_ID_2,
|
A_USER_ID_2,
|
||||||
CallNotifyType.RING
|
CallNotifyType.RING
|
||||||
|
|
@ -654,12 +658,12 @@ class DefaultNotifiableEventResolverTest {
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
noisy = true,
|
noisy = true,
|
||||||
timestamp = 0L,
|
timestamp = 0L,
|
||||||
senderDisambiguatedDisplayName = "Bob",
|
senderDisambiguatedDisplayName = A_USER_NAME_2,
|
||||||
senderId = UserId("@bob:server.org"),
|
senderId = A_USER_ID_2,
|
||||||
body = "☎\uFE0F Incoming call",
|
body = "☎\uFE0F Incoming call",
|
||||||
roomId = A_ROOM_ID,
|
roomId = A_ROOM_ID,
|
||||||
threadId = null,
|
threadId = null,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
canBeReplaced = false,
|
canBeReplaced = false,
|
||||||
isRedacted = false,
|
isRedacted = false,
|
||||||
imageUriString = null,
|
imageUriString = null,
|
||||||
|
|
@ -674,11 +678,11 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve CallNotify - notify`() = runTest {
|
fun `resolve CallNotify - notify`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.CallNotify(
|
content = NotificationContent.MessageLike.CallNotify(
|
||||||
A_USER_ID_2,
|
A_USER_ID_2,
|
||||||
CallNotifyType.NOTIFY
|
CallNotifyType.NOTIFY
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -689,12 +693,12 @@ class DefaultNotifiableEventResolverTest {
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
noisy = true,
|
noisy = true,
|
||||||
timestamp = A_TIMESTAMP,
|
timestamp = A_TIMESTAMP,
|
||||||
senderDisambiguatedDisplayName = "Bob",
|
senderDisambiguatedDisplayName = A_USER_NAME_2,
|
||||||
senderId = UserId("@bob:server.org"),
|
senderId = A_USER_ID_2,
|
||||||
body = "☎\uFE0F Incoming call",
|
body = "☎\uFE0F Incoming call",
|
||||||
roomId = A_ROOM_ID,
|
roomId = A_ROOM_ID,
|
||||||
threadId = null,
|
threadId = null,
|
||||||
roomName = null,
|
roomName = A_ROOM_NAME,
|
||||||
canBeReplaced = false,
|
canBeReplaced = false,
|
||||||
isRedacted = false,
|
isRedacted = false,
|
||||||
imageUriString = null,
|
imageUriString = null,
|
||||||
|
|
@ -709,7 +713,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve RoomRedaction`() = runTest {
|
fun `resolve RoomRedaction`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomRedaction(
|
content = NotificationContent.MessageLike.RoomRedaction(
|
||||||
AN_EVENT_ID_2,
|
AN_EVENT_ID_2,
|
||||||
A_REDACTION_REASON,
|
A_REDACTION_REASON,
|
||||||
|
|
@ -731,7 +735,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
fun `resolve RoomRedaction with null redactedEventId should return null`() = runTest {
|
fun `resolve RoomRedaction with null redactedEventId should return null`() = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = NotificationContent.MessageLike.RoomRedaction(
|
content = NotificationContent.MessageLike.RoomRedaction(
|
||||||
null,
|
null,
|
||||||
A_REDACTION_REASON,
|
A_REDACTION_REASON,
|
||||||
|
|
@ -782,7 +786,7 @@ class DefaultNotifiableEventResolverTest {
|
||||||
private fun testNull(content: NotificationContent) = runTest {
|
private fun testNull(content: NotificationContent) = runTest {
|
||||||
val sut = createDefaultNotifiableEventResolver(
|
val sut = createDefaultNotifiableEventResolver(
|
||||||
notificationResult = Result.success(
|
notificationResult = Result.success(
|
||||||
createNotificationData(
|
aNotificationData(
|
||||||
content = content
|
content = content
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -819,61 +823,4 @@ class DefaultNotifiableEventResolverTest {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createNotificationData(
|
|
||||||
content: NotificationContent,
|
|
||||||
isDirect: Boolean = false,
|
|
||||||
hasMention: Boolean = false,
|
|
||||||
timestamp: Long = A_TIMESTAMP,
|
|
||||||
senderDisplayName: String? = "Bob",
|
|
||||||
senderIsNameAmbiguous: Boolean = false,
|
|
||||||
): NotificationData {
|
|
||||||
return NotificationData(
|
|
||||||
eventId = AN_EVENT_ID,
|
|
||||||
roomId = A_ROOM_ID,
|
|
||||||
senderAvatarUrl = null,
|
|
||||||
senderDisplayName = senderDisplayName,
|
|
||||||
senderIsNameAmbiguous = senderIsNameAmbiguous,
|
|
||||||
roomAvatarUrl = null,
|
|
||||||
roomDisplayName = null,
|
|
||||||
isDirect = isDirect,
|
|
||||||
isEncrypted = false,
|
|
||||||
isNoisy = false,
|
|
||||||
timestamp = timestamp,
|
|
||||||
content = content,
|
|
||||||
hasMention = hasMention,
|
|
||||||
isDm = false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createNotifiableMessageEvent(
|
|
||||||
body: String,
|
|
||||||
hasMentionOrReply: Boolean = false,
|
|
||||||
): NotifiableMessageEvent {
|
|
||||||
return NotifiableMessageEvent(
|
|
||||||
sessionId = A_SESSION_ID,
|
|
||||||
roomId = A_ROOM_ID,
|
|
||||||
eventId = AN_EVENT_ID,
|
|
||||||
editedEventId = null,
|
|
||||||
canBeReplaced = false,
|
|
||||||
senderId = A_USER_ID_2,
|
|
||||||
noisy = false,
|
|
||||||
timestamp = A_TIMESTAMP,
|
|
||||||
senderDisambiguatedDisplayName = "Bob",
|
|
||||||
body = body,
|
|
||||||
imageUriString = null,
|
|
||||||
threadId = null,
|
|
||||||
roomName = null,
|
|
||||||
roomAvatarPath = null,
|
|
||||||
senderAvatarPath = null,
|
|
||||||
soundName = null,
|
|
||||||
outGoingMessage = false,
|
|
||||||
outGoingMessageFailed = false,
|
|
||||||
isRedacted = false,
|
|
||||||
isUpdated = false,
|
|
||||||
hasMentionOrReply = hasMentionOrReply,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val A_TIMESTAMP = 567L
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import androidx.core.app.NotificationCompat
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import io.element.android.libraries.matrix.api.media.MediaSource
|
import io.element.android.libraries.matrix.api.media.MediaSource
|
||||||
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_TIMESTAMP
|
||||||
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
||||||
import io.element.android.libraries.matrix.ui.media.MediaRequestData
|
import io.element.android.libraries.matrix.ui.media.MediaRequestData
|
||||||
import io.element.android.libraries.push.impl.notifications.factories.createNotificationCreator
|
import io.element.android.libraries.push.impl.notifications.factories.createNotificationCreator
|
||||||
|
|
@ -27,7 +28,6 @@ import org.junit.runner.RunWith
|
||||||
import org.robolectric.RobolectricTestRunner
|
import org.robolectric.RobolectricTestRunner
|
||||||
import org.robolectric.RuntimeEnvironment
|
import org.robolectric.RuntimeEnvironment
|
||||||
|
|
||||||
private const val A_TIMESTAMP = 6480L
|
|
||||||
private const val A_ROOM_AVATAR = "mxc://roomAvatar"
|
private const val A_ROOM_AVATAR = "mxc://roomAvatar"
|
||||||
private const val A_USER_AVATAR_1 = "mxc://userAvatar1"
|
private const val A_USER_AVATAR_1 = "mxc://userAvatar1"
|
||||||
private const val A_USER_AVATAR_2 = "mxc://userAvatar2"
|
private const val A_USER_AVATAR_2 = "mxc://userAvatar2"
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class NotificationDataFactoryTest {
|
||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
roomId = A_ROOM_ID,
|
roomId = A_ROOM_ID,
|
||||||
summaryLine = "room-name: sender-name message-body",
|
summaryLine = "A room name: Bob Hello world!",
|
||||||
messageCount = events.size,
|
messageCount = events.size,
|
||||||
latestTimestamp = events.maxOf { it.timestamp },
|
latestTimestamp = events.maxOf { it.timestamp },
|
||||||
shouldBing = events.any { it.noisy }
|
shouldBing = events.any { it.noisy }
|
||||||
|
|
@ -152,7 +152,7 @@ class NotificationDataFactoryTest {
|
||||||
null,
|
null,
|
||||||
),
|
),
|
||||||
roomId = A_ROOM_ID,
|
roomId = A_ROOM_ID,
|
||||||
summaryLine = "room-name: sender-name message-body",
|
summaryLine = "A room name: Bob Hello world!",
|
||||||
messageCount = withRedactedRemoved.size,
|
messageCount = withRedactedRemoved.size,
|
||||||
latestTimestamp = withRedactedRemoved.maxOf { it.timestamp },
|
latestTimestamp = withRedactedRemoved.maxOf { it.timestamp },
|
||||||
shouldBing = withRedactedRemoved.any { it.noisy }
|
shouldBing = withRedactedRemoved.any { it.noisy }
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,13 @@ import io.element.android.libraries.matrix.api.notification.CallNotifyType
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
|
||||||
import io.element.android.libraries.matrix.test.AN_AVATAR_URL
|
import io.element.android.libraries.matrix.test.AN_AVATAR_URL
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
|
import io.element.android.libraries.matrix.test.A_MESSAGE
|
||||||
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.libraries.matrix.test.A_SESSION_ID
|
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||||
|
import io.element.android.libraries.matrix.test.A_TIMESTAMP
|
||||||
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
import io.element.android.libraries.matrix.test.A_USER_ID_2
|
||||||
|
import io.element.android.libraries.matrix.test.A_USER_NAME_2
|
||||||
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableMessageEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableRingingCallEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableRingingCallEvent
|
||||||
|
|
@ -56,7 +60,7 @@ fun anInviteNotifiableEvent(
|
||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
roomName = "a room name",
|
roomName = A_ROOM_NAME,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
noisy = false,
|
noisy = false,
|
||||||
title = "title",
|
title = "title",
|
||||||
|
|
@ -69,28 +73,40 @@ fun anInviteNotifiableEvent(
|
||||||
)
|
)
|
||||||
|
|
||||||
fun aNotifiableMessageEvent(
|
fun aNotifiableMessageEvent(
|
||||||
|
body: String = A_MESSAGE,
|
||||||
sessionId: SessionId = A_SESSION_ID,
|
sessionId: SessionId = A_SESSION_ID,
|
||||||
roomId: RoomId = A_ROOM_ID,
|
roomId: RoomId = A_ROOM_ID,
|
||||||
eventId: EventId = AN_EVENT_ID,
|
eventId: EventId = AN_EVENT_ID,
|
||||||
threadId: ThreadId? = null,
|
threadId: ThreadId? = null,
|
||||||
isRedacted: Boolean = false,
|
isRedacted: Boolean = false,
|
||||||
timestamp: Long = 0,
|
hasMentionOrReply: Boolean = false,
|
||||||
|
timestamp: Long = A_TIMESTAMP,
|
||||||
type: String = EventType.MESSAGE,
|
type: String = EventType.MESSAGE,
|
||||||
|
senderId: UserId = A_USER_ID_2,
|
||||||
|
senderDisambiguatedDisplayName: String = A_USER_NAME_2,
|
||||||
|
roomName: String? = A_ROOM_NAME,
|
||||||
) = NotifiableMessageEvent(
|
) = NotifiableMessageEvent(
|
||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
noisy = false,
|
noisy = false,
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
senderDisambiguatedDisplayName = "sender-name",
|
senderDisambiguatedDisplayName = senderDisambiguatedDisplayName,
|
||||||
senderId = UserId("@sending-id:domain.com"),
|
senderId = senderId,
|
||||||
body = "message-body",
|
body = body,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
threadId = threadId,
|
threadId = threadId,
|
||||||
roomName = "room-name",
|
roomName = roomName,
|
||||||
canBeReplaced = false,
|
canBeReplaced = false,
|
||||||
isRedacted = isRedacted,
|
isRedacted = isRedacted,
|
||||||
imageUriString = null,
|
imageUriString = null,
|
||||||
|
roomAvatarPath = null,
|
||||||
|
senderAvatarPath = null,
|
||||||
|
soundName = null,
|
||||||
|
outGoingMessage = false,
|
||||||
|
outGoingMessageFailed = false,
|
||||||
|
isUpdated = false,
|
||||||
|
hasMentionOrReply = hasMentionOrReply,
|
||||||
type = type,
|
type = type,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -108,7 +124,7 @@ fun aNotifiableCallEvent(
|
||||||
sessionId = sessionId,
|
sessionId = sessionId,
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
roomName = "a room name",
|
roomName = A_ROOM_NAME,
|
||||||
editedEventId = null,
|
editedEventId = null,
|
||||||
description = "description",
|
description = "description",
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue