@ -6,24 +6,17 @@
package org.mozilla.fenix.ui.robots
package org.mozilla.fenix.ui.robots
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.action.ViewActions.swipeUp
import androidx.test.espresso.action.ViewActions.swipeUp
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.RootMatchers
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
@ -35,10 +28,9 @@ import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import androidx.test.uiautomator.Until
import org.hamcrest.Matcher
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.allOf
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assert.assertTrue
import org.mozilla.fenix.FeatureFlags
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
@ -48,6 +40,7 @@ import org.mozilla.fenix.share.ShareFragment
/ * *
/ * *
* Implementation of Robot Pattern for the three dot ( main ) menu .
* Implementation of Robot Pattern for the three dot ( main ) menu .
* /
* /
@Suppress ( " ForbiddenComment " )
class ThreeDotMenuMainRobot {
class ThreeDotMenuMainRobot {
fun verifyTabSettingsButton ( ) = assertTabSettingsButton ( )
fun verifyTabSettingsButton ( ) = assertTabSettingsButton ( )
fun verifyRecentlyClosedTabsButton ( ) = assertRecentlyClosedTabsButton ( )
fun verifyRecentlyClosedTabsButton ( ) = assertRecentlyClosedTabsButton ( )
@ -58,6 +51,7 @@ class ThreeDotMenuMainRobot {
fun verifyHistoryButton ( ) = assertHistoryButton ( )
fun verifyHistoryButton ( ) = assertHistoryButton ( )
fun verifyBookmarksButton ( ) = assertBookmarksButton ( )
fun verifyBookmarksButton ( ) = assertBookmarksButton ( )
fun verifySyncedTabsButton ( ) = assertSyncedTabsButton ( )
fun verifySyncedTabsButton ( ) = assertSyncedTabsButton ( )
fun verifySyncSignInButton ( ) = assertSignInToSyncButton ( )
fun verifyHelpButton ( ) = assertHelpButton ( )
fun verifyHelpButton ( ) = assertHelpButton ( )
fun verifyThreeDotMenuExists ( ) = threeDotMenuRecyclerViewExists ( )
fun verifyThreeDotMenuExists ( ) = threeDotMenuRecyclerViewExists ( )
fun verifyForwardButton ( ) = assertForwardButton ( )
fun verifyForwardButton ( ) = assertForwardButton ( )
@ -68,7 +62,16 @@ class ThreeDotMenuMainRobot {
fun verifyShareButton ( ) = assertShareButton ( )
fun verifyShareButton ( ) = assertShareButton ( )
fun verifyReaderViewAppearance ( visible : Boolean ) = assertReaderViewAppearanceButton ( visible )
fun verifyReaderViewAppearance ( visible : Boolean ) = assertReaderViewAppearanceButton ( visible )
fun expandMenu ( ) {
onView ( withId ( R . id . mozac _browser _menu _menuView ) ) . perform ( swipeUp ( ) )
}
fun clickShareButton ( ) {
fun clickShareButton ( ) {
var maxSwipes = 3
while ( ! shareButton ( ) . exists ( ) && maxSwipes != 0 ) {
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
maxSwipes --
}
shareButton ( ) . click ( )
shareButton ( ) . click ( )
mDevice . waitNotNull ( Until . findObject ( By . text ( " ALL ACTIONS " ) ) , waitingTime )
mDevice . waitNotNull ( Until . findObject ( By . text ( " ALL ACTIONS " ) ) , waitingTime )
}
}
@ -85,74 +88,42 @@ class ThreeDotMenuMainRobot {
addNewCollectionButton ( ) . click ( )
addNewCollectionButton ( ) . click ( )
}
}
fun clickAddBookmarkButton ( ) {
mDevice . waitNotNull (
Until . findObject ( By . desc ( " Bookmark " ) ) ,
waitingTime
)
addBookmarkButton ( ) . perform (
click (
/ * no - op rollback action for when clicks randomly perform a long click , Espresso should attempt to click again
https : //issuetracker.google.com/issues/37078920#comment9
* /
object : ViewAction {
override fun getDescription ( ) : String {
return " Handle tap->longclick. "
}
override fun getConstraints ( ) : Matcher < View > {
return isAssignableFrom ( View :: class . java )
}
override fun perform ( uiController : UiController ? , view : View ? ) {
// do nothing
}
}
)
)
}
fun verifyCollectionNameTextField ( ) = assertCollectionNameTextField ( )
fun verifyCollectionNameTextField ( ) = assertCollectionNameTextField ( )
fun verifyFindInPageButton ( ) = assertFindInPageButton ( )
fun verifyFindInPageButton ( ) = assertFindInPageButton ( )
fun verifyShareScrim ( ) = assertShareScrim ( )
fun verifyShareScrim ( ) = assertShareScrim ( )
fun verifySendToDeviceTitle ( ) = assertSendToDeviceTitle ( )
fun verifySendToDeviceTitle ( ) = assertSendToDeviceTitle ( )
fun verifyShareALinkTitle ( ) = assertShareALinkTitle ( )
fun verifyShareALinkTitle ( ) = assertShareALinkTitle ( )
fun verifyWhatsNewButton ( ) = assertWhatsNewButton ( )
fun verifyWhatsNewButton ( ) = assertWhatsNewButton ( )
fun verifyAdd FirefoxHome( ) = assertAddToFirefoxHome ( )
fun verifyAddToTopSitesButton ( ) = assertAddToTopSitesButton ( )
fun verifyAddToMobileHome ( ) = assertAddToMobileHome ( )
fun verifyAddToMobileHome ( ) = assertAddToMobileHome ( )
fun verifyDesktopSite ( ) = assertDesktopSite ( )
fun verifyDesktopSite ( ) = assertDesktopSite ( )
fun verifyDownloadsButton ( ) = assertDownloadsButton ( )
fun verifyDownloadsButton ( ) = assertDownloadsButton ( )
fun verifyShareTabsOverlay ( ) = assertShareTabsOverlay ( )
fun verifyShareTabsOverlay ( ) = assertShareTabsOverlay ( )
fun verifySignInToSyncButton ( ) = assertSignInToSyncButton ( )
fun verifyNewTabButton ( ) = assertNewTabButton ( )
fun verifyReportSiteIssueButton ( ) = assertReportSiteIssueButton ( )
fun verifyThreeDotMainMenuItems ( ) {
fun verifyPageThreeDotMainMenuItems ( ) {
if ( FeatureFlags . toolbarMenuFeature ) {
verifyNewTabButton ( )
verifyDownloadsButton ( )
verifyHistoryButton ( )
verifyBookmarksButton ( )
verifyBookmarksButton ( )
verifySettingsButton ( )
verifyAddBookmarkButton ( )
verifyDesktopSite ( )
verifySaveCollection ( )
verifyShareButton ( )
verifyForwardButton ( )
verifyRefreshButton ( )
} else {
verifyAddOnsButton ( )
verifyDownloadsButton ( )
verifyHistoryButton ( )
verifyHistoryButton ( )
verifyBookmarksButton ( )
verifyDownloadsButton ( )
verifySyncedTabsButton ( )
verifyAddOnsButton ( )
verifySettingsButton ( )
verifySignInToSyncButton ( )
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
verifyFindInPageButton ( )
verifyFindInPageButton ( )
verifyAddFirefoxHome ( )
verifyAddToMobileHome ( )
verifyDesktopSite ( )
verifyDesktopSite ( )
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
verifyReportSiteIssueButton ( )
verifyAddToTopSitesButton ( )
verifyAddToMobileHome ( )
verifySaveCollection ( )
verifySaveCollection ( )
verifyAddBookmarkButton ( )
verifySettings Button( )
verifyShareButton ( )
verifyShareButton ( )
verifyForwardButton ( )
verifyForwardButton ( )
verifyRefreshButton ( )
verifyRefreshButton ( )
}
}
}
private fun assertShareTabsOverlay ( ) {
private fun assertShareTabsOverlay ( ) {
onView ( withId ( R . id . shared _site _list ) ) . check ( matches ( isDisplayed ( ) ) )
onView ( withId ( R . id . shared _site _list ) ) . check ( matches ( isDisplayed ( ) ) )
@ -166,11 +137,12 @@ 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 {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( ViewActions . swipeDown ( ) )
var maxSwipes = 3
onView ( allOf ( withResourceName ( " text " ) , withText ( R . string . browser _menu _settings ) ) )
while ( ! settingsButton ( ) . exists ( ) && maxSwipes != 0 ) {
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
. check ( matches ( isCompletelyDisplayed ( ) ) )
maxSwipes --
. perform ( ViewActions . click ( ) )
}
settingsButton ( ) . click ( )
SettingsRobot ( ) . interact ( )
SettingsRobot ( ) . interact ( )
return SettingsRobot . Transition ( )
return SettingsRobot . Transition ( )
@ -185,7 +157,7 @@ class ThreeDotMenuMainRobot {
}
}
fun openSyncedTabs ( interact : SyncedTabsRobot . ( ) -> Unit ) : SyncedTabsRobot . Transition {
fun openSyncedTabs ( interact : SyncedTabsRobot . ( ) -> Unit ) : SyncedTabsRobot . Transition {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( ViewActions . swipeDown ( ) )
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( swipeDown ( ) )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Synced tabs " ) ) , waitingTime )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Synced tabs " ) ) , waitingTime )
syncedTabsButton ( ) . click ( )
syncedTabsButton ( ) . click ( )
@ -193,6 +165,15 @@ class ThreeDotMenuMainRobot {
return SyncedTabsRobot . Transition ( )
return SyncedTabsRobot . Transition ( )
}
}
fun openSyncSignIn ( interact : SyncSignInRobot . ( ) -> Unit ) : SyncSignInRobot . Transition {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( swipeDown ( ) )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Sign in to sync " ) ) , waitingTime )
signInToSyncButton ( ) . click ( )
SyncSignInRobot ( ) . interact ( )
return SyncSignInRobot . Transition ( )
}
fun openBookmarks ( interact : BookmarksRobot . ( ) -> Unit ) : BookmarksRobot . Transition {
fun openBookmarks ( interact : BookmarksRobot . ( ) -> Unit ) : BookmarksRobot . Transition {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( swipeDown ( ) )
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( swipeDown ( ) )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Bookmarks " ) ) , waitingTime )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Bookmarks " ) ) , waitingTime )
@ -205,7 +186,7 @@ class ThreeDotMenuMainRobot {
}
}
fun openHistory ( interact : HistoryRobot . ( ) -> Unit ) : HistoryRobot . Transition {
fun openHistory ( interact : HistoryRobot . ( ) -> Unit ) : HistoryRobot . Transition {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( ViewActions . swipeDown ( ) )
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( swipeDown ( ) )
mDevice . waitNotNull ( Until . findObject ( By . text ( " History " ) ) , waitingTime )
mDevice . waitNotNull ( Until . findObject ( By . text ( " History " ) ) , waitingTime )
historyButton ( ) . click ( )
historyButton ( ) . click ( )
@ -214,7 +195,7 @@ class ThreeDotMenuMainRobot {
}
}
fun bookmarkPage ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
fun bookmarkPage ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
mDevice . waitNotNull ( Until . findObject ( By . desc( " Bookmark " ) ) , waitingTime )
mDevice . waitNotNull ( Until . findObject ( By . text( " Bookmarks " ) ) , waitingTime )
addBookmarkButton ( ) . click ( )
addBookmarkButton ( ) . click ( )
BrowserRobot ( ) . interact ( )
BrowserRobot ( ) . interact ( )
@ -222,10 +203,7 @@ class ThreeDotMenuMainRobot {
}
}
fun sharePage ( interact : LibrarySubMenusMultipleSelectionToolbarRobot . ( ) -> Unit ) : LibrarySubMenusMultipleSelectionToolbarRobot . Transition {
fun sharePage ( interact : LibrarySubMenusMultipleSelectionToolbarRobot . ( ) -> Unit ) : LibrarySubMenusMultipleSelectionToolbarRobot . Transition {
mDevice . waitNotNull ( Until . findObject ( By . desc ( " Share " ) ) , waitingTime )
shareButton ( ) . click ( )
shareButton ( ) . click ( )
pressBack ( )
LibrarySubMenusMultipleSelectionToolbarRobot ( ) . interact ( )
LibrarySubMenusMultipleSelectionToolbarRobot ( ) . interact ( )
return LibrarySubMenusMultipleSelectionToolbarRobot . Transition ( )
return LibrarySubMenusMultipleSelectionToolbarRobot . Transition ( )
}
}
@ -239,7 +217,6 @@ class ThreeDotMenuMainRobot {
}
}
fun goForward ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
fun goForward ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
mDevice . waitNotNull ( Until . findObject ( By . desc ( " Forward " ) ) , waitingTime )
forwardButton ( ) . click ( )
forwardButton ( ) . click ( )
BrowserRobot ( ) . interact ( )
BrowserRobot ( ) . interact ( )
@ -273,7 +250,7 @@ class ThreeDotMenuMainRobot {
}
}
fun refreshPage ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
fun refreshPage ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
mDevice. waitNotNull ( Until . findObject ( By . desc ( " Refresh " ) ) , waitingTime )
assertRefreshButton( )
refreshButton ( ) . click ( )
refreshButton ( ) . click ( )
BrowserRobot ( ) . interact ( )
BrowserRobot ( ) . interact ( )
@ -303,7 +280,7 @@ class ThreeDotMenuMainRobot {
}
}
fun openFindInPage ( interact : FindInPageRobot . ( ) -> Unit ) : FindInPageRobot . Transition {
fun openFindInPage ( interact : FindInPageRobot . ( ) -> Unit ) : FindInPageRobot . Transition {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( ViewActions . swipeDown ( ) )
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) ) . perform ( swipeDown ( ) )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Find in page " ) ) , waitingTime )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Find in page " ) ) , waitingTime )
findInPageButton ( ) . click ( )
findInPageButton ( ) . click ( )
@ -340,6 +317,11 @@ class ThreeDotMenuMainRobot {
}
}
fun openReaderViewAppearance ( interact : ReaderViewRobot . ( ) -> Unit ) : ReaderViewRobot . Transition {
fun openReaderViewAppearance ( interact : ReaderViewRobot . ( ) -> Unit ) : ReaderViewRobot . Transition {
var maxSwipes = 3
while ( ! readerViewAppearanceToggle ( ) . exists ( ) && maxSwipes != 0 ) {
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
maxSwipes --
}
readerViewAppearanceToggle ( ) . click ( )
readerViewAppearanceToggle ( ) . click ( )
ReaderViewRobot ( ) . interact ( )
ReaderViewRobot ( ) . interact ( )
@ -347,7 +329,7 @@ class ThreeDotMenuMainRobot {
}
}
fun addToFirefoxHome ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
fun addToFirefoxHome ( interact : BrowserRobot . ( ) -> Unit ) : BrowserRobot . Transition {
addTo FirefoxHome Button( ) . click ( )
addTo TopSites Button( ) . click ( )
BrowserRobot ( ) . interact ( )
BrowserRobot ( ) . interact ( )
return BrowserRobot . Transition ( )
return BrowserRobot . Transition ( )
@ -362,6 +344,11 @@ class ThreeDotMenuMainRobot {
}
}
fun clickInstall ( interact : AddToHomeScreenRobot . ( ) -> Unit ) : AddToHomeScreenRobot . Transition {
fun clickInstall ( interact : AddToHomeScreenRobot . ( ) -> Unit ) : AddToHomeScreenRobot . Transition {
var maxSwipes = 3
while ( !in stallPWAButton ( ) . exists ( ) && maxSwipes != 0 ) {
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
maxSwipes --
}
installPWAButton ( ) . click ( )
installPWAButton ( ) . click ( )
AddToHomeScreenRobot ( ) . interact ( )
AddToHomeScreenRobot ( ) . interact ( )
@ -377,6 +364,11 @@ class ThreeDotMenuMainRobot {
}
}
fun openSaveToCollection ( interact : ThreeDotMenuMainRobot . ( ) -> Unit ) : ThreeDotMenuMainRobot . Transition {
fun openSaveToCollection ( interact : ThreeDotMenuMainRobot . ( ) -> Unit ) : ThreeDotMenuMainRobot . Transition {
// Ensure the menu is expanded and fully scrolled to the bottom.
for ( i in 0. . 3 ) {
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
}
mDevice . waitNotNull ( Until . findObject ( By . text ( " Save to collection " ) ) , waitingTime )
mDevice . waitNotNull ( Until . findObject ( By . text ( " Save to collection " ) ) , waitingTime )
saveCollectionButton ( ) . click ( )
saveCollectionButton ( ) . click ( )
ThreeDotMenuMainRobot ( ) . interact ( )
ThreeDotMenuMainRobot ( ) . interact ( )
@ -401,18 +393,17 @@ class ThreeDotMenuMainRobot {
}
}
}
}
}
}
private fun threeDotMenuRecyclerView ( ) =
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) )
private fun threeDotMenuRecyclerViewExists ( ) {
private fun threeDotMenuRecyclerViewExists ( ) {
onView( withId ( R . id . mozac _browser _menu _recyclerView ) ) . check ( matches ( isDisplayed ( ) ) )
threeDotMenuRecyclerView( ) . check ( matches ( isDisplayed ( ) ) )
}
}
private fun settingsButton ( ) = onView ( allOf ( withResourceName ( " text " ) , withText ( R . string . browser _menu _settings ) ) )
private fun settingsButton ( ) = mDevice . findObject ( UiSelector ( ) . text ( " Settings " ) )
private fun assertSettingsButton ( ) = settingsButton ( )
private fun assertSettingsButton ( ) = assertTrue ( settingsButton ( ) . waitForExists ( waitingTime ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
. check ( matches ( isCompletelyDisplayed ( ) ) )
private val addOnsText = if ( FeatureFlags . toolbarMenuFeature ) " Extensions " else " Add-ons "
private fun addOnsButton ( ) = onView ( allOf ( withText ( " Add-ons " ) ) )
private fun addOnsButton ( ) = onView ( allOf ( withText ( addOnsText ) ) )
private fun assertAddOnsButton ( ) {
private fun assertAddOnsButton ( ) {
onView ( withId ( R . id . mozac _browser _menu _menuView ) ) . perform ( swipeDown ( ) )
onView ( withId ( R . id . mozac _browser _menu _menuView ) ) . perform ( swipeDown ( ) )
addOnsButton ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
addOnsButton ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
@ -430,27 +421,28 @@ private fun syncedTabsButton() = onView(allOf(withText(R.string.library_synced_t
private fun assertSyncedTabsButton ( ) = syncedTabsButton ( )
private fun assertSyncedTabsButton ( ) = syncedTabsButton ( )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
private fun signInToSyncButton ( ) = onView ( withText ( " Sign in to sync " ) )
private fun assertSignInToSyncButton ( ) = signInToSyncButton ( ) . check ( matches ( isDisplayed ( ) ) )
private fun helpButton ( ) = onView ( allOf ( withText ( R . string . browser _menu _help ) ) )
private fun helpButton ( ) = onView ( allOf ( withText ( R . string . browser _menu _help ) ) )
private fun assertHelpButton ( ) = helpButton ( )
private fun assertHelpButton ( ) = helpButton ( )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
private fun forwardButton ( ) = onView ( ViewMatchers . withContentDescription ( " Forward " ) )
private fun forwardButton ( ) = mDevice . findObject ( UiSelector ( ) . description ( " Forward " ) )
private fun assertForwardButton ( ) = forwardButton ( )
private fun assertForwardButton ( ) = assertTrue ( forwardButton ( ) . waitForExists ( waitingTime ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
private fun addBookmarkButton ( ) = onView ( ViewMatchers . withContentDescription ( " Bookmark " ) )
private fun addBookmarkButton ( ) = onView ( allOf ( withId ( R . id . checkbox ) , withText ( " Add " ) ) )
private fun assertAddBookmarkButton ( ) {
private fun assertAddBookmarkButton ( ) {
onView ( withId ( R . id . mozac _browser _menu _menuView ) ) . perform ( swipeUp ( ) )
onView ( withId ( R . id . mozac _browser _menu _menuView ) ) . perform ( swipeUp ( ) )
addBookmarkButton ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
addBookmarkButton ( ) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
}
}
private fun editBookmarkButton ( ) = onView ( ViewMatchers . withContentDescription ( " Edit bookmark " ) )
private fun editBookmarkButton ( ) = onView ( withText ( " Edit " ) )
private fun assertEditBookmarkButton ( ) = editBookmarkButton ( )
private fun assertEditBookmarkButton ( ) = editBookmarkButton ( )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
private fun refreshButton ( ) = onView ( ViewMatchers . withContentDescription ( " Refresh " ) )
private fun refreshButton ( ) = mDevice . findObject ( UiSelector ( ) . description ( " Refresh " ) )
private fun assertRefreshButton ( ) = refreshButton ( )
private fun assertRefreshButton ( ) = assertTrue ( refreshButton ( ) . waitForExists ( waitingTime ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
private fun stopLoadingButton ( ) = onView ( ViewMatchers . withContentDescription ( " Stop " ) )
private fun stopLoadingButton ( ) = onView ( ViewMatchers . withContentDescription ( " Stop " ) )
@ -462,14 +454,13 @@ private fun shareTabButton() = onView(allOf(withText("Share all tabs"))).inRoot(
private fun assertShareTabButton ( ) = shareTabButton ( )
private fun assertShareTabButton ( ) = shareTabButton ( )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
private fun shareButton ( ) = onView ( ViewMatchers . withContentDescription ( " Share " ) )
private fun shareButton ( ) = mDevice . findObject ( UiSelector ( ) . description ( " Share " ) )
private fun assertShareButton ( ) = shareButton ( )
private fun assertShareButton ( ) = assertTrue ( shareButton ( ) . waitForExists ( waitingTime ) )
. check ( matches ( withEffectiveVisibility ( ViewMatchers . Visibility . VISIBLE ) ) )
private fun browserViewSaveCollectionButton ( ) = onView (
private fun browserViewSaveCollectionButton ( ) = onView (
allOf (
allOf (
withText ( " Save to collection " ) ,
withText ( " Save to collection " ) ,
withEffectiveVisibility ( Vi ewMatchers. Vi sibility. VISIBLE )
withEffectiveVisibility ( Vi sibility. VISIBLE )
)
)
)
)
@ -492,11 +483,14 @@ private fun assertCollectionNameTextField() = collectionNameTextField()
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
. check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
private fun reportSiteIssueButton ( ) = onView ( withText ( " Report Site Issue… " ) )
private fun reportSiteIssueButton ( ) = onView ( withText ( " Report Site Issue… " ) )
private fun assertReportSiteIssueButton ( ) = reportSiteIssueButton ( ) . check ( matches ( isDisplayed ( ) ) )
private fun findInPageButton ( ) = onView ( allOf ( withText ( " Find in page " ) ) )
private fun findInPageButton ( ) = onView ( allOf ( withText ( " Find in page " ) ) )
private fun assertFindInPageButton ( ) = findInPageButton ( )
private fun assertFindInPageButton ( ) = findInPageButton ( )
private fun shareScrim ( ) = onView ( withResourceName ( " closeSharingScrim " ) )
private fun shareScrim ( ) = onView ( withResourceName ( " closeSharingScrim " ) )
private fun assertShareScrim ( ) =
private fun assertShareScrim ( ) =
shareScrim ( ) . check ( matches ( ViewMatchers . withAlpha ( ShareFragment . SHOW _PAGE _ALPHA ) ) )
shareScrim ( ) . check ( matches ( ViewMatchers . withAlpha ( ShareFragment . SHOW _PAGE _ALPHA ) ) )
@ -524,17 +518,29 @@ private fun assertWhatsNewButton() = whatsNewButton()
private fun addToHomeScreenButton ( ) = onView ( withText ( " Add to Home screen " ) )
private fun addToHomeScreenButton ( ) = onView ( withText ( " Add to Home screen " ) )
private fun readerViewAppearanceToggle ( ) =
private fun readerViewAppearanceToggle ( ) =
onView( allOf ( withText ( R . string . browser _menu _read _appearance ) ) )
mDevice. findObject ( UiSelector ( ) . text ( " Customize reader view " ) )
private fun assertReaderViewAppearanceButton ( visible : Boolean ) = readerViewAppearanceToggle ( )
private fun assertReaderViewAppearanceButton ( visible : Boolean ) {
. check (
var maxSwipes = 3
if ( visible ) matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) else ViewAssertions . doesNotExist ( )
if ( visible ) {
)
while ( ! readerViewAppearanceToggle ( ) . exists ( ) && maxSwipes != 0 ) {
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
maxSwipes --
}
assertTrue ( readerViewAppearanceToggle ( ) . exists ( ) )
} else {
while ( ! readerViewAppearanceToggle ( ) . exists ( ) && maxSwipes != 0 ) {
threeDotMenuRecyclerView ( ) . perform ( swipeUp ( ) )
maxSwipes --
}
assertFalse ( readerViewAppearanceToggle ( ) . exists ( ) )
}
}
private fun addToFirefoxHomeButton ( ) =
private fun addTo TopSites Button( ) =
onView ( allOf ( withText ( R . string . browser _menu _add _to _top _sites ) ) )
onView ( allOf ( withText ( R . string . browser _menu _add _to _top _sites ) ) )
private fun assertAddToFirefoxHome ( ) {
private fun assertAddTo TopSitesButton ( ) {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) )
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) )
. perform (
. perform (
RecyclerViewActions . scrollTo < RecyclerView . ViewHolder > (
RecyclerViewActions . scrollTo < RecyclerView . ViewHolder > (
@ -545,6 +551,7 @@ private fun assertAddToFirefoxHome() {
private fun addToMobileHomeButton ( ) =
private fun addToMobileHomeButton ( ) =
onView ( allOf ( withText ( R . string . browser _menu _add _to _homescreen ) ) )
onView ( allOf ( withText ( R . string . browser _menu _add _to _homescreen ) ) )
private fun assertAddToMobileHome ( ) {
private fun assertAddToMobileHome ( ) {
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) )
onView ( withId ( R . id . mozac _browser _menu _recyclerView ) )
. perform (
. perform (
@ -554,7 +561,7 @@ private fun assertAddToMobileHome() {
) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
) . check ( matches ( withEffectiveVisibility ( Visibility . VISIBLE ) ) )
}
}
private fun installPWAButton ( ) = onView( allOf ( withId ( R . id . highlight _text ) , withT ext( " Install " ) ) )
private fun installPWAButton ( ) = mDevice. findObject ( UiSelector ( ) . t ext( " Install " ) )
private fun desktopSiteButton ( ) =
private fun desktopSiteButton ( ) =
onView ( allOf ( withText ( R . string . browser _menu _desktop _site ) ) )
onView ( allOf ( withText ( R . string . browser _menu _desktop _site ) ) )
@ -602,3 +609,5 @@ private fun assertShareAllTabsButton() {
. check (
. check (
matches ( isDisplayed ( ) ) )
matches ( isDisplayed ( ) ) )
}
}
private fun assertNewTabButton ( ) = onView ( withText ( " New tab " ) ) . check ( matches ( isDisplayed ( ) ) )