Browse Source

Test that blurhash is correctly used and fix issue on StickerContent.

pull/2384/head
Benoit Marty 7 months ago
parent
commit
d33f5543b6
  1. 3
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/InReplyToMetadata.kt
  2. 33
      features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/model/InReplyToMetadataKtTest.kt

3
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/InReplyToMetadata.kt

@ -114,7 +114,8 @@ internal fun InReplyToDetails.metadata(): InReplyToMetadata? = when (eventConten @@ -114,7 +114,8 @@ internal fun InReplyToDetails.metadata(): InReplyToMetadata? = when (eventConten
AttachmentThumbnailInfo(
thumbnailSource = MediaSource(eventContent.url),
textContent = eventContent.body,
type = AttachmentThumbnailType.Image
type = AttachmentThumbnailType.Image,
blurHash = eventContent.info.blurhash,
)
)
is PollContent -> InReplyToMetadata.Thumbnail(

33
features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/timeline/model/InReplyToMetadataKtTest.kt

@ -55,6 +55,7 @@ import io.element.android.libraries.matrix.test.A_USER_ID @@ -55,6 +55,7 @@ import io.element.android.libraries.matrix.test.A_USER_ID
import io.element.android.libraries.matrix.test.media.aMediaSource
import io.element.android.libraries.matrix.test.timeline.aMessageContent
import io.element.android.libraries.matrix.test.timeline.aPollContent
import io.element.android.libraries.matrix.ui.components.A_BLUR_HASH
import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailInfo
import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailType
import kotlinx.coroutines.test.runTest
@ -82,7 +83,7 @@ class InReplyToMetadataKtTest { @@ -82,7 +83,7 @@ class InReplyToMetadataKtTest {
messageType = ImageMessageType(
body = "body",
source = aMediaSource(),
info = null,
info = anImageInfo(),
)
)
).metadata()
@ -94,7 +95,7 @@ class InReplyToMetadataKtTest { @@ -94,7 +95,7 @@ class InReplyToMetadataKtTest {
thumbnailSource = aMediaSource(),
textContent = "body",
type = AttachmentThumbnailType.Image,
blurHash = null,
blurHash = A_BLUR_HASH,
)
)
)
@ -108,15 +109,7 @@ class InReplyToMetadataKtTest { @@ -108,15 +109,7 @@ class InReplyToMetadataKtTest {
anInReplyToDetails(
eventContent = StickerContent(
body = "body",
info = ImageInfo(
height = null,
width = null,
mimetype = null,
size = null,
thumbnailInfo = null,
thumbnailSource = aMediaSource(),
blurhash = null
),
info = anImageInfo(),
url = "url"
)
).metadata()
@ -128,7 +121,7 @@ class InReplyToMetadataKtTest { @@ -128,7 +121,7 @@ class InReplyToMetadataKtTest {
thumbnailSource = aMediaSource(url = "url"),
textContent = "body",
type = AttachmentThumbnailType.Image,
blurHash = null,
blurHash = A_BLUR_HASH,
)
)
)
@ -152,7 +145,7 @@ class InReplyToMetadataKtTest { @@ -152,7 +145,7 @@ class InReplyToMetadataKtTest {
size = null,
thumbnailInfo = null,
thumbnailSource = aMediaSource(),
blurhash = null
blurhash = A_BLUR_HASH
),
)
)
@ -165,7 +158,7 @@ class InReplyToMetadataKtTest { @@ -165,7 +158,7 @@ class InReplyToMetadataKtTest {
thumbnailSource = aMediaSource(),
textContent = "body",
type = AttachmentThumbnailType.Video,
blurHash = null,
blurHash = A_BLUR_HASH,
)
)
)
@ -454,6 +447,18 @@ fun anInReplyToDetails( @@ -454,6 +447,18 @@ fun anInReplyToDetails(
textContent = textContent,
)
fun anImageInfo(): ImageInfo {
return ImageInfo(
height = 100,
width = 100,
mimetype = "image/jpeg",
size = 1000,
thumbnailInfo = null,
thumbnailSource = aMediaSource(),
blurhash = A_BLUR_HASH,
)
}
@Composable
private fun testEnv(content: @Composable () -> Any?): Any? {
var result: Any? = null

Loading…
Cancel
Save