diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt index dde68a9cc..a39a33705 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt @@ -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" ) } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt index 910afb983..853474bd6 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt @@ -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)