mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Restore test for image sending, now that computing Thumbnail can fail.
This commit is contained in:
+5
@@ -65,6 +65,7 @@ class ThumbnailFactory @Inject constructor(
|
|||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
suspend fun createImageThumbnail(file: File): ThumbnailResult? {
|
suspend fun createImageThumbnail(file: File): ThumbnailResult? {
|
||||||
return createThumbnail { cancellationSignal ->
|
return createThumbnail { cancellationSignal ->
|
||||||
|
try {
|
||||||
// This API works correctly with GIF
|
// This API works correctly with GIF
|
||||||
if (sdkIntProvider.isAtLeast(Build.VERSION_CODES.Q)) {
|
if (sdkIntProvider.isAtLeast(Build.VERSION_CODES.Q)) {
|
||||||
try {
|
try {
|
||||||
@@ -84,6 +85,10 @@ class ThumbnailFactory @Inject constructor(
|
|||||||
MediaStore.Images.Thumbnails.MINI_KIND,
|
MediaStore.Images.Thumbnails.MINI_KIND,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} catch (throwable: Throwable) {
|
||||||
|
Timber.w(throwable, "Failed to create thumbnail for $file")
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-16
@@ -55,15 +55,11 @@ class AndroidMediaPreProcessorTest {
|
|||||||
deleteOriginal = false,
|
deleteOriginal = false,
|
||||||
compressIfPossible = true,
|
compressIfPossible = true,
|
||||||
)
|
)
|
||||||
// This is failing for now
|
|
||||||
val error = result.exceptionOrNull()
|
|
||||||
assertThat(error).isInstanceOf(MediaPreProcessor.Failure::class.java)
|
|
||||||
assertThat(error?.cause).isInstanceOf(NullPointerException::class.java)
|
|
||||||
/*
|
|
||||||
val data = result.getOrThrow()
|
val data = result.getOrThrow()
|
||||||
assertThat(data.file.path).endsWith("image.png")
|
assertThat(data.file.path).endsWith("image.png")
|
||||||
val info = data as MediaUploadInfo.Image
|
val info = data as MediaUploadInfo.Image
|
||||||
assertThat(info.thumbnailFile).isNull() // TODO Check this
|
// Computing thumbnailFile is failing with Robolectric
|
||||||
|
assertThat(info.thumbnailFile).isNull()
|
||||||
assertThat(info.imageInfo).isEqualTo(
|
assertThat(info.imageInfo).isEqualTo(
|
||||||
ImageInfo(
|
ImageInfo(
|
||||||
height = 1_178,
|
height = 1_178,
|
||||||
@@ -76,7 +72,6 @@ class AndroidMediaPreProcessorTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
assertThat(file.exists()).isTrue()
|
assertThat(file.exists()).isTrue()
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -90,15 +85,11 @@ class AndroidMediaPreProcessorTest {
|
|||||||
deleteOriginal = false,
|
deleteOriginal = false,
|
||||||
compressIfPossible = true,
|
compressIfPossible = true,
|
||||||
)
|
)
|
||||||
// This is not working for now
|
|
||||||
val error = result.exceptionOrNull()
|
|
||||||
assertThat(error).isInstanceOf(MediaPreProcessor.Failure::class.java)
|
|
||||||
assertThat(error?.cause).isInstanceOf(NoSuchMethodError::class.java)
|
|
||||||
/*
|
|
||||||
val data = result.getOrThrow()
|
val data = result.getOrThrow()
|
||||||
assertThat(data.file.path).endsWith("image.png")
|
assertThat(data.file.path).endsWith("image.png")
|
||||||
val info = data as MediaUploadInfo.Image
|
val info = data as MediaUploadInfo.Image
|
||||||
assertThat(info.thumbnailFile).isNull() // TODO Check this
|
// Computing thumbnailFile is failing with Robolectric
|
||||||
|
assertThat(info.thumbnailFile).isNull()
|
||||||
assertThat(info.imageInfo).isEqualTo(
|
assertThat(info.imageInfo).isEqualTo(
|
||||||
ImageInfo(
|
ImageInfo(
|
||||||
height = 1_178,
|
height = 1_178,
|
||||||
@@ -111,7 +102,6 @@ class AndroidMediaPreProcessorTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
assertThat(file.exists()).isTrue()
|
assertThat(file.exists()).isTrue()
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -266,7 +256,8 @@ class AndroidMediaPreProcessorTest {
|
|||||||
).getOrThrow()
|
).getOrThrow()
|
||||||
assertThat(result.file.path).endsWith("video.mp4")
|
assertThat(result.file.path).endsWith("video.mp4")
|
||||||
val info = result as MediaUploadInfo.Video
|
val info = result as MediaUploadInfo.Video
|
||||||
assertThat(info.thumbnailFile).isNotNull()
|
// Computing thumbnailFile is failing with Robolectric
|
||||||
|
assertThat(info.thumbnailFile).isNull()
|
||||||
assertThat(info.videoInfo).isEqualTo(
|
assertThat(info.videoInfo).isEqualTo(
|
||||||
VideoInfo(
|
VideoInfo(
|
||||||
duration = Duration.ZERO, // Not available with Robolectric?
|
duration = Duration.ZERO, // Not available with Robolectric?
|
||||||
@@ -274,7 +265,7 @@ class AndroidMediaPreProcessorTest {
|
|||||||
width = 0, // Not available with Robolectric?
|
width = 0, // Not available with Robolectric?
|
||||||
mimetype = MimeTypes.Mp4,
|
mimetype = MimeTypes.Mp4,
|
||||||
size = 1_673_712,
|
size = 1_673_712,
|
||||||
thumbnailInfo = ThumbnailInfo(height = null, width = null, mimetype = MimeTypes.Jpeg, size = 0), // Not available with Robolectric?
|
thumbnailInfo = null,
|
||||||
thumbnailSource = null,
|
thumbnailSource = null,
|
||||||
blurhash = null,
|
blurhash = null,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user