- 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:
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.ui.components
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.annotation.VisibleForTesting
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import com.vitorpamplona.amethyst.Amethyst
|
import com.vitorpamplona.amethyst.Amethyst
|
||||||
import com.vitorpamplona.quartz.utils.Log
|
import com.vitorpamplona.quartz.utils.Log
|
||||||
@@ -85,10 +86,13 @@ object ShareHelper {
|
|||||||
} ?: throw IOException("Unable to open snapshot for: $imageUrl")
|
} ?: throw IOException("Unable to open snapshot for: $imageUrl")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
internal fun getImageExtension(file: File): String = getMediaExtension(file, isVideo = false)
|
internal fun getImageExtension(file: File): String = getMediaExtension(file, isVideo = false)
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
internal fun getVideoExtension(file: File): String = getMediaExtension(file, isVideo = true)
|
internal fun getVideoExtension(file: File): String = getMediaExtension(file, isVideo = true)
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
internal fun getMediaExtension(
|
internal fun getMediaExtension(
|
||||||
file: File,
|
file: File,
|
||||||
isVideo: Boolean,
|
isVideo: Boolean,
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ class ShareHelperTest {
|
|||||||
|
|
||||||
private fun createTempFileWithBytes(bytes: ByteArray): File {
|
private fun createTempFileWithBytes(bytes: ByteArray): File {
|
||||||
val file = File.createTempFile("sharehelpertest", ".tmp")
|
val file = File.createTempFile("sharehelpertest", ".tmp")
|
||||||
file.deleteOnExit()
|
|
||||||
file.writeBytes(bytes)
|
file.writeBytes(bytes)
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user