For #26286 improve homeThreeDotMenuItemsTest UI test coverage and other refactoring work
This commit is contained in:
parent
875a339ee7
commit
78c0b7ec3b
|
@ -21,9 +21,20 @@ object MatcherHelper {
|
|||
fun itemContainingText(itemText: String) =
|
||||
mDevice.findObject(UiSelector().textContains(itemText))
|
||||
|
||||
fun itemWithDescription(description: String) =
|
||||
mDevice.findObject(UiSelector().descriptionContains(description))
|
||||
|
||||
fun checkedItemWithResId(resourceId: String, isChecked: Boolean) =
|
||||
mDevice.findObject(UiSelector().resourceId(resourceId).checked(isChecked))
|
||||
|
||||
fun checkedItemWithResIdAndText(resourceId: String, text: String, isChecked: Boolean) =
|
||||
mDevice.findObject(
|
||||
UiSelector()
|
||||
.resourceId(resourceId)
|
||||
.textContains(text)
|
||||
.checked(isChecked),
|
||||
)
|
||||
|
||||
fun itemWithResIdAndDescription(resourceId: String, description: String) =
|
||||
mDevice.findObject(UiSelector().resourceId(resourceId).descriptionContains(description))
|
||||
|
||||
|
@ -42,12 +53,24 @@ object MatcherHelper {
|
|||
}
|
||||
}
|
||||
|
||||
fun assertItemWithDescriptionExists(vararg appItems: UiObject) {
|
||||
for (appItem in appItems) {
|
||||
assertTrue(appItem.waitForExists(waitingTime))
|
||||
}
|
||||
}
|
||||
|
||||
fun assertCheckedItemWithResIdExists(vararg appItems: UiObject) {
|
||||
for (appItem in appItems) {
|
||||
assertTrue(appItem.waitForExists(waitingTime))
|
||||
}
|
||||
}
|
||||
|
||||
fun assertCheckedItemWithResIdAndTextExists(vararg appItems: UiObject) {
|
||||
for (appItem in appItems) {
|
||||
assertTrue(appItem.waitForExists(waitingTime))
|
||||
}
|
||||
}
|
||||
|
||||
fun assertItemWithResIdAndDescriptionExists(vararg appItems: UiObject) {
|
||||
for (appItem in appItems) {
|
||||
assertTrue(appItem.waitForExists(waitingTime))
|
||||
|
|
|
@ -65,7 +65,7 @@ class NavigationToolbarTest {
|
|||
}.enterURLAndEnterToBrowser(nextWebPage.url) {
|
||||
verifyUrl(nextWebPage.url.toString())
|
||||
}.openThreeDotMenu {
|
||||
}.goBack {
|
||||
}.goToPreviousPage {
|
||||
mDevice.waitForIdle()
|
||||
verifyUrl(defaultWebPage.url.toString())
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class NavigationToolbarTest {
|
|||
mDevice.waitForIdle()
|
||||
verifyUrl(nextWebPage.url.toString())
|
||||
}.openThreeDotMenu {
|
||||
}.goBack {
|
||||
}.goToPreviousPage {
|
||||
mDevice.waitForIdle()
|
||||
verifyUrl(defaultWebPage.url.toString())
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ class SmokeTest {
|
|||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
waitForPageToLoad()
|
||||
}.openThreeDotMenu {
|
||||
verifyPageThreeDotMainMenuItems()
|
||||
verifyPageThreeDotMainMenuItems(isRequestDesktopSiteEnabled = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,50 +44,47 @@ class ThreeDotMenuMainTest {
|
|||
fun homeThreeDotMenuItemsTest() {
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
verifyBookmarksButton()
|
||||
verifyHistoryButton()
|
||||
verifyDownloadsButton()
|
||||
verifyAddOnsButton()
|
||||
// Disabled step due to https://github.com/mozilla-mobile/fenix/issues/26788
|
||||
// verifySyncSignInButton()
|
||||
verifyDesktopSite()
|
||||
verifyWhatsNewButton()
|
||||
verifyHelpButton()
|
||||
verifyCustomizeHomeButton()
|
||||
verifySettingsButton()
|
||||
}.openSettings {
|
||||
verifySettingsView()
|
||||
verifyHomeThreeDotMainMenuItems(isRequestDesktopSiteEnabled = false)
|
||||
}.openBookmarks {
|
||||
verifyBookmarksMenuView()
|
||||
}.goBack {
|
||||
}.openThreeDotMenu {
|
||||
}.openHistory {
|
||||
verifyHistoryMenuView()
|
||||
}.goBack {
|
||||
}.openThreeDotMenu {
|
||||
}.openDownloadsManager {
|
||||
verifyEmptyDownloadsList()
|
||||
}.goBack {
|
||||
}.openThreeDotMenu {
|
||||
}.openAddonsManagerMenu {
|
||||
verifyAddonsItems()
|
||||
}.goBack {
|
||||
}.openThreeDotMenu {
|
||||
}.openSyncSignIn {
|
||||
verifyTurnOnSyncMenu()
|
||||
}.goBack {
|
||||
// Desktop toggle
|
||||
}.openThreeDotMenu {
|
||||
}.switchDesktopSiteMode {
|
||||
}
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
verifyDesktopSiteModeEnabled(isRequestDesktopSiteEnabled = true)
|
||||
}.openWhatsNew {
|
||||
verifyWhatsNewURL()
|
||||
}.goToHomescreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openHelp {
|
||||
verifyHelpUrl()
|
||||
}.goToHomescreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openCustomizeHome {
|
||||
verifyHomePageView()
|
||||
}.goBack {
|
||||
}.openThreeDotMenu {
|
||||
}.openHelp {
|
||||
verifyHelpUrl()
|
||||
}.openTabDrawer {
|
||||
closeTab()
|
||||
}
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openWhatsNew {
|
||||
verifyWhatsNewURL()
|
||||
}.openTabDrawer {
|
||||
closeTab()
|
||||
}
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openBookmarks {
|
||||
verifyBookmarksMenuView()
|
||||
}.closeMenu {
|
||||
}
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openHistory {
|
||||
verifyHistoryMenuView()
|
||||
}.openSettings {
|
||||
verifySettingsView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class TopSitesTest {
|
|||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
}.openThreeDotMenu {
|
||||
expandMenu()
|
||||
verifyAddToTopSitesButton()
|
||||
verifyAddToShortcutsButton()
|
||||
}.addToFirefoxHome {
|
||||
verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts))
|
||||
}.goToHomescreen {
|
||||
|
@ -84,7 +84,7 @@ class TopSitesTest {
|
|||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
}.openThreeDotMenu {
|
||||
expandMenu()
|
||||
verifyAddToTopSitesButton()
|
||||
verifyAddToShortcutsButton()
|
||||
}.addToFirefoxHome {
|
||||
verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts))
|
||||
}.goToHomescreen {
|
||||
|
@ -111,7 +111,7 @@ class TopSitesTest {
|
|||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
}.openThreeDotMenu {
|
||||
expandMenu()
|
||||
verifyAddToTopSitesButton()
|
||||
verifyAddToShortcutsButton()
|
||||
}.addToFirefoxHome {
|
||||
verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts))
|
||||
}.goToHomescreen {
|
||||
|
@ -134,7 +134,7 @@ class TopSitesTest {
|
|||
waitForPageToLoad()
|
||||
}.openThreeDotMenu {
|
||||
expandMenu()
|
||||
verifyAddToTopSitesButton()
|
||||
verifyAddToShortcutsButton()
|
||||
}.addToFirefoxHome {
|
||||
verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts))
|
||||
}.goToHomescreen {
|
||||
|
@ -156,7 +156,7 @@ class TopSitesTest {
|
|||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
}.openThreeDotMenu {
|
||||
expandMenu()
|
||||
verifyAddToTopSitesButton()
|
||||
verifyAddToShortcutsButton()
|
||||
}.addToFirefoxHome {
|
||||
verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts))
|
||||
}.goToHomescreen {
|
||||
|
@ -177,7 +177,7 @@ class TopSitesTest {
|
|||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
}.openThreeDotMenu {
|
||||
expandMenu()
|
||||
verifyAddToTopSitesButton()
|
||||
verifyAddToShortcutsButton()
|
||||
}.addToFirefoxHome {
|
||||
verifySnackBarText(getStringResource(R.string.snackbar_added_to_shortcuts))
|
||||
}.goToHomescreen {
|
||||
|
|
|
@ -258,6 +258,13 @@ class BookmarksRobot {
|
|||
SettingsTurnOnSyncRobot().interact()
|
||||
return SettingsTurnOnSyncRobot.Transition()
|
||||
}
|
||||
|
||||
fun goBack(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
HomeScreenRobot().interact()
|
||||
return HomeScreenRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,13 @@ class DownloadRobot {
|
|||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun goBack(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
HomeScreenRobot().interact()
|
||||
return HomeScreenRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,3 +202,5 @@ private fun assertDownloadedFileIcon() =
|
|||
mDevice.findObject(UiSelector().resourceId("$packageName:id/favicon"))
|
||||
.exists(),
|
||||
)
|
||||
|
||||
private fun goBackButton() = onView(withContentDescription("Navigate up"))
|
||||
|
|
|
@ -53,16 +53,16 @@ import org.mozilla.fenix.R
|
|||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.helpers.Constants.LISTS_MAXSWIPES
|
||||
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertCheckedItemWithResIdExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemContainingTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndDescriptionExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.checkedItemWithResId
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndDescription
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemContainingTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertCheckedItemWithResIdExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndDescriptionExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndTextExists
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort
|
||||
import org.mozilla.fenix.helpers.TestHelper.appContext
|
||||
|
|
|
@ -16,8 +16,6 @@ import androidx.test.espresso.matcher.RootMatchers
|
|||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isChecked
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
|
@ -26,11 +24,18 @@ import androidx.test.uiautomator.By
|
|||
import androidx.test.uiautomator.UiSelector
|
||||
import androidx.test.uiautomator.Until
|
||||
import org.hamcrest.Matchers.allOf
|
||||
import org.hamcrest.Matchers.not
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.Constants.RETRY_COUNT
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertCheckedItemWithResIdAndTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemContainingTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithDescriptionExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.checkedItemWithResIdAndText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong
|
||||
import org.mozilla.fenix.helpers.TestHelper.getStringResource
|
||||
|
@ -45,20 +50,12 @@ import org.mozilla.fenix.helpers.ext.waitNotNull
|
|||
@Suppress("ForbiddenComment")
|
||||
class ThreeDotMenuMainRobot {
|
||||
fun verifyShareAllTabsButton() = assertShareAllTabsButton()
|
||||
fun verifySettingsButton() = assertSettingsButton()
|
||||
fun verifyCustomizeHomeButton() = assertCustomizeHomeButton()
|
||||
fun verifyAddOnsButton() = assertAddOnsButton()
|
||||
fun verifyHistoryButton() = assertHistoryButton()
|
||||
fun verifyBookmarksButton() = assertBookmarksButton()
|
||||
fun verifySyncSignInButton() = assertSyncSignInButton()
|
||||
fun verifyHelpButton() = assertHelpButton()
|
||||
fun verifySettingsButton() = assertItemContainingTextExists(settingsButton())
|
||||
fun verifyHistoryButton() = assertItemContainingTextExists(historyButton)
|
||||
fun verifyThreeDotMenuExists() = threeDotMenuRecyclerViewExists()
|
||||
fun verifyForwardButton() = assertForwardButton()
|
||||
fun verifyAddBookmarkButton() = assertAddBookmarkButton()
|
||||
fun verifyAddBookmarkButton() = assertItemWithResIdAndTextExists(addBookmarkButton)
|
||||
fun verifyEditBookmarkButton() = assertEditBookmarkButton()
|
||||
fun verifyRefreshButton() = assertRefreshButton()
|
||||
fun verifyCloseAllTabsButton() = assertCloseAllTabsButton()
|
||||
fun verifyShareButton() = assertShareButton()
|
||||
fun verifyReaderViewAppearance(visible: Boolean) = assertReaderViewAppearanceButton(visible)
|
||||
|
||||
fun expandMenu() {
|
||||
|
@ -66,49 +63,61 @@ class ThreeDotMenuMainRobot {
|
|||
}
|
||||
|
||||
fun verifyShareTabButton() = assertShareTabButton()
|
||||
fun verifySaveCollection() = assertSaveCollectionButton()
|
||||
fun verifySelectTabs() = assertSelectTabsButton()
|
||||
|
||||
fun verifyFindInPageButton() = assertFindInPageButton()
|
||||
fun verifyWhatsNewButton() = assertWhatsNewButton()
|
||||
fun verifyAddToTopSitesButton() = assertAddToTopSitesButton()
|
||||
fun verifyFindInPageButton() = assertItemContainingTextExists(findInPageButton)
|
||||
fun verifyAddToShortcutsButton() = assertItemContainingTextExists(addToShortcutsButton)
|
||||
fun verifyRemoveFromShortcutsButton() = assertRemoveFromShortcutsButton()
|
||||
fun verifyAddToMobileHome() = assertAddToMobileHome()
|
||||
fun verifyDesktopSite() = assertDesktopSite()
|
||||
fun verifyDownloadsButton() = assertDownloadsButton()
|
||||
fun verifyShareTabsOverlay() = assertShareTabsOverlay()
|
||||
fun verifyNewTabButton() = assertNormalBrowsingNewTabButton()
|
||||
fun verifyReportSiteIssueButton() = assertReportSiteIssueButton()
|
||||
|
||||
fun verifyDesktopSiteModeEnabled(state: Boolean) {
|
||||
fun verifyDesktopSiteModeEnabled(isRequestDesktopSiteEnabled: Boolean) {
|
||||
expandMenu()
|
||||
if (state) {
|
||||
desktopSiteButton().check(matches(isChecked()))
|
||||
} else {
|
||||
desktopSiteButton().check(matches(not(isChecked())))
|
||||
}
|
||||
assertCheckedItemWithResIdAndTextExists(desktopSiteToggle(isRequestDesktopSiteEnabled))
|
||||
}
|
||||
|
||||
fun verifyPageThreeDotMainMenuItems() {
|
||||
verifyNewTabButton()
|
||||
verifyBookmarksButton()
|
||||
verifyAddBookmarkButton()
|
||||
verifyHistoryButton()
|
||||
verifyDownloadsButton()
|
||||
verifyAddOnsButton()
|
||||
verifySyncSignInButton()
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
verifyFindInPageButton()
|
||||
verifyDesktopSite()
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
verifyReportSiteIssueButton()
|
||||
verifyAddToTopSitesButton()
|
||||
verifyAddToMobileHome()
|
||||
verifySaveCollection()
|
||||
verifySettingsButton()
|
||||
verifyShareButton()
|
||||
verifyForwardButton()
|
||||
verifyRefreshButton()
|
||||
fun verifyPageThreeDotMainMenuItems(isRequestDesktopSiteEnabled: Boolean) {
|
||||
expandMenu()
|
||||
assertItemContainingTextExists(
|
||||
normalBrowsingNewTabButton,
|
||||
bookmarksButton,
|
||||
historyButton,
|
||||
downloadsButton,
|
||||
addOnsButton,
|
||||
syncAndSaveDataButton,
|
||||
findInPageButton,
|
||||
desktopSiteButton,
|
||||
reportSiteIssueButton,
|
||||
addToHomeScreenButton,
|
||||
addToShortcutsButton,
|
||||
saveToCollectionButton,
|
||||
settingsButton(),
|
||||
)
|
||||
assertCheckedItemWithResIdAndTextExists(addBookmarkButton)
|
||||
assertCheckedItemWithResIdAndTextExists(desktopSiteToggle(isRequestDesktopSiteEnabled))
|
||||
assertItemWithDescriptionExists(
|
||||
backButton,
|
||||
forwardButton,
|
||||
shareButton,
|
||||
refreshButton,
|
||||
)
|
||||
}
|
||||
|
||||
fun verifyHomeThreeDotMainMenuItems(isRequestDesktopSiteEnabled: Boolean) {
|
||||
assertItemContainingTextExists(
|
||||
bookmarksButton,
|
||||
historyButton,
|
||||
downloadsButton,
|
||||
addOnsButton,
|
||||
// Disabled step due to https://github.com/mozilla-mobile/fenix/issues/26788
|
||||
// syncAndSaveDataButton,
|
||||
desktopSiteButton,
|
||||
whatsNewButton,
|
||||
helpButton,
|
||||
customizeHomeButton,
|
||||
settingsButton(),
|
||||
)
|
||||
|
||||
assertCheckedItemWithResIdAndTextExists(desktopSiteToggle(isRequestDesktopSiteEnabled))
|
||||
}
|
||||
|
||||
private fun assertShareTabsOverlay() {
|
||||
|
@ -164,7 +173,7 @@ class ThreeDotMenuMainRobot {
|
|||
|
||||
fun openDownloadsManager(interact: DownloadRobot.() -> Unit): DownloadRobot.Transition {
|
||||
threeDotMenuRecyclerView().perform(swipeDown())
|
||||
downloadsButton().click()
|
||||
downloadsButton.click()
|
||||
|
||||
DownloadRobot().interact()
|
||||
return DownloadRobot.Transition()
|
||||
|
@ -173,7 +182,7 @@ class ThreeDotMenuMainRobot {
|
|||
fun openSyncSignIn(interact: SyncSignInRobot.() -> Unit): SyncSignInRobot.Transition {
|
||||
threeDotMenuRecyclerView().perform(swipeDown())
|
||||
mDevice.waitNotNull(Until.findObject(By.text("Sync and save data")), waitingTime)
|
||||
syncSignInButton().click()
|
||||
syncAndSaveDataButton.click()
|
||||
|
||||
SyncSignInRobot().interact()
|
||||
return SyncSignInRobot.Transition()
|
||||
|
@ -183,7 +192,7 @@ class ThreeDotMenuMainRobot {
|
|||
threeDotMenuRecyclerView().perform(swipeDown())
|
||||
mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime)
|
||||
|
||||
bookmarksButton().click()
|
||||
bookmarksButton.click()
|
||||
assertTrue(mDevice.findObject(UiSelector().resourceId("$packageName:id/bookmark_list")).waitForExists(waitingTime))
|
||||
|
||||
BookmarksRobot().interact()
|
||||
|
@ -193,7 +202,7 @@ class ThreeDotMenuMainRobot {
|
|||
fun openHistory(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
|
||||
threeDotMenuRecyclerView().perform(swipeDown())
|
||||
mDevice.waitNotNull(Until.findObject(By.text("History")), waitingTime)
|
||||
historyButton().click()
|
||||
historyButton.click()
|
||||
|
||||
HistoryRobot().interact()
|
||||
return HistoryRobot.Transition()
|
||||
|
@ -201,7 +210,7 @@ class ThreeDotMenuMainRobot {
|
|||
|
||||
fun bookmarkPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime)
|
||||
addBookmarkButton().click()
|
||||
addBookmarkButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
|
@ -217,7 +226,7 @@ class ThreeDotMenuMainRobot {
|
|||
|
||||
fun openHelp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
mDevice.waitNotNull(Until.findObject(By.text("Help")), waitingTime)
|
||||
helpButton().click()
|
||||
helpButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
|
@ -232,7 +241,7 @@ class ThreeDotMenuMainRobot {
|
|||
waitingTime,
|
||||
)
|
||||
|
||||
customizeHomeButton().click()
|
||||
customizeHomeButton.click()
|
||||
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("$packageName:id/recycler_view"),
|
||||
|
@ -243,21 +252,21 @@ class ThreeDotMenuMainRobot {
|
|||
}
|
||||
|
||||
fun goForward(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
forwardButton().click()
|
||||
forwardButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
backButton().click()
|
||||
fun goToPreviousPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
backButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickShareButton(interact: ShareOverlayRobot.() -> Unit): ShareOverlayRobot.Transition {
|
||||
shareButton().click()
|
||||
shareButton.click()
|
||||
mDevice.waitNotNull(Until.findObject(By.text("ALL ACTIONS")), waitingTime)
|
||||
|
||||
ShareOverlayRobot().interact()
|
||||
|
@ -281,8 +290,7 @@ class ThreeDotMenuMainRobot {
|
|||
}
|
||||
|
||||
fun refreshPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
assertRefreshButton()
|
||||
refreshButton().click()
|
||||
refreshButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
|
@ -298,7 +306,7 @@ class ThreeDotMenuMainRobot {
|
|||
fun openReportSiteIssue(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
reportSiteIssueButton().click()
|
||||
reportSiteIssueButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
|
@ -308,7 +316,7 @@ class ThreeDotMenuMainRobot {
|
|||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
mDevice.waitNotNull(Until.findObject(By.text("Find in page")), waitingTime)
|
||||
findInPageButton().click()
|
||||
findInPageButton.click()
|
||||
|
||||
FindInPageRobot().interact()
|
||||
return FindInPageRobot.Transition()
|
||||
|
@ -316,7 +324,7 @@ class ThreeDotMenuMainRobot {
|
|||
|
||||
fun openWhatsNew(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
mDevice.waitNotNull(Until.findObject(By.text("What’s new")), waitingTime)
|
||||
whatsNewButton().click()
|
||||
whatsNewButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
|
@ -332,7 +340,7 @@ class ThreeDotMenuMainRobot {
|
|||
}
|
||||
|
||||
fun addToFirefoxHome(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
addToTopSitesButton().click()
|
||||
addToShortcutsButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
|
@ -347,7 +355,7 @@ class ThreeDotMenuMainRobot {
|
|||
|
||||
fun openAddToHomeScreen(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenRobot.Transition {
|
||||
mDevice.waitNotNull(Until.findObject(By.text("Add to Home screen")), waitingTime)
|
||||
addToHomeScreenButton().click()
|
||||
addToHomeScreenButton.click()
|
||||
|
||||
AddToHomeScreenRobot().interact()
|
||||
return AddToHomeScreenRobot.Transition()
|
||||
|
@ -368,7 +376,7 @@ class ThreeDotMenuMainRobot {
|
|||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
|
||||
mDevice.waitNotNull(Until.findObject(By.text("Save to collection")), waitingTime)
|
||||
saveCollectionButton().click()
|
||||
saveToCollectionButton.click()
|
||||
CollectionRobot().interact()
|
||||
return CollectionRobot.Transition()
|
||||
}
|
||||
|
@ -396,7 +404,7 @@ class ThreeDotMenuMainRobot {
|
|||
fun switchDesktopSiteMode(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
desktopSiteButton().click()
|
||||
desktopSiteButton.click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
|
@ -417,61 +425,10 @@ private fun threeDotMenuRecyclerViewExists() {
|
|||
threeDotMenuRecyclerView().check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun settingsButton(localizedText: String = getStringResource(R.string.browser_menu_settings)) =
|
||||
mDevice.findObject(UiSelector().text(localizedText))
|
||||
|
||||
private fun assertSettingsButton() = assertTrue(settingsButton().waitForExists(waitingTime))
|
||||
|
||||
private fun customizeHomeButton() =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.text),
|
||||
withText(R.string.browser_menu_customize_home_1),
|
||||
),
|
||||
)
|
||||
|
||||
private fun assertCustomizeHomeButton() =
|
||||
customizeHomeButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun addOnsButton() = onView(allOf(withText("Add-ons")))
|
||||
private fun assertAddOnsButton() {
|
||||
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown())
|
||||
addOnsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun historyButton() = onView(allOf(withText(R.string.library_history)))
|
||||
private fun assertHistoryButton() = historyButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun bookmarksButton() = onView(allOf(withText(R.string.library_bookmarks)))
|
||||
private fun assertBookmarksButton() = bookmarksButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun syncSignInButton() = onView(withText("Sync and save data"))
|
||||
private fun assertSyncSignInButton() = syncSignInButton().check(matches(isDisplayed()))
|
||||
|
||||
private fun helpButton() = onView(allOf(withText(R.string.browser_menu_help)))
|
||||
private fun assertHelpButton() = helpButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun forwardButton() = mDevice.findObject(UiSelector().description("Forward"))
|
||||
private fun assertForwardButton() = assertTrue(forwardButton().waitForExists(waitingTime))
|
||||
|
||||
private fun backButton() = mDevice.findObject(UiSelector().description("Back"))
|
||||
|
||||
private fun addBookmarkButton() = onView(allOf(withId(R.id.checkbox), withText("Add")))
|
||||
private fun assertAddBookmarkButton() {
|
||||
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeUp())
|
||||
addBookmarkButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun editBookmarkButton() = onView(withText("Edit"))
|
||||
private fun assertEditBookmarkButton() = editBookmarkButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun refreshButton() = mDevice.findObject(UiSelector().description("Refresh"))
|
||||
private fun assertRefreshButton() = assertTrue(refreshButton().waitForExists(waitingTime))
|
||||
|
||||
private fun stopLoadingButton() = onView(ViewMatchers.withContentDescription("Stop"))
|
||||
|
||||
private fun closeAllTabsButton() = onView(allOf(withText("Close all tabs"))).inRoot(RootMatchers.isPlatformPopup())
|
||||
|
@ -482,36 +439,10 @@ private fun shareTabButton() = onView(allOf(withText("Share all tabs"))).inRoot(
|
|||
private fun assertShareTabButton() = shareTabButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun shareButton() = mDevice.findObject(UiSelector().description("Share"))
|
||||
private fun assertShareButton() = assertTrue(shareButton().waitForExists(waitingTime))
|
||||
|
||||
private fun saveCollectionButton() = onView(allOf(withText("Save to collection"))).inRoot(RootMatchers.isPlatformPopup())
|
||||
private fun assertSaveCollectionButton() = saveCollectionButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun selectTabsButton() = onView(allOf(withText("Select tabs"))).inRoot(RootMatchers.isPlatformPopup())
|
||||
private fun assertSelectTabsButton() = selectTabsButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
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 assertFindInPageButton() = findInPageButton()
|
||||
|
||||
private fun whatsNewButton() = onView(
|
||||
allOf(
|
||||
withText("What’s new"),
|
||||
withEffectiveVisibility(Visibility.VISIBLE),
|
||||
),
|
||||
)
|
||||
|
||||
private fun assertWhatsNewButton() = whatsNewButton()
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
||||
private fun addToHomeScreenButton() = onView(withText("Add to Home screen"))
|
||||
|
||||
private fun readerViewAppearanceToggle() =
|
||||
mDevice.findObject(UiSelector().text("Customize reader view"))
|
||||
|
||||
|
@ -532,21 +463,9 @@ private fun assertReaderViewAppearanceButton(visible: Boolean) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun addToTopSitesButton() =
|
||||
onView(allOf(withText(R.string.browser_menu_add_to_shortcuts)))
|
||||
|
||||
private fun removeFromShortcutsButton() =
|
||||
onView(allOf(withText(R.string.browser_menu_remove_from_shortcuts)))
|
||||
|
||||
private fun assertAddToTopSitesButton() {
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||
.perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText(R.string.browser_menu_add_to_shortcuts)),
|
||||
),
|
||||
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertRemoveFromShortcutsButton() {
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||
.perform(
|
||||
|
@ -556,26 +475,8 @@ private fun assertRemoveFromShortcutsButton() {
|
|||
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun addToMobileHomeButton() =
|
||||
onView(allOf(withText(R.string.browser_menu_add_to_homescreen)))
|
||||
|
||||
private fun assertAddToMobileHome() {
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||
.perform(
|
||||
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||
hasDescendant(withText(R.string.browser_menu_add_to_homescreen)),
|
||||
),
|
||||
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun installPWAButton() = mDevice.findObject(UiSelector().text("Install"))
|
||||
|
||||
private fun desktopSiteButton() = onView(withId(R.id.switch_widget))
|
||||
private fun assertDesktopSite() {
|
||||
threeDotMenuRecyclerView().perform(swipeUp())
|
||||
desktopSiteButton().check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun openInAppButton() =
|
||||
onView(
|
||||
allOf(
|
||||
|
@ -584,15 +485,9 @@ private fun openInAppButton() =
|
|||
),
|
||||
)
|
||||
|
||||
private fun downloadsButton() = onView(withText(R.string.library_downloads))
|
||||
private fun assertDownloadsButton() {
|
||||
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown())
|
||||
downloadsButton().check(matches(isDisplayed()))
|
||||
}
|
||||
|
||||
private fun clickAddonsManagerButton() {
|
||||
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown())
|
||||
addOnsButton().check(matches(isCompletelyDisplayed())).click()
|
||||
addOnsButton.click()
|
||||
}
|
||||
|
||||
private fun shareAllTabsButton() =
|
||||
|
@ -605,4 +500,45 @@ private fun assertShareAllTabsButton() {
|
|||
)
|
||||
}
|
||||
|
||||
private fun assertNormalBrowsingNewTabButton() = onView(withText("New tab")).check(matches(isDisplayed()))
|
||||
private val bookmarksButton =
|
||||
itemContainingText(getStringResource(R.string.library_bookmarks))
|
||||
private val historyButton =
|
||||
itemContainingText(getStringResource(R.string.library_history))
|
||||
private val downloadsButton =
|
||||
itemContainingText(getStringResource(R.string.library_downloads))
|
||||
private val addOnsButton =
|
||||
itemContainingText(getStringResource(R.string.browser_menu_add_ons))
|
||||
private val desktopSiteButton =
|
||||
itemContainingText(getStringResource(R.string.browser_menu_desktop_site))
|
||||
private fun desktopSiteToggle(state: Boolean) =
|
||||
checkedItemWithResIdAndText(
|
||||
"$packageName:id/switch_widget",
|
||||
getStringResource(R.string.browser_menu_desktop_site),
|
||||
state,
|
||||
)
|
||||
private val whatsNewButton =
|
||||
itemContainingText(getStringResource(R.string.browser_menu_whats_new))
|
||||
private val helpButton =
|
||||
itemContainingText(getStringResource(R.string.browser_menu_help))
|
||||
private val customizeHomeButton =
|
||||
itemContainingText(getStringResource(R.string.browser_menu_customize_home_1))
|
||||
private fun settingsButton(localizedText: String = getStringResource(R.string.browser_menu_settings)) =
|
||||
itemContainingText(localizedText)
|
||||
private val syncAndSaveDataButton =
|
||||
itemContainingText(getStringResource(R.string.sync_menu_sync_and_save_data))
|
||||
private val normalBrowsingNewTabButton =
|
||||
itemContainingText(getStringResource(R.string.library_new_tab))
|
||||
private val addBookmarkButton =
|
||||
itemWithResIdAndText(
|
||||
"$packageName:id/checkbox",
|
||||
getStringResource(R.string.browser_menu_add),
|
||||
)
|
||||
private val findInPageButton = itemContainingText(getStringResource(R.string.browser_menu_find_in_page))
|
||||
private val reportSiteIssueButton = itemContainingText("Report Site Issue")
|
||||
private val addToHomeScreenButton = itemContainingText(getStringResource(R.string.browser_menu_add_to_homescreen))
|
||||
private val addToShortcutsButton = itemContainingText(getStringResource(R.string.browser_menu_add_to_shortcuts))
|
||||
private val saveToCollectionButton = itemContainingText(getStringResource(R.string.browser_menu_save_to_collection_2))
|
||||
private val backButton = itemWithDescription(getStringResource(R.string.browser_menu_back))
|
||||
private val forwardButton = itemWithDescription(getStringResource(R.string.browser_menu_forward))
|
||||
private val shareButton = itemWithDescription(getStringResource(R.string.share_button_content_description))
|
||||
private val refreshButton = itemWithDescription(getStringResource(R.string.browser_menu_refresh))
|
||||
|
|
Loading…
Reference in New Issue
Block a user