mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Improved the DownloadTest which sometimes failing on API level 25
This commit is contained in:
parent
f3d115cde1
commit
3c378b5d7a
@ -42,6 +42,7 @@ import org.kiwix.kiwixmobile.Findable.ViewId
|
||||
import org.kiwix.kiwixmobile.R
|
||||
import org.kiwix.kiwixmobile.core.R.string
|
||||
import org.kiwix.kiwixmobile.core.utils.files.Log
|
||||
import org.kiwix.kiwixmobile.download.DownloadTest.Companion.KIWIX_DOWNLOAD_TEST
|
||||
import org.kiwix.kiwixmobile.testutils.TestUtils
|
||||
import org.kiwix.kiwixmobile.testutils.TestUtils.testFlakyView
|
||||
import org.kiwix.kiwixmobile.utils.RecyclerViewMatcher
|
||||
@ -150,12 +151,12 @@ class DownloadRobot : BaseRobot() {
|
||||
fun waitUntilDownloadComplete(retryCountForDownloadingZimFile: Int = 30) {
|
||||
try {
|
||||
onView(withId(R.id.stop)).check(doesNotExist())
|
||||
Log.i("kiwixDownloadTest", "Download complete")
|
||||
Log.e(KIWIX_DOWNLOAD_TEST, "Download complete")
|
||||
} catch (e: AssertionFailedError) {
|
||||
if (retryCountForDownloadingZimFile > 0) {
|
||||
resumeDownloadIfPaused()
|
||||
BaristaSleepInteractions.sleep(TestUtils.TEST_PAUSE_MS_FOR_DOWNLOAD_TEST.toLong())
|
||||
Log.i("kiwixDownloadTest", "Downloading in progress")
|
||||
Log.e(KIWIX_DOWNLOAD_TEST, "Downloading in progress")
|
||||
waitUntilDownloadComplete(retryCountForDownloadingZimFile - 1)
|
||||
return
|
||||
}
|
||||
@ -203,7 +204,7 @@ class DownloadRobot : BaseRobot() {
|
||||
pauseForBetterTestPerformance()
|
||||
} catch (e: Exception) {
|
||||
Log.i(
|
||||
"DOWNLOAD_TEST",
|
||||
KIWIX_DOWNLOAD_TEST,
|
||||
"Failed to stop downloading. Probably because it is not downloading the zim file"
|
||||
)
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.kiwix.kiwixmobile.download
|
||||
|
||||
import android.util.Log
|
||||
import androidx.core.content.edit
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
@ -138,17 +139,21 @@ class DownloadTest : BaseActivityTest() {
|
||||
scrollToZimFileIndex(smallestZimFileIndex)
|
||||
stopDownloadIfAlreadyStarted()
|
||||
downloadZimFile(smallestZimFileIndex)
|
||||
assertDownloadStart()
|
||||
try {
|
||||
assertDownloadStart()
|
||||
pauseDownload()
|
||||
assertDownloadPaused()
|
||||
resumeDownload()
|
||||
assertDownloadResumed()
|
||||
waitUntilDownloadComplete()
|
||||
} catch (ignore: Exception) {
|
||||
// do nothing as ZIM file already downloaded, since we are downloading the smallest file
|
||||
// so it can be downloaded immediately after starting.
|
||||
Log.e(
|
||||
KIWIX_DOWNLOAD_TEST,
|
||||
"Could not pause download. Original exception = $ignore"
|
||||
)
|
||||
}
|
||||
waitUntilDownloadComplete()
|
||||
clickLibraryOnBottomNav()
|
||||
// refresh the local library list to show the downloaded zim file
|
||||
library(LibraryRobot::refreshList)
|
||||
|
Loading…
x
Reference in New Issue
Block a user