mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Fix download test
This commit is contained in:
parent
acd7adff0a
commit
2b8914dbf6
@ -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))
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user