diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt index fb44b6f0ab..e99a473cb7 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/ObjectBoxToLibkiwixMigratorTest.kt @@ -119,6 +119,8 @@ class ObjectBoxToLibkiwixMigratorTest : BaseActivityTest() { ) } box = boxStore.boxFor(BookmarkEntity::class.java) + // clear the data before running the test case + clearBookmarks() // add a file in fileSystem because we need to actual file path for making object of Archive. val loadFileStream = @@ -139,9 +141,6 @@ class ObjectBoxToLibkiwixMigratorTest : BaseActivityTest() { } } } - - // clear the data before running the test case - clearBookmarks() } @Test @@ -310,7 +309,9 @@ class ObjectBoxToLibkiwixMigratorTest : BaseActivityTest() { .blockingFirst() as List ) box.removeAll() - zimFile.delete() // delete the temp ZIM file to free up the memory + if (::zimFile.isInitialized) { + zimFile.delete() // delete the temp ZIM file to free up the memory + } } @After 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 19e426a6e3..0a10c2d0c1 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadRobot.kt @@ -42,8 +42,8 @@ fun downloadRobot(func: DownloadRobot.() -> Unit) = class DownloadRobot : BaseRobot() { - private var retryCountForDataToLoad = 5 - private var retryCountForCheckDownloadStart = 5 + private var retryCountForDataToLoad = 10 + private var retryCountForCheckDownloadStart = 10 private val zimFileTitle = "Off the Grid" fun clickLibraryOnBottomNav() { @@ -69,6 +69,10 @@ class DownloadRobot : BaseRobot() { isVisible(Text(zimFileTitle)) } + fun refreshOnlineList() { + refresh(R.id.librarySwipeRefresh) + } + fun downloadZimFile() { clickOn(Text(zimFileTitle)) } 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 7d6a2ad118..2ebe377b04 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/download/DownloadTest.kt @@ -91,6 +91,7 @@ class DownloadTest : BaseActivityTest() { } downloadRobot { clickDownloadOnBottomNav() + refreshOnlineList() waitForDataToLoad() stopDownloadIfAlreadyStarted() downloadZimFile() diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt index 6da4299122..6bc5595f41 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/initial/download/InitialDownloadRobot.kt @@ -41,8 +41,8 @@ fun initialDownload(func: InitialDownloadRobot.() -> Unit) = class InitialDownloadRobot : BaseRobot() { - private var retryCountForCheckDownloadStart = 5 - private var retryCountForCheckDataLoaded = 5 + private var retryCountForCheckDownloadStart = 10 + private var retryCountForCheckDataLoaded = 10 private val zimFileTitle = "Off the Grid" fun clickLibraryOnBottomNav() { diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt index 79300b463d..c97078dbc2 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageFragmentTest.kt @@ -20,8 +20,9 @@ package org.kiwix.kiwixmobile.language import android.Manifest import android.app.Instrumentation import androidx.core.content.edit +import androidx.lifecycle.Lifecycle import androidx.preference.PreferenceManager -import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.core.app.ActivityScenario import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import androidx.test.platform.app.InstrumentationRegistry @@ -46,9 +47,6 @@ class LanguageFragmentTest { @JvmField var retryRule = RetryRule() - @get:Rule - var activityScenarioRule = ActivityScenarioRule(KiwixMainActivity::class.java) - private val permissions = arrayOf( Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE @@ -77,6 +75,9 @@ class LanguageFragmentTest { putBoolean(SharedPreferenceUtil.PREF_WIFI_ONLY, false) putBoolean(SharedPreferenceUtil.PREF_PLAY_STORE_RESTRICTION, false) } + ActivityScenario.launch(KiwixMainActivity::class.java).apply { + moveToState(Lifecycle.State.RESUMED) + } } @Test diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt index 3c6506fe49..cfaf05651f 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/language/LanguageRobot.kt @@ -38,7 +38,7 @@ fun language(func: LanguageRobot.() -> Unit) = LanguageRobot().applyWithViewHier class LanguageRobot : BaseRobot() { - private var retryCountForDataToLoad = 5 + private var retryCountForDataToLoad = 10 fun clickDownloadOnBottomNav() { clickOn(ViewId(R.id.downloadsFragment))