From 44ffaa34319665ce1f509826250cf46db01123dc Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 31 Jul 2026 09:28:30 +0000 Subject: [PATCH 1/2] chore(deps): [WPB-9777] Update dependency org.robolectric:robolectric to v4.16.1 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0e957dbe920..17fb3bd4a34 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -112,7 +112,7 @@ junit5 = "5.11.0" mockk = "1.14.11" okio = "3.9.0" turbine = "1.2.1" -robolectric = "4.14.1" +robolectric = "4.16.1" hamcrest = "3.0" rules = "1.7.0" zxing = "3.5.2" From 989762fa79c4574c203730f73b7aadb5d7bf7082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Saleniuk?= Date: Wed, 5 Aug 2026 12:42:28 +0200 Subject: [PATCH 2/2] fix mocking uri mime type --- .../com/wire/android/util/FileHelperTest.kt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/test/kotlin/com/wire/android/util/FileHelperTest.kt b/app/src/test/kotlin/com/wire/android/util/FileHelperTest.kt index 7822871e69a..35ea95ae2ca 100644 --- a/app/src/test/kotlin/com/wire/android/util/FileHelperTest.kt +++ b/app/src/test/kotlin/com/wire/android/util/FileHelperTest.kt @@ -28,11 +28,13 @@ import android.os.Environment import androidx.core.content.FileProvider import io.mockk.MockKAnnotations import io.mockk.coEvery +import io.mockk.every import io.mockk.impl.annotations.MockK import io.mockk.mockkStatic import io.mockk.verify import io.mockk.verifyOrder import kotlinx.coroutines.test.runTest +import okio.Path import okio.Path.Companion.toOkioPath import org.junit.Rule import org.junit.Test @@ -98,10 +100,10 @@ class FileHelperTest { @Test fun `given Android greater than 9, when saving file to downloads folder, then use correct order of executions`() = runTest { // given + val downloadedFilePath = tempDir.newFile("filename.txt").toOkioPath() val arrangement = Arrangement() - .withUriMimeType("text/plain") + .withUriMimeType(downloadedFilePath, "text/plain") .arrange() - val downloadedFilePath = tempDir.newFile("filename.txt").toOkioPath() // when saveFileToDownloadsFolder("name", downloadedFilePath, 100L, arrangement.context) // then @@ -118,10 +120,10 @@ class FileHelperTest { @Test fun `given Android 9, when saving file to downloads folder, then use correct order of executions`() = runTest { // given + val downloadedFilePath = tempDir.newFile("filename.txt").toOkioPath() val arrangement = Arrangement() - .withUriMimeType("text/plain") + .withUriMimeType(downloadedFilePath, "text/plain") .arrange() - val downloadedFilePath = tempDir.newFile("filename.txt").toOkioPath() // when saveFileToDownloadsFolder("name", downloadedFilePath, 100L, arrangement.context) // then @@ -138,10 +140,10 @@ class FileHelperTest { @Test fun `given Android 9 and null mimeType, when saving file to downloads folder, then use mimeType indicating all types`() = runTest { // given + val downloadedFilePath = tempDir.newFile("filename.txt").toOkioPath() val arrangement = Arrangement() - .withUriMimeType(null) + .withUriMimeType(downloadedFilePath, null) .arrange() - val downloadedFilePath = tempDir.newFile("filename.txt").toOkioPath() // when saveFileToDownloadsFolder("name", downloadedFilePath, 100L, arrangement.context) // then @@ -168,6 +170,7 @@ class FileHelperTest { MockKAnnotations.init(this, relaxUnitFun = true) mockkStatic(Environment::class) mockkStatic(FileProvider::class) + mockkStatic(Uri::class) mockkStatic("com.wire.android.util.FileUtilKt") coEvery { context.packageName } returns "com.wire" coEvery { context.contentResolver } returns contentResolver @@ -177,11 +180,11 @@ class FileHelperTest { coEvery { contentResolver.insert(any(), any()) } returns uri coEvery { downloadManager.addCompletedDownload(any(), any(), any(), any(), any(), any(), any()) } returns 1L coEvery { contentResolver.copyFile(any(), any()) } returns Unit - withUriMimeType(null) } - fun withUriMimeType(mimeType: String?) = apply { - coEvery { uri.getMimeType(context) } returns mimeType + fun withUriMimeType(downloadedDataPath: Path, mimeType: String?) = apply { + every { Uri.parse(downloadedDataPath.toString()) } returns uri + every { uri.getMimeType(context) } returns mimeType } fun arrange() = this