mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-04 03:06:41 -04:00
Improved the CopyMoveFileHandlerTest
UI test.
This commit is contained in:
parent
a968e380e8
commit
0d4a8a961b
@ -22,6 +22,7 @@ import android.net.Uri
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
|
import androidx.documentfile.provider.DocumentFile
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
@ -193,7 +194,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() {
|
|||||||
navHostFragment.childFragmentManager.fragments[0] as LocalLibraryFragment
|
navHostFragment.childFragmentManager.fragments[0] as LocalLibraryFragment
|
||||||
localLibraryFragment.copyMoveFileHandler?.showMoveFileToPublicDirectoryDialog(
|
localLibraryFragment.copyMoveFileHandler?.showMoveFileToPublicDirectoryDialog(
|
||||||
Uri.fromFile(selectedFile),
|
Uri.fromFile(selectedFile),
|
||||||
selectedFile
|
DocumentFile.fromFile(selectedFile)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +241,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() {
|
|||||||
selectedFile = File(parentFile, selectedFileName).apply {
|
selectedFile = File(parentFile, selectedFileName).apply {
|
||||||
if (!isFileExist()) createNewFile()
|
if (!isFileExist()) createNewFile()
|
||||||
}
|
}
|
||||||
copyMoveFileHandler.setSelectedFileAndUri(null, selectedFile)
|
copyMoveFileHandler.setSelectedFileAndUri(null, DocumentFile.fromFile(selectedFile))
|
||||||
destinationFile = copyMoveFileHandler.getDestinationFile()
|
destinationFile = copyMoveFileHandler.getDestinationFile()
|
||||||
Assert.assertNotEquals(
|
Assert.assertNotEquals(
|
||||||
destinationFile.name,
|
destinationFile.name,
|
||||||
@ -254,7 +255,7 @@ class CopyMoveFileHandlerTest : BaseActivityTest() {
|
|||||||
|
|
||||||
// test when there is no zim file available in the storage it should return the same fileName
|
// test when there is no zim file available in the storage it should return the same fileName
|
||||||
selectedFile = File(parentFile, selectedFileName)
|
selectedFile = File(parentFile, selectedFileName)
|
||||||
copyMoveFileHandler.setSelectedFileAndUri(null, selectedFile)
|
copyMoveFileHandler.setSelectedFileAndUri(null, DocumentFile.fromFile(selectedFile))
|
||||||
destinationFile = copyMoveFileHandler.getDestinationFile()
|
destinationFile = copyMoveFileHandler.getDestinationFile()
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
destinationFile.name,
|
destinationFile.name,
|
||||||
|
@ -356,7 +356,7 @@ class CopyMoveFileHandler @Inject constructor(
|
|||||||
} ?: throw FileNotFoundException("The selected file could not be opened")
|
} ?: throw FileNotFoundException("The selected file could not be opened")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDestinationFile(): File {
|
fun getDestinationFile(): File {
|
||||||
val root = File(sharedPreferenceUtil.prefStorage)
|
val root = File(sharedPreferenceUtil.prefStorage)
|
||||||
val fileName = selectedFile?.name ?: ""
|
val fileName = selectedFile?.name ?: ""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user