mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 15:27:55 -04:00
Fix download test
This commit is contained in:
parent
acd7adff0a
commit
2b8914dbf6
@ -19,11 +19,9 @@
|
|||||||
package org.kiwix.kiwixmobile.download
|
package org.kiwix.kiwixmobile.download
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
import androidx.test.espresso.action.ViewActions.click
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
|
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.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import applyWithViewHierarchyPrinting
|
import applyWithViewHierarchyPrinting
|
||||||
@ -42,7 +40,7 @@ class DownloadRobot : BaseRobot() {
|
|||||||
|
|
||||||
private var retryCountForDataToLoad = 5
|
private var retryCountForDataToLoad = 5
|
||||||
private var retryCountForCheckDownloadStart = 5
|
private var retryCountForCheckDownloadStart = 5
|
||||||
private val zimFileTitle = "A little question a day"
|
private val zimFileTitle = "Off the Grid"
|
||||||
|
|
||||||
fun clickLibraryOnBottomNav() {
|
fun clickLibraryOnBottomNav() {
|
||||||
clickOn(ViewId(R.id.libraryFragment))
|
clickOn(ViewId(R.id.libraryFragment))
|
||||||
@ -68,7 +66,7 @@ class DownloadRobot : BaseRobot() {
|
|||||||
|
|
||||||
fun waitForDataToLoad() {
|
fun waitForDataToLoad() {
|
||||||
try {
|
try {
|
||||||
isVisible(Text("Off the Grid"))
|
isVisible(Text(zimFileTitle))
|
||||||
} catch (e: RuntimeException) {
|
} catch (e: RuntimeException) {
|
||||||
if (retryCountForDataToLoad > 0) {
|
if (retryCountForDataToLoad > 0) {
|
||||||
retryCountForDataToLoad--
|
retryCountForDataToLoad--
|
||||||
@ -77,10 +75,6 @@ class DownloadRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scrollToAlpineWikiZim() {
|
|
||||||
onView(withId(R.id.libraryList)).perform(scrollToPosition<ViewHolder>(20))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun checkIfZimFileDownloaded() {
|
fun checkIfZimFileDownloaded() {
|
||||||
isVisible(Text(zimFileTitle))
|
isVisible(Text(zimFileTitle))
|
||||||
}
|
}
|
||||||
|
@ -73,17 +73,17 @@ class DownloadTest : BaseActivityTest() {
|
|||||||
deleteZimIfExists()
|
deleteZimIfExists()
|
||||||
clickDownloadOnBottomNav()
|
clickDownloadOnBottomNav()
|
||||||
waitForDataToLoad()
|
waitForDataToLoad()
|
||||||
scrollToAlpineWikiZim()
|
|
||||||
downloadZimFile()
|
downloadZimFile()
|
||||||
assertDownloadStart()
|
assertDownloadStart()
|
||||||
waitUntilDownloadComplete()
|
waitUntilDownloadComplete()
|
||||||
clickLibraryOnBottomNav()
|
clickLibraryOnBottomNav()
|
||||||
checkIfZimFileDownloaded()
|
checkIfZimFileDownloaded()
|
||||||
|
deleteZimIfExists()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Assert.fail(
|
Assert.fail(
|
||||||
"""
|
"""
|
||||||
Couldn't find downloaded file 'A little question a day'
|
Couldn't find downloaded file 'Off the Grid'
|
||||||
Original Exception:
|
Original Exception:
|
||||||
${e.localizedMessage}
|
${e.localizedMessage}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user