From 595d73f5688ead2333b2ae12b3fd1543ac60ef3c Mon Sep 17 00:00:00 2001 From: Sean Mac Gillicuddy Date: Wed, 18 Dec 2019 11:39:41 +0000 Subject: [PATCH] #1593 Move CI from Travis to GitHub Action - clean wait usage --- .../java/org/kiwix/kiwixmobile/BaseRobot.kt | 12 +++++++----- .../java/org/kiwix/kiwixmobile/intro/IntroRobot.kt | 8 +++++--- .../kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt index ee61eef7b..baeb76b27 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/BaseRobot.kt @@ -30,7 +30,9 @@ import org.kiwix.kiwixmobile.Findable.StringId.ContentDesc import org.kiwix.kiwixmobile.Findable.Text 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( private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation(), @@ -50,7 +52,7 @@ abstract class BaseRobot( 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)) protected fun UiObject2.swipeLeft() { @@ -61,7 +63,7 @@ abstract class BaseRobot( 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() } @@ -70,7 +72,7 @@ abstract class BaseRobot( } protected fun clickOnTab(textId: Int) { - clickOn(ContentDesc(textId), 20_000L) + clickOn(ContentDesc(textId), LONG_WAIT) } protected fun waitFor(milliseconds: Long) { @@ -79,7 +81,7 @@ abstract class BaseRobot( private fun waitFor( findable: Findable, - timeout: Long = WAIT_TIMEOUT_MS + timeout: Long = DEFAULT_WAIT ): UiObject2? = uiDevice.wait(Until.findObject(findable.selector(this)), timeout) diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt index 68cc86fb5..1323468fa 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/intro/IntroRobot.kt @@ -23,7 +23,9 @@ import attempt import org.kiwix.kiwixmobile.BaseRobot import org.kiwix.kiwixmobile.Findable.StringId.TextId import org.kiwix.kiwixmobile.Findable.ViewId +import org.kiwix.kiwixmobile.LONG_WAIT import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.VERY_LONG_WAIT import org.kiwix.kiwixmobile.main.MainRobot import org.kiwix.kiwixmobile.main.main @@ -35,7 +37,7 @@ class IntroRobot : BaseRobot() { private val viewPager = ViewId(R.id.view_pager) init { - isVisible(getStarted, 20_000L) + isVisible(getStarted, LONG_WAIT) } fun swipeLeft() { @@ -49,8 +51,8 @@ class IntroRobot : BaseRobot() { fun swipeRight() { attempt(10) { isVisible(viewPager).swipeRight() - isVisible(TextId(R.string.welcome_to_the_family), 40_000L) - isVisible(TextId(R.string.human_kind_knowledge), 40_000L) + isVisible(TextId(R.string.welcome_to_the_family), VERY_LONG_WAIT) + isVisible(TextId(R.string.human_kind_knowledge), VERY_LONG_WAIT) } } diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt index e947fe365..25f68185a 100644 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/zim_manager/ZimManageRobot.kt @@ -22,7 +22,9 @@ import org.kiwix.kiwixmobile.BaseRobot import org.kiwix.kiwixmobile.Findable.StringId.TextId import org.kiwix.kiwixmobile.Findable.Text import org.kiwix.kiwixmobile.Findable.ViewId +import org.kiwix.kiwixmobile.LONG_WAIT import org.kiwix.kiwixmobile.R +import org.kiwix.kiwixmobile.VERY_LONG_WAIT import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book import org.kiwix.kiwixmobile.language.LanguageRobot import org.kiwix.kiwixmobile.language.language @@ -32,7 +34,7 @@ fun zimManage(func: ZimManageRobot.() -> Unit) = class ZimManageRobot : BaseRobot() { init { - isVisible(ViewId(R.id.manageViewPager), 40_000L) + isVisible(ViewId(R.id.manageViewPager), VERY_LONG_WAIT) } fun clickOnOnline(func: LibraryRobot.() -> Unit): LibraryRobot { @@ -67,7 +69,7 @@ class ZimManageRobot : BaseRobot() { } fun clickOnSearch() { - clickOn(ViewId(R.id.action_search), 20_000L) + clickOn(ViewId(R.id.action_search), LONG_WAIT) } fun searchFor(book: Book) { @@ -75,7 +77,7 @@ class ZimManageRobot : BaseRobot() { } 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() { - clickOn(ViewId(R.id.stop), 20_000L) + clickOn(ViewId(R.id.stop), LONG_WAIT) } fun waitForEmptyView() {