Fix download test

This commit is contained in:
MohitMali 2022-12-09 17:39:33 +05:30
parent acd7adff0a
commit 2b8914dbf6
2 changed files with 4 additions and 10 deletions

View File

@ -19,11 +19,9 @@
package org.kiwix.kiwixmobile.download
import android.util.Log
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import applyWithViewHierarchyPrinting
@ -42,7 +40,7 @@ class DownloadRobot : BaseRobot() {
private var retryCountForDataToLoad = 5
private var retryCountForCheckDownloadStart = 5
private val zimFileTitle = "A little question a day"
private val zimFileTitle = "Off the Grid"
fun clickLibraryOnBottomNav() {
clickOn(ViewId(R.id.libraryFragment))
@ -68,7 +66,7 @@ class DownloadRobot : BaseRobot() {
fun waitForDataToLoad() {
try {
isVisible(Text("Off the Grid"))
isVisible(Text(zimFileTitle))
} catch (e: RuntimeException) {
if (retryCountForDataToLoad > 0) {
retryCountForDataToLoad--
@ -77,10 +75,6 @@ class DownloadRobot : BaseRobot() {
}
}
fun scrollToAlpineWikiZim() {
onView(withId(R.id.libraryList)).perform(scrollToPosition<ViewHolder>(20))
}
fun checkIfZimFileDownloaded() {
isVisible(Text(zimFileTitle))
}

View File

@ -73,17 +73,17 @@ class DownloadTest : BaseActivityTest() {
deleteZimIfExists()
clickDownloadOnBottomNav()
waitForDataToLoad()
scrollToAlpineWikiZim()
downloadZimFile()
assertDownloadStart()
waitUntilDownloadComplete()
clickLibraryOnBottomNav()
checkIfZimFileDownloaded()
deleteZimIfExists()
}
} catch (e: Exception) {
Assert.fail(
"""
Couldn't find downloaded file 'A little question a day'
Couldn't find downloaded file 'Off the Grid'
Original Exception:
${e.localizedMessage}
""".trimIndent()