mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-24 05:04:50 -04:00
#1593 Move CI from Travis to GitHub Action - clean wait usage
This commit is contained in:
parent
fd6ae39763
commit
595d73f568
@ -30,7 +30,9 @@ import org.kiwix.kiwixmobile.Findable.StringId.ContentDesc
|
|||||||
import org.kiwix.kiwixmobile.Findable.Text
|
import org.kiwix.kiwixmobile.Findable.Text
|
||||||
import org.kiwix.kiwixmobile.Findable.ViewId
|
import org.kiwix.kiwixmobile.Findable.ViewId
|
||||||
|
|
||||||
const val WAIT_TIMEOUT_MS = 10_000L
|
const val DEFAULT_WAIT = 10_000L
|
||||||
|
const val LONG_WAIT = 20_000L
|
||||||
|
const val VERY_LONG_WAIT = 40_000L
|
||||||
|
|
||||||
abstract class BaseRobot(
|
abstract class BaseRobot(
|
||||||
private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(),
|
private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(),
|
||||||
@ -50,7 +52,7 @@ abstract class BaseRobot(
|
|||||||
uiDevice.pressBack()
|
uiDevice.pressBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun isVisible(findable: Findable, timeout: Long = WAIT_TIMEOUT_MS) =
|
protected fun isVisible(findable: Findable, timeout: Long = DEFAULT_WAIT) =
|
||||||
waitFor(findable, timeout) ?: throw RuntimeException(findable.errorMessage(this))
|
waitFor(findable, timeout) ?: throw RuntimeException(findable.errorMessage(this))
|
||||||
|
|
||||||
protected fun UiObject2.swipeLeft() {
|
protected fun UiObject2.swipeLeft() {
|
||||||
@ -61,7 +63,7 @@ abstract class BaseRobot(
|
|||||||
customSwipe(Direction.RIGHT)
|
customSwipe(Direction.RIGHT)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun clickOn(findable: Findable, timeout: Long = WAIT_TIMEOUT_MS) {
|
protected fun clickOn(findable: Findable, timeout: Long = DEFAULT_WAIT) {
|
||||||
isVisible(findable, timeout).click()
|
isVisible(findable, timeout).click()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +72,7 @@ abstract class BaseRobot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected fun clickOnTab(textId: Int) {
|
protected fun clickOnTab(textId: Int) {
|
||||||
clickOn(ContentDesc(textId), 20_000L)
|
clickOn(ContentDesc(textId), LONG_WAIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun waitFor(milliseconds: Long) {
|
protected fun waitFor(milliseconds: Long) {
|
||||||
@ -79,7 +81,7 @@ abstract class BaseRobot(
|
|||||||
|
|
||||||
private fun waitFor(
|
private fun waitFor(
|
||||||
findable: Findable,
|
findable: Findable,
|
||||||
timeout: Long = WAIT_TIMEOUT_MS
|
timeout: Long = DEFAULT_WAIT
|
||||||
): UiObject2? =
|
): UiObject2? =
|
||||||
uiDevice.wait(Until.findObject(findable.selector(this)), timeout)
|
uiDevice.wait(Until.findObject(findable.selector(this)), timeout)
|
||||||
|
|
||||||
|
@ -23,7 +23,9 @@ import attempt
|
|||||||
import org.kiwix.kiwixmobile.BaseRobot
|
import org.kiwix.kiwixmobile.BaseRobot
|
||||||
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
||||||
import org.kiwix.kiwixmobile.Findable.ViewId
|
import org.kiwix.kiwixmobile.Findable.ViewId
|
||||||
|
import org.kiwix.kiwixmobile.LONG_WAIT
|
||||||
import org.kiwix.kiwixmobile.R
|
import org.kiwix.kiwixmobile.R
|
||||||
|
import org.kiwix.kiwixmobile.VERY_LONG_WAIT
|
||||||
import org.kiwix.kiwixmobile.main.MainRobot
|
import org.kiwix.kiwixmobile.main.MainRobot
|
||||||
import org.kiwix.kiwixmobile.main.main
|
import org.kiwix.kiwixmobile.main.main
|
||||||
|
|
||||||
@ -35,7 +37,7 @@ class IntroRobot : BaseRobot() {
|
|||||||
private val viewPager = ViewId(R.id.view_pager)
|
private val viewPager = ViewId(R.id.view_pager)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
isVisible(getStarted, 20_000L)
|
isVisible(getStarted, LONG_WAIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun swipeLeft() {
|
fun swipeLeft() {
|
||||||
@ -49,8 +51,8 @@ class IntroRobot : BaseRobot() {
|
|||||||
fun swipeRight() {
|
fun swipeRight() {
|
||||||
attempt(10) {
|
attempt(10) {
|
||||||
isVisible(viewPager).swipeRight()
|
isVisible(viewPager).swipeRight()
|
||||||
isVisible(TextId(R.string.welcome_to_the_family), 40_000L)
|
isVisible(TextId(R.string.welcome_to_the_family), VERY_LONG_WAIT)
|
||||||
isVisible(TextId(R.string.human_kind_knowledge), 40_000L)
|
isVisible(TextId(R.string.human_kind_knowledge), VERY_LONG_WAIT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@ import org.kiwix.kiwixmobile.BaseRobot
|
|||||||
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
import org.kiwix.kiwixmobile.Findable.StringId.TextId
|
||||||
import org.kiwix.kiwixmobile.Findable.Text
|
import org.kiwix.kiwixmobile.Findable.Text
|
||||||
import org.kiwix.kiwixmobile.Findable.ViewId
|
import org.kiwix.kiwixmobile.Findable.ViewId
|
||||||
|
import org.kiwix.kiwixmobile.LONG_WAIT
|
||||||
import org.kiwix.kiwixmobile.R
|
import org.kiwix.kiwixmobile.R
|
||||||
|
import org.kiwix.kiwixmobile.VERY_LONG_WAIT
|
||||||
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
|
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book
|
||||||
import org.kiwix.kiwixmobile.language.LanguageRobot
|
import org.kiwix.kiwixmobile.language.LanguageRobot
|
||||||
import org.kiwix.kiwixmobile.language.language
|
import org.kiwix.kiwixmobile.language.language
|
||||||
@ -32,7 +34,7 @@ fun zimManage(func: ZimManageRobot.() -> Unit) =
|
|||||||
|
|
||||||
class ZimManageRobot : BaseRobot() {
|
class ZimManageRobot : BaseRobot() {
|
||||||
init {
|
init {
|
||||||
isVisible(ViewId(R.id.manageViewPager), 40_000L)
|
isVisible(ViewId(R.id.manageViewPager), VERY_LONG_WAIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnOnline(func: LibraryRobot.() -> Unit): LibraryRobot {
|
fun clickOnOnline(func: LibraryRobot.() -> Unit): LibraryRobot {
|
||||||
@ -67,7 +69,7 @@ class ZimManageRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun clickOnSearch() {
|
fun clickOnSearch() {
|
||||||
clickOn(ViewId(R.id.action_search), 20_000L)
|
clickOn(ViewId(R.id.action_search), LONG_WAIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchFor(book: Book) {
|
fun searchFor(book: Book) {
|
||||||
@ -75,7 +77,7 @@ class ZimManageRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun waitForEmptyView() {
|
fun waitForEmptyView() {
|
||||||
isVisible(ViewId(R.id.libraryErrorText), 40_000L)
|
isVisible(ViewId(R.id.libraryErrorText), VERY_LONG_WAIT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +88,7 @@ class ZimManageRobot : BaseRobot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun clickStop() {
|
fun clickStop() {
|
||||||
clickOn(ViewId(R.id.stop), 20_000L)
|
clickOn(ViewId(R.id.stop), LONG_WAIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun waitForEmptyView() {
|
fun waitForEmptyView() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user