Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/utils/ImportUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ object ImportUtils {
}
}

@NeedsTest("Check file name is absolute")
fun getFileCachedCopy(
context: Context,
uri: Uri,
Expand Down
10 changes: 10 additions & 0 deletions AnkiDroid/src/test/java/com/ichi2/utils/ImportUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ import org.hamcrest.Matchers.containsString
import org.hamcrest.Matchers.endsWith
import org.hamcrest.Matchers.lessThanOrEqualTo
import org.hamcrest.Matchers.not
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import java.io.File

@RunWith(AndroidJUnit4::class)
class ImportUtilsTest : RobolectricTest() {
Expand Down Expand Up @@ -76,6 +78,14 @@ class ImportUtilsTest : RobolectricTest() {
return testFileImporter.cacheFileName
}

@Test
fun getFileCachedCopyReturnsAbsolutePath() {
val filename = "spaced filename.apkg"
val expectedFilepath = File(targetContext.cacheDir, filename).absolutePath
val actualFilepath = TestFileImporter(filename).getFileCachedCopy(targetContext, "dummy".toUri())
assertEquals(expectedFilepath, actualFilepath)
}

@Test
fun collectionApkgIsValid() {
assertTrue(ImportUtils.isValidPackageName("collection.apkg"))
Expand Down
Loading