1
0
Fork 0

Closes #6031 - Wrap waits with assert check; adjust timer check (#6084)

See #6031

- Adjust waits with assert check
- Adjusts timer to speed things up
- Test fix and cleanup

fix: review comments

- fixed proper resource name selectors
- re-added waits for slow devices

fix: ktlint
master
Aaron Train 2019-10-23 10:55:19 -04:00 committed by GitHub
parent 885e81699e
commit c677fc6109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 61 additions and 48 deletions

View File

@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit
*/ */
object TestAssetHelper { object TestAssetHelper {
@Suppress("MagicNumber") @Suppress("MagicNumber")
val waitingTime: Long = TimeUnit.SECONDS.toMillis(45) val waitingTime: Long = TimeUnit.SECONDS.toMillis(15)
val waitingTimeShort: Long = TimeUnit.SECONDS.toMillis(1) val waitingTimeShort: Long = TimeUnit.SECONDS.toMillis(1)
data class TestAsset(val url: Uri, val content: String) data class TestAsset(val url: Uri, val content: String)

View File

@ -27,6 +27,7 @@ import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.allOf
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.junit.Assert.assertNotNull
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") @Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
class SyncIntegrationTest { class SyncIntegrationTest {
@ -96,7 +97,7 @@ class SyncIntegrationTest {
} }
fun tapOnContinueButton() { fun tapOnContinueButton() {
val continueButton = mDevice.findObject(By.res("submit-btn")) val continueButton = mDevice.findObject(By.res("org.mozilla.fenix.debug:id/submit-btn"))
continueButton.clickAndWait(Until.newWindow(), TestAssetHelper.waitingTime) continueButton.clickAndWait(Until.newWindow(), TestAssetHelper.waitingTime)
} }
@ -110,7 +111,7 @@ class SyncIntegrationTest {
} }
fun tapOnSignIn() { fun tapOnSignIn() {
mDevice.wait(Until.findObjects(By.text("Sign in")), TestAssetHelper.waitingTimeShort) assertNotNull(mDevice.wait(Until.findObjects(By.text("Sign in")), TestAssetHelper.waitingTimeShort))
// Let's tap on enter, sometimes depending on the device the sign in button is // Let's tap on enter, sometimes depending on the device the sign in button is
// hidden by the keyboard // hidden by the keyboard
mDevice.pressEnter() mDevice.pressEnter()
@ -132,7 +133,7 @@ class SyncIntegrationTest {
} }
fun seeBookmark() { fun seeBookmark() {
mDevice.wait(Until.findObjects(By.text("Bookmark")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObjects(By.text("Bookmark")), TestAssetHelper.waitingTime))
val bookmarkButton = mDevice.findObject(By.text("Bookmark")) val bookmarkButton = mDevice.findObject(By.text("Bookmark"))
bookmarkButton.click() bookmarkButton.click()
} }

View File

@ -5,6 +5,7 @@
package org.mozilla.fenix.ui package org.mozilla.fenix.ui
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import org.junit.Assert.assertNotNull
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.Ignore import org.junit.Ignore
@ -121,7 +122,7 @@ class HomeScreenTest {
homeScreen { homeScreen {
// To deal with the race condition where multiple "add tab" buttons are present, // To deal with the race condition where multiple "add tab" buttons are present,
// we need to wait until previous HomeFragment View objects are gone. // we need to wait until previous HomeFragment View objects are gone.
mDevice.wait(Until.gone(By.text(PRIVATE_SESSION_MESSAGE)), waitingTime) assertNotNull(mDevice.wait(Until.gone(By.text(PRIVATE_SESSION_MESSAGE)), waitingTime))
verifyHomeScreen() verifyHomeScreen()
verifyNavigationToolbar() verifyNavigationToolbar()
verifyHomePrivateBrowsingButton() verifyHomePrivateBrowsingButton()

View File

@ -9,6 +9,7 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import okhttp3.mockwebserver.MockWebServer import okhttp3.mockwebserver.MockWebServer
import org.junit.Assert.assertNotNull
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
@ -74,7 +75,8 @@ class TabbedBrowsingTest {
}.openHomeScreen { } }.openHomeScreen { }
homeScreen { homeScreen {
mDevice.wait(Until.findObject(By.res("R.id.item_tab")), TestAssetHelper.waitingTime) // Timing issue on slow devices on Firebase
assertNotNull(mDevice.wait(Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), TestAssetHelper.waitingTime))
verifyExistingTabList() verifyExistingTabList()
}.openTabsListThreeDotMenu { }.openTabsListThreeDotMenu {
@ -103,7 +105,8 @@ class TabbedBrowsingTest {
verifyPageContent(defaultWebPage.content) verifyPageContent(defaultWebPage.content)
verifyTabCounter("1") verifyTabCounter("1")
}.openHomeScreen { }.openHomeScreen {
mDevice.wait(Until.findObject(By.res("R.id.item_tab")), TestAssetHelper.waitingTime) // Timing issue on slow devices on Firebase
assertNotNull(mDevice.wait(Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), TestAssetHelper.waitingTime))
verifyExistingTabList() verifyExistingTabList()
verifyShareTabsButton(true) verifyShareTabsButton(true)
verifyCloseTabsButton(true) verifyCloseTabsButton(true)
@ -131,7 +134,8 @@ class TabbedBrowsingTest {
}.openHomeScreen { } }.openHomeScreen { }
homeScreen { homeScreen {
mDevice.wait(Until.findObject(By.res("R.id.item_tab")), TestAssetHelper.waitingTime) // Timing issue on slow devices on Firebase
assertNotNull(mDevice.wait(Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), TestAssetHelper.waitingTime))
verifyExistingTabList() verifyExistingTabList()
}.openTabsListThreeDotMenu { }.openTabsListThreeDotMenu {
verifyCloseAllTabsButton() verifyCloseAllTabsButton()

View File

@ -15,6 +15,7 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers.containsString import org.hamcrest.CoreMatchers.containsString
import org.junit.Assert.assertNotNull
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
@ -24,7 +25,7 @@ class BrowserRobot {
fun verifyHelpUrl() { fun verifyHelpUrl() {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val redirectUrl = "https://support.mozilla.org/" val redirectUrl = "https://support.mozilla.org/"
mDevice.wait(Until.findObject(By.res("mozac_browser_toolbar_url_view")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")), TestAssetHelper.waitingTime))
onView(withId(R.id.mozac_browser_toolbar_url_view)) onView(withId(R.id.mozac_browser_toolbar_url_view))
.check(matches(withText(containsString(redirectUrl)))) .check(matches(withText(containsString(redirectUrl))))
} }
@ -32,8 +33,7 @@ class BrowserRobot {
fun verifyWhatsNewURL() { fun verifyWhatsNewURL() {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val redirectUrl = "https://support.mozilla.org/" val redirectUrl = "https://support.mozilla.org/"
assertNotNull(mDevice.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")), TestAssetHelper.waitingTime))
mDevice.wait(Until.findObject(By.res("mozac_browser_toolbar_url_view")), TestAssetHelper.waitingTime)
onView(withId(R.id.mozac_browser_toolbar_url_view)) onView(withId(R.id.mozac_browser_toolbar_url_view))
.check(matches(withText(containsString(redirectUrl)))) .check(matches(withText(containsString(redirectUrl))))
} }
@ -43,7 +43,7 @@ class BrowserRobot {
*/ */
fun verifyPageContent(expectedText: String) { fun verifyPageContent(expectedText: String) {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.wait(Until.findObject(By.res(expectedText)), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text(expectedText)), TestAssetHelper.waitingTime))
} }
fun verifyTabCounter(expectedText: String) { fun verifyTabCounter(expectedText: String) {
@ -67,19 +67,19 @@ class BrowserRobot {
tabsCounter().click() tabsCounter().click()
mDevice.wait( assertNotNull(mDevice.wait(
Until.findObject(By.res("R.id.header_text")), Until.findObject(By.res("org.mozilla.fenix.debug:id/header_text")),
TestAssetHelper.waitingTime TestAssetHelper.waitingTime
) ))
HomeScreenRobot().interact() HomeScreenRobot().interact()
return HomeScreenRobot.Transition() return HomeScreenRobot.Transition()
} }
fun openQuickActionBar(interact: QuickActionBarRobot.() -> Unit): QuickActionBarRobot.Transition { fun openQuickActionBar(interact: QuickActionBarRobot.() -> Unit): QuickActionBarRobot.Transition {
mDevice.wait(Until.gone(By.res("org.mozilla.fenix.nightly:id/quick_action_sheet")), assertNotNull(mDevice.wait(Until.gone(By.res("org.mozilla.fenix.debug:id/quick_action_sheet")),
TestAssetHelper.waitingTime TestAssetHelper.waitingTime
) ))
quickActionBarHandle().click() quickActionBarHandle().click()
QuickActionBarRobot().interact() QuickActionBarRobot().interact()

View File

@ -17,6 +17,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import org.junit.Assert.assertNotNull
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
@ -33,15 +34,15 @@ class FindInPageRobot {
fun verifyFindInPageCloseButton() = assertFindInPageCloseButton()!! fun verifyFindInPageCloseButton() = assertFindInPageCloseButton()!!
fun enterFindInPageQuery(expectedText: String) { fun enterFindInPageQuery(expectedText: String) {
mDevice.wait(Until.findObject(By.res("find_in_page_query_text")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/find_in_page_query_text")), waitingTime))
findInPageQuery().perform(clearText()) findInPageQuery().perform(clearText())
mDevice.wait(Until.gone(By.res("find_in_page_result_text")), waitingTime) assertNotNull(mDevice.wait(Until.gone(By.res("org.mozilla.fenix.debug:id/find_in_page_result_text")), waitingTime))
findInPageQuery().perform(typeText(expectedText)) findInPageQuery().perform(typeText(expectedText))
mDevice.wait(Until.findObject(By.res("find_in_page_result_text")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/find_in_page_result_text")), waitingTime))
} }
fun verifyFindNextInPageResult(ratioCounter: String) { fun verifyFindNextInPageResult(ratioCounter: String) {
mDevice.wait(Until.findObject(By.text(ratioCounter)), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text(ratioCounter)), waitingTime))
val element = mDevice.findObject(By.text(ratioCounter)) val element = mDevice.findObject(By.text(ratioCounter))
findInPageResult().check(matches(withText((ratioCounter)))) findInPageResult().check(matches(withText((ratioCounter))))
findInPageNextButton().click() findInPageNextButton().click()
@ -49,7 +50,7 @@ class FindInPageRobot {
} }
fun verifyFindPrevInPageResult(ratioCounter: String) { fun verifyFindPrevInPageResult(ratioCounter: String) {
mDevice.wait(Until.findObject(By.text(ratioCounter)), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text(ratioCounter)), waitingTime))
val element = mDevice.findObject(By.text(ratioCounter)) val element = mDevice.findObject(By.text(ratioCounter))
findInPageResult().check(matches(withText((ratioCounter)))) findInPageResult().check(matches(withText((ratioCounter))))
findInPagePrevButton().click() findInPagePrevButton().click()

View File

@ -18,6 +18,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.junit.Assert.assertNotNull
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
@ -51,7 +52,7 @@ class LibraryRobot {
} }
fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition { fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
mDevice.wait(Until.findObject(By.text("Bookmarks")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("Bookmarks")), TestAssetHelper.waitingTime))
bookmarksButton().click() bookmarksButton().click()
BookmarksRobot().interact() BookmarksRobot().interact()
@ -59,7 +60,7 @@ class LibraryRobot {
} }
fun openHistory(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition { fun openHistory(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
mDevice.wait(Until.findObject(By.text("History")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("History")), TestAssetHelper.waitingTime))
historyButton().click() historyButton().click()
HistoryRobot().interact() HistoryRobot().interact()

View File

@ -18,6 +18,7 @@ import androidx.test.uiautomator.Until
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
import org.junit.Assert.assertNotNull
/** /**
* Implementation of Robot Pattern for the URL toolbar. * Implementation of Robot Pattern for the URL toolbar.
@ -28,7 +29,7 @@ class NavigationToolbarRobot {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
fun enterURLAndEnterToBrowser(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun enterURLAndEnterToBrowser(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.wait(Until.findObject(By.text("Search or enter address")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/toolbar")), waitingTime))
urlBar().click() urlBar().click()
awesomeBar().perform(replaceText(url.toString()), pressImeActionButton()) awesomeBar().perform(replaceText(url.toString()), pressImeActionButton())
@ -37,7 +38,7 @@ class NavigationToolbarRobot {
} }
fun openThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition { fun openThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
mDevice.wait(Until.findObject(By.text("Menu")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.descContains("Menu")), waitingTime))
threeDotButton().click() threeDotButton().click()
ThreeDotMenuMainRobot().interact() ThreeDotMenuMainRobot().interact()
@ -45,7 +46,7 @@ class NavigationToolbarRobot {
} }
fun openNewTabAndEnterToBrowser(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun openNewTabAndEnterToBrowser(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.wait(Until.findObject(By.descContains("Add tab")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.descContains("Add tab")), waitingTime))
newTab().click() newTab().click()
awesomeBar().perform(replaceText(url.toString()), pressImeActionButton()) awesomeBar().perform(replaceText(url.toString()), pressImeActionButton())

View File

@ -27,6 +27,7 @@ import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.startsWith import org.hamcrest.CoreMatchers.startsWith
import org.hamcrest.Matchers import org.hamcrest.Matchers
import org.junit.Assert.assertNotNull
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
@ -64,7 +65,7 @@ class SearchRobot {
} }
fun clickDuckDuckGoResult() { fun clickDuckDuckGoResult() {
mDevice.wait(Until.findObjects(By.text("DuckDuckGo")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObjects(By.text("DuckDuckGo")), TestAssetHelper.waitingTime))
awesomeBar().perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click())) awesomeBar().perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click()))
} }
@ -100,28 +101,29 @@ private fun awesomeBar() = onView(withId(R.id.awesomeBar))
private fun browserToolbarEditView() = onView(Matchers.allOf(withId(R.id.mozac_browser_toolbar_edit_url_view))) private fun browserToolbarEditView() = onView(Matchers.allOf(withId(R.id.mozac_browser_toolbar_edit_url_view)))
private fun duckDuckGoEngineButton(): ViewInteraction { private fun duckDuckGoEngineButton(): ViewInteraction {
mDevice.wait(Until.findObject(By.text("DuckDuckGo")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("DuckDuckGo")), TestAssetHelper.waitingTime))
return onView(Matchers.allOf(withText("DuckDuckGo"))) return onView(Matchers.allOf(withText("DuckDuckGo")))
} }
private fun denyPermissionButton(): UiObject { private fun denyPermissionButton(): UiObject {
mDevice.wait(Until.findObjects(By.text("Deny")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObjects(By.text("Deny")), TestAssetHelper.waitingTime))
return mDevice.findObject(UiSelector().text("Deny")) return mDevice.findObject(UiSelector().text("Deny"))
} }
private fun allowPermissionButton(): UiObject { private fun allowPermissionButton(): UiObject {
mDevice.wait(Until.findObjects(By.text("Allow")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObjects(By.text("Allow")), TestAssetHelper.waitingTime))
return mDevice.findObject(UiSelector().text("Allow")) return mDevice.findObject(UiSelector().text("Allow"))
} }
private fun scanButton(): ViewInteraction { private fun scanButton(): ViewInteraction {
mDevice.wait(Until.findObject(By.res("R.id.search_scan_button")), TestAssetHelper.waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/search_scan_button")), TestAssetHelper.waitingTime))
return onView(allOf(withId(R.id.searchScanButton))) return onView(allOf(withId(R.id.searchScanButton)))
} }
private fun clearButton() = onView(withId(R.id.mozac_browser_toolbar_clear_view)) private fun clearButton() = onView(withId(R.id.mozac_browser_toolbar_clear_view))
private fun assertDuckDuckGoURL() { private fun assertDuckDuckGoURL() {
assertNotNull(mDevice.wait(Until.findObject(By.textContains("https://duckduckgo.com/?q=mozilla")), TestAssetHelper.waitingTime))
onView(allOf(withText(startsWith("https://duckduckgo.com")))) onView(allOf(withText(startsWith("https://duckduckgo.com"))))
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) .check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
} }

View File

@ -18,6 +18,7 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.allOf
import org.junit.Assert.assertNotNull
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
@ -38,7 +39,7 @@ class ThreeDotMenuMainRobot {
fun verifyShareButton() = assertShareButton() fun verifyShareButton() = assertShareButton()
fun clickShareButton() { fun clickShareButton() {
shareButton().click() shareButton().click()
mDevice.wait(Until.findObject(By.text("SHARE A LINK")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("SHARE A LINK")), waitingTime))
} }
fun verifyShareTabButton() = assertShareTabButton() fun verifyShareTabButton() = assertShareTabButton()
@ -54,7 +55,7 @@ class ThreeDotMenuMainRobot {
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
fun openSettings(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { fun openSettings(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
mDevice.wait(Until.findObject(By.text("R.string.settings")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("Settings")), waitingTime))
settingsButton().click() settingsButton().click()
SettingsRobot().interact() SettingsRobot().interact()
@ -62,7 +63,7 @@ class ThreeDotMenuMainRobot {
} }
fun openLibrary(interact: LibraryRobot.() -> Unit): LibraryRobot.Transition { fun openLibrary(interact: LibraryRobot.() -> Unit): LibraryRobot.Transition {
mDevice.wait(Until.findObject(By.text("R.string.Library")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("Your Library")), waitingTime))
libraryButton().click() libraryButton().click()
LibraryRobot().interact() LibraryRobot().interact()
@ -70,7 +71,7 @@ class ThreeDotMenuMainRobot {
} }
fun openHelp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun openHelp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.wait(Until.findObject(By.text("Help")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("Help")), waitingTime))
helpButton().click() helpButton().click()
BrowserRobot().interact() BrowserRobot().interact()
@ -78,7 +79,7 @@ class ThreeDotMenuMainRobot {
} }
fun goForward(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun goForward(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.wait(Until.findObject(By.desc("Forward")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.desc("Forward")), waitingTime))
forwardButton().click() forwardButton().click()
BrowserRobot().interact() BrowserRobot().interact()
@ -86,7 +87,7 @@ class ThreeDotMenuMainRobot {
} }
fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.wait(Until.findObject(By.desc("Back")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.desc("Back")), waitingTime))
backButton().click() backButton().click()
BrowserRobot().interact() BrowserRobot().interact()
@ -94,7 +95,7 @@ class ThreeDotMenuMainRobot {
} }
fun refreshPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun refreshPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.wait(Until.findObject(By.desc("Refresh")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.desc("Refresh")), waitingTime))
refreshButton().click() refreshButton().click()
BrowserRobot().interact() BrowserRobot().interact()
@ -102,7 +103,7 @@ class ThreeDotMenuMainRobot {
} }
fun closeAllTabs(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { fun closeAllTabs(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
mDevice.wait(Until.findObject(By.text("Close all tabs")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("Close all tabs")), waitingTime))
closeAllTabsButton().click() closeAllTabsButton().click()
HomeScreenRobot().interact() HomeScreenRobot().interact()
@ -110,7 +111,7 @@ class ThreeDotMenuMainRobot {
} }
fun openFindInPage(interact: FindInPageRobot.() -> Unit): FindInPageRobot.Transition { fun openFindInPage(interact: FindInPageRobot.() -> Unit): FindInPageRobot.Transition {
mDevice.wait(Until.findObject(By.text("Find in page")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("Find in page")), waitingTime))
findInPageButton().click() findInPageButton().click()
FindInPageRobot().interact() FindInPageRobot().interact()
@ -118,7 +119,7 @@ class ThreeDotMenuMainRobot {
} }
fun openWhatsNew(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun openWhatsNew(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.wait(Until.findObject(By.text("What's New")), waitingTime) assertNotNull(mDevice.wait(Until.findObject(By.text("What's New")), waitingTime))
whatsNewButton().click() whatsNewButton().click()
BrowserRobot().interact() BrowserRobot().interact()

View File

@ -19,6 +19,7 @@
// import okhttp3.mockwebserver.MockWebServer // import okhttp3.mockwebserver.MockWebServer
// import org.hamcrest.Matchers // import org.hamcrest.Matchers
// import org.junit.After // import org.junit.After
// import org.junit.Assert.assertNotNull
// import org.junit.Before // import org.junit.Before
// import org.junit.Rule // import org.junit.Rule
// import org.junit.Test // import org.junit.Test
@ -167,22 +168,22 @@
// .instance(1) // .instance(1)
// .className(ImageView::class.java)).click() // .className(ImageView::class.java)).click()
// // Homescreen with visited tabs // // Homescreen with visited tabs
// device.wait(Until.findObjects(By.text("Save to collection")), TestAssetHelper.waitingTimeShort) // assertNotNull(device.wait(Until.findObjects(By.text("Save to collection")), TestAssetHelper.waitingTimeShort))
// openTabsMenu() // openTabsMenu()
// Screengrab.screenshot("open-tabs-menu") // Screengrab.screenshot("open-tabs-menu")
// device.pressBack() // device.pressBack()
// device.wait(Until.findObjects(By.text("Save to collection")), TestAssetHelper.waitingTimeShort) // assertNotNull(device.wait(Until.findObjects(By.text("Save to collection")), TestAssetHelper.waitingTimeShort))
// Screengrab.screenshot("save-collection-button") // Screengrab.screenshot("save-collection-button")
// //
// // Save a collection // // Save a collection
// saveToCollectionButton() // saveToCollectionButton()
// Screengrab.screenshot("save-collection-view") // Screengrab.screenshot("save-collection-view")
// device.wait(Until.findObject(By.res("name_collection_edittext")), TestAssetHelper.waitingTimeShort) // assertNotNull(device.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/name_collection_edittext")), TestAssetHelper.waitingTimeShort))
// nameCollectionTextBox().perform(replaceText("CollectionName"), // nameCollectionTextBox().perform(replaceText("CollectionName"),
// pressImeActionButton()) // pressImeActionButton())
// //
// // Homescreen after saving one collection // // Homescreen after saving one collection
// device.wait(Until.findObject(By.res("collection_title")), TestAssetHelper.waitingTimeShort) // assertNotNull(device.wait(Until.findObject(By.res("org.mozilla.fenix.debug:id/collection_title")), TestAssetHelper.waitingTimeShort))
// Screengrab.screenshot("saved-tab") // Screengrab.screenshot("saved-tab")
// //
// // Open Collection menu // // Open Collection menu
@ -196,7 +197,7 @@
// navigationToolbar { // navigationToolbar {
// }.enterURLAndEnterToBrowser(defaultWebPage.url) { // }.enterURLAndEnterToBrowser(defaultWebPage.url) {
// } // }
// device.wait(Until.findObjects(By.res("quick_action_sheet_handle")), TestAssetHelper.waitingTimeShort) // assertNotNull(device.wait(Until.findObjects(By.res("org.mozilla.fenix.debug:id/quick_action_sheet_handle")), TestAssetHelper.waitingTimeShort))
// openQuickActionMenu() // openQuickActionMenu()
// Screengrab.screenshot("browser-tab-share-bookmark") // Screengrab.screenshot("browser-tab-share-bookmark")
// // Open Browser tab menu // // Open Browser tab menu
@ -209,7 +210,7 @@
// device.findObject(UiSelector() // device.findObject(UiSelector()
// .instance(1) // .instance(1)
// .className(ImageView::class.java)).click() // .className(ImageView::class.java)).click()
// device.wait(Until.findObjects(By.res("close_tab_button")), TestAssetHelper.waitingTimeShort) // assertNotNull(device.wait(Until.findObjects(By.res("org.mozilla.fenix.debug:id/close_tab_button")), TestAssetHelper.waitingTimeShort))
// closeTabButton() // closeTabButton()
// Screengrab.screenshot("remove-tab") // Screengrab.screenshot("remove-tab")
// } // }