- Added @VisibleForTesting annotation to the three internal methods in ShareHelper.kt — signals test-only intent and triggers lint warnings if called from production code

- Removed redundant deleteOnExit() in test helper — explicit delete() after each test already handles cleanup; the shutdown hook was unnecessary overhead
This commit is contained in:
davotoula
2026-04-05 18:05:48 +02:00
parent 6e1526e178
commit f9c7e3b15c
2 changed files with 4 additions and 1 deletions
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.components
import android.content.Context
import android.net.Uri
import androidx.annotation.VisibleForTesting
import androidx.core.content.FileProvider
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.quartz.utils.Log
@@ -85,10 +86,13 @@ object ShareHelper {
} ?: throw IOException("Unable to open snapshot for: $imageUrl")
}
@VisibleForTesting
internal fun getImageExtension(file: File): String = getMediaExtension(file, isVideo = false)
@VisibleForTesting
internal fun getVideoExtension(file: File): String = getMediaExtension(file, isVideo = true)
@VisibleForTesting
internal fun getMediaExtension(
file: File,
isVideo: Boolean,
@@ -159,7 +159,6 @@ class ShareHelperTest {
private fun createTempFileWithBytes(bytes: ByteArray): File {
val file = File.createTempFile("sharehelpertest", ".tmp")
file.deleteOnExit()
file.writeBytes(bytes)
return file
}