Upgrade robolectric to version 4.16 (#5923)

* Update dependency org.robolectric:robolectric to v4.16

* Fix file size formatter output on API 26+

* Use more realistic value for maxUploadSize

* Update screenshots

* Fix test issue: "java.security.KeyStoreException: AndroidKeyStore not found"

* Add exceptions.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
Benoit Marty 2025-12-19 15:37:38 +01:00 committed by GitHub
commit 2a9765ad33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 127 additions and 30 deletions

View file

@ -24,12 +24,15 @@ class AndroidFileSizeFormatter(
override fun format(fileSize: Long, useShortFormat: Boolean): String {
// Since Android O, the system considers that 1kB = 1000 bytes instead of 1024 bytes.
// We want to avoid that.
// Sadly we do not have access to the flags values Formatter.FLAG_IEC_UNITS and Formatter.FLAG_SHORTER
// nor the method Formatter.formatFileSize with the flags parameter.
// So for Android 0 and more, first convert the fileSize to MB/GB/TB ourselves
val normalizedSize = if (sdkIntProvider.get() <= Build.VERSION_CODES.N) {
fileSize
} else {
// First convert the size
when {
fileSize < 1024 -> fileSize
fileSize <= 1 -> fileSize
fileSize < 1024 * 1024 -> fileSize * 1000 / 1024
fileSize < 1024 * 1024 * 1024 -> fileSize * 1000 / 1024 * 1000 / 1024
else -> fileSize * 1000 / 1024 * 1000 / 1024 * 1000 / 1024
@ -40,6 +43,6 @@ class AndroidFileSizeFormatter(
Formatter.formatShortFileSize(context, normalizedSize)
} else {
Formatter.formatFileSize(context, normalizedSize)
}
}.replace("kB", "KB")
}
}