For #17979 & #17840: fix and re-enable UI tests affected by main menu changes

upstream-sync
Oana Horvath 3 years ago
parent 358a3a3d4c
commit 78f0086b7e

@ -28,7 +28,6 @@ import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.ext.toUri
import org.mozilla.fenix.helpers.ext.waitNotNull
import org.mozilla.fenix.ui.robots.accountSettings
import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.settingsSubMenuLoginsAndPassword
@ -141,10 +140,7 @@ class SyncIntegrationTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage) {
}.openThreeDotMenu {
verifyAddBookmarkButton()
clickAddBookmarkButton()
}
browserScreen {
}.bookmarkPage {
}.openThreeDotMenu {
}.openSettings {
}.openTurnOnSyncMenu {

@ -12,7 +12,6 @@ import mozilla.appservices.places.BookmarkRoot
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
@ -32,7 +31,6 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
/**
* Tests for verifying basic functionality of bookmarks
*/
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17979")
class BookmarksTest {
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
@ -96,10 +94,7 @@ class BookmarksTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyAddBookmarkButton()
clickAddBookmarkButton()
}
browserScreen {
}.bookmarkPage {
}.openThreeDotMenu {
verifyEditBookmarkButton()
}

@ -49,7 +49,6 @@ class NavigationToolbarTest {
}
@Test
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/17979")
fun goBackTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val nextWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
@ -68,7 +67,6 @@ class NavigationToolbarTest {
}
@Test
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/17979")
fun goForwardTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val nextWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)
@ -90,32 +88,11 @@ class NavigationToolbarTest {
navigationToolbar {
}.openThreeDotMenu {
verifyThreeDotMenuExists()
verifyForwardButton()
}.goForward {
verifyUrl(nextWebPage.url.toString())
}
}
@Test
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/17979")
fun refreshPageTest() {
val refreshWebPage = TestAssetHelper.getRefreshAsset(mockWebServer)
navigationToolbar {
}.enterURLAndEnterToBrowser(refreshWebPage.url) {
mDevice.waitForIdle()
}
// Use refresh from the three-dot menu
navigationToolbar {
}.openThreeDotMenu {
verifyThreeDotMenuExists()
verifyRefreshButton()
}.refreshPage {
verifyPageContent("REFRESHED")
}
}
@Test
fun visitURLTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

@ -6,7 +6,6 @@ package org.mozilla.fenix.ui
import androidx.core.net.toUri
import org.junit.After
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
@ -67,7 +66,6 @@ class NoNetworkAccessStartupTests {
}
@Test
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/17979")
fun testPageReloadAfterNetworkInterrupted() {
val url = "example.com"
@ -80,11 +78,7 @@ class NoNetworkAccessStartupTests {
browserScreen {
}.openThreeDotMenu {
verifyRefreshButton()
}
// we verify that the share button exists, but this fails when trying to click
// .refreshPage {}
}.refreshPage { }
}
@Test

@ -9,10 +9,8 @@ import androidx.test.espresso.IdlingRegistry
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
@ -104,7 +102,6 @@ class ReaderViewTest {
@Test
fun verifyReaderViewToggle() {
// New three-dot menu design does not have readerview appearance menu item
val readerViewPage =
TestAssetHelper.getLoremIpsumAsset(mockWebServer)
@ -127,34 +124,21 @@ class ReaderViewTest {
}
browserScreen {
verifyPageContent(estimatedReadingTime)
}
}.openThreeDotMenu {
verifyReaderViewAppearance(true)
}.closeBrowserMenuToBrowser { }
navigationToolbar {
verifyCloseReaderViewDetected(true)
toggleReaderView()
mDevice.waitForIdle()
verifyReaderViewDetected(true)
}
if (!FeatureFlags.toolbarMenuFeature) {
browserScreen {
verifyPageContent(estimatedReadingTime)
}.openThreeDotMenu {
verifyReaderViewAppearance(true)
}.closeBrowserMenuToBrowser { }
}
if (!FeatureFlags.toolbarMenuFeature) {
navigationToolbar {
toggleReaderView()
mDevice.waitForIdle()
}.openThreeDotMenu {
verifyReaderViewAppearance(false)
}.close { }
}
}.openThreeDotMenu {
verifyReaderViewAppearance(false)
}.close { }
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17971")
fun verifyReaderViewAppearanceFontToggle() {
val readerViewPage =
TestAssetHelper.getLoremIpsumAsset(mockWebServer)
@ -195,7 +179,6 @@ class ReaderViewTest {
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17971")
fun verifyReaderViewAppearanceFontSizeToggle() {
val readerViewPage =
TestAssetHelper.getLoremIpsumAsset(mockWebServer)
@ -242,7 +225,6 @@ class ReaderViewTest {
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17971")
fun verifyReaderViewAppearanceColorSchemeChange() {
val readerViewPage =
TestAssetHelper.getLoremIpsumAsset(mockWebServer)

@ -10,7 +10,6 @@ import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.FenixApplication
@ -106,7 +105,6 @@ class SettingsBasicsTest {
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17979")
fun toggleShowVisitedSitesAndBookmarks() {
// Bookmarks a few websites, toggles the history and bookmarks setting to off, then verifies if the visited and bookmarked websites do not show in the suggestions.
val page1 = getGenericAsset(mockWebServer, 1)
@ -117,15 +115,13 @@ class SettingsBasicsTest {
}.openNavigationToolbar {
}.enterURLAndEnterToBrowser(page1.url) {
}.openThreeDotMenu {
clickAddBookmarkButton()
}
}.bookmarkPage { }
navigationToolbar {
}.enterURLAndEnterToBrowser(page2.url) {
verifyUrl(page2.url.toString())
}.openThreeDotMenu {
clickAddBookmarkButton()
}
}.bookmarkPage { }
navigationToolbar {
}.enterURLAndEnterToBrowser(page3.url) {

@ -9,7 +9,6 @@ import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
@ -45,7 +44,6 @@ class ShareButtonTest {
}
@Test
@Ignore("To be re-implemented with the three dot menu changes https://github.com/mozilla-mobile/fenix/issues/17979")
fun ShareButtonAppearanceTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
@ -58,7 +56,6 @@ class ShareButtonTest {
// From the 3-dot menu next to the Select share menu
navigationToolbar {
}.openThreeDotMenu {
verifyShareButton()
clickShareButton()
verifyShareScrim()
verifySendToDeviceTitle()

@ -17,7 +17,6 @@ import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
@ -194,14 +193,13 @@ class SmokeTest {
@Test
// Verifies the list of items in a tab's 3 dot menu
@Ignore("To be re-implemented with the three dot menu changes https://github.com/mozilla-mobile/fenix/issues/17870")
fun verifyPageMainMenuItemsTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyThreeDotMainMenuItems()
verifyPageThreeDotMainMenuItems()
}
}
@ -321,41 +319,32 @@ class SmokeTest {
@Test
// Verifies the Bookmark button in a tab's 3 dot menu
// TODO: To be removed in https://github.com/mozilla-mobile/fenix/issues/17979 since the bookmark button is no longer in the nav bar.
fun mainMenuBookmarkButtonTest() {
if (!FeatureFlags.toolbarMenuFeature) {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
}.bookmarkPage {
verifySnackBarText("Bookmark saved!")
}
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
}.bookmarkPage {
verifySnackBarText("Bookmark saved!")
}
}
@Test
// Verifies the Share button in a tab's 3 dot menu
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/17979")
fun mainMenuShareButtonTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyShareButton()
}.sharePage {
verifyShareAppsLayout()
}
// we verify that the share button exists, but this fails when trying to click
// .sharePage {
// verifyShareAppsLayout()
// }
}
@Test
// Verifies the refresh button in a tab's 3 dot menu
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/17979")
fun mainMenuRefreshButtonTest() {
val refreshWebPage = TestAssetHelper.getRefreshAsset(mockWebServer)
@ -364,18 +353,13 @@ class SmokeTest {
mDevice.waitForIdle()
}.openThreeDotMenu {
verifyThreeDotMenuExists()
verifyRefreshButton()
}.refreshPage {
verifyPageContent("REFRESHED")
}
// we verify that the refresh button exists, but this fails when trying to click
// .refreshPage {
// verifyPageContent("REFRESHED")
// }
}
@Test
// Turns ETP toggle off from Settings and verifies the ETP shield is not displayed in the nav bar
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/17979")
fun verifyETPShieldNotDisplayedIfOFFGlobally() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
@ -552,7 +536,6 @@ class SmokeTest {
@Test
// Saves a login, then changes it and verifies the update
@Ignore("To be re-implemented with the three dot menu changes https://github.com/mozilla-mobile/fenix/issues/17870")
fun updateSavedLoginTest() {
val saveLoginTest =
TestAssetHelper.getSaveLoginAsset(mockWebServer)
@ -616,7 +599,6 @@ class SmokeTest {
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17799")
// Installs uBlock add-on and checks that the app doesn't crash while loading pages with trackers
fun noCrashWithAddonInstalledTest() {
// setting ETP to Strict mode to test it works with add-ons
@ -991,7 +973,6 @@ class SmokeTest {
@Test
// Verifies that deleting a Bookmarks folder also removes the item from inside it.
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17799")
fun deleteNonEmptyBookmarkFolderTest() {
val website = TestAssetHelper.getGenericAsset(mockWebServer, 1)
@ -1152,7 +1133,6 @@ class SmokeTest {
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17799")
fun mainMenuInstallPWATest() {
val pwaPage = "https://rpappalax.github.io/testapp/"
@ -1169,7 +1149,6 @@ class SmokeTest {
}
@Test
@Ignore("To be re-implemented in https://github.com/mozilla-mobile/fenix/issues/17971")
// Verifies that reader mode is detected and the custom appearance controls are displayed
fun verifyReaderViewAppearanceUI() {
val readerViewPage =

@ -8,7 +8,6 @@ import androidx.test.platform.app.InstrumentationRegistry
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.ext.settings
@ -127,7 +126,6 @@ class StrictEnhancedTrackingProtectionTest {
}
@Test
@Ignore("To be re-implemented with the three dot menu changes https://github.com/mozilla-mobile/fenix/issues/17870")
fun testStrictVisitDisable() {
val trackingProtectionTest =
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
@ -151,7 +149,6 @@ class StrictEnhancedTrackingProtectionTest {
navigationToolbar {
}.openThreeDotMenu {
verifyThreeDotMenuExists()
verifySettingsButton()
}.openSettings {
verifyEnhancedTrackingProtectionButton()
verifyEnhancedTrackingProtectionValue("On")

@ -4,15 +4,11 @@
package org.mozilla.fenix.ui
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.ui.robots.homeScreen
@ -38,85 +34,54 @@ class ThreeDotMenuMainTest {
}
}
// changing the device preference for Touch and Hold delay, to avoid long-clicks instead of a single-click
companion object {
@BeforeClass
@JvmStatic
fun setDevicePreference() {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.executeShellCommand("settings put secure long_press_timeout 3000")
}
}
@After
fun tearDown() {
mockWebServer.shutdown()
}
// Verifies the list of items in the homescreen's 3 dot main menu
@Test
fun threeDotMenuItemsTest() {
if (FeatureFlags.toolbarMenuFeature) {
homeScreen {
}.openThreeDotMenu {
}.openHistory {
verifyHistoryMenuView()
}.goBackToBrowser {}
homeScreen {
}.openThreeDotMenu {
}.openBookmarks {
verifyBookmarksMenuView()
}.closeMenu {}
homeScreen {
}.openThreeDotMenu {
verifySettingsButton()
verifyBookmarksButton()
verifyHistoryButton()
}.openSettings {
verifySettingsView()
}.goBack {
}.openThreeDotMenu {
}.goBack {}
} else {
homeScreen {
}.openThreeDotMenu {
verifySettingsButton()
verifyBookmarksButton()
verifyHistoryButton()
verifyHelpButton()
verifyWhatsNewButton()
}.openSettings {
verifySettingsView()
}.goBack {
}.openThreeDotMenu {
}.openHelp {
verifyHelpUrl()
}.openTabDrawer {
closeTab()
}
homeScreen {
}.openThreeDotMenu {
}.openWhatsNew {
verifyWhatsNewURL()
}.openTabDrawer {
closeTab()
}
fun homeThreeDotMenuItemsTest() {
homeScreen {
}.openThreeDotMenu {
verifyBookmarksButton()
verifyHistoryButton()
verifyDownloadsButton()
verifyAddOnsButton()
verifySyncedTabsButton()
verifyDesktopSite()
verifyWhatsNewButton()
verifyHelpButton()
verifySettingsButton()
}.openSettings {
verifySettingsView()
}.goBack {
}.openThreeDotMenu {
}.openHelp {
verifyHelpUrl()
}.openTabDrawer {
closeTab()
}
homeScreen {
}.openThreeDotMenu {
}.openBookmarks {
verifyBookmarksMenuView()
}.closeMenu {
}
homeScreen {
}.openThreeDotMenu {
}.openWhatsNew {
verifyWhatsNewURL()
}.openTabDrawer {
closeTab()
}
homeScreen {
}.openThreeDotMenu {
}.openHistory {
verifyHistoryMenuView()
}
homeScreen {
}.openThreeDotMenu {
}.openBookmarks {
verifyBookmarksMenuView()
}.closeMenu {
}
homeScreen {
}.openThreeDotMenu {
}.openHistory {
verifyHistoryMenuView()
}
}
}

@ -54,7 +54,7 @@ class TopSitesTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyAddFirefoxHome()
verifyAddToTopSitesButton()
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
@ -73,7 +73,7 @@ class TopSitesTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyAddFirefoxHome()
verifyAddToTopSitesButton()
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
@ -104,7 +104,7 @@ class TopSitesTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyAddFirefoxHome()
verifyAddToTopSitesButton()
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
@ -128,7 +128,7 @@ class TopSitesTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyAddFirefoxHome()
verifyAddToTopSitesButton()
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
@ -152,7 +152,7 @@ class TopSitesTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyAddFirefoxHome()
verifyAddToTopSitesButton()
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {

@ -310,8 +310,7 @@ class BrowserRobot {
// needs to wait for the right url to load before saving a bookmark
verifyUrl(url.toString())
}.openThreeDotMenu {
clickAddBookmarkButton()
}
}.bookmarkPage { }
}
fun clickLinkMatchingText(expectedText: String) {

@ -645,7 +645,7 @@ private fun assertPrivacyNoticeButton() {
private fun assertStartBrowsingButton() {
scrollToElementByText("Start browsing")
onView(allOf(withText("Start browsing")))
onView(withId(R.id.finish_button))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}

@ -269,16 +269,20 @@ private fun assertThemeSelected() = onView(withText("Light"))
private fun assertAccessibilityButton() = onView(withText("Accessibility"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertSetAsDefaultBrowserButton() =
private fun assertSetAsDefaultBrowserButton() {
scrollToElementByText("Set as default browser")
onView(withText("Set as default browser"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertDefaultBrowserIsDisabled() {
scrollToElementByText("Set as default browser")
onView(withId(R.id.switch_widget))
.check(matches(ViewMatchers.isNotChecked()))
}
private fun toggleDefaultBrowserSwitch() {
scrollToElementByText("Set as default browser")
onView(
CoreMatchers.allOf(
ViewMatchers.withParent(CoreMatchers.not(withId(R.id.navigationToolbar))),

@ -6,24 +6,17 @@
package org.mozilla.fenix.ui.robots
import android.view.View
import androidx.recyclerview.widget.RecyclerView
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.click
import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.action.ViewActions.swipeUp
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
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.isAssignableFrom
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
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.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.Matcher
import org.hamcrest.Matchers.allOf
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.click
@ -74,6 +66,11 @@ class ThreeDotMenuMainRobot {
}
fun clickShareButton() {
var maxSwipes = 3
while (!shareButton().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
shareButton().click()
mDevice.waitNotNull(Until.findObject(By.text("ALL ACTIONS")), waitingTime)
}
@ -90,73 +87,41 @@ class ThreeDotMenuMainRobot {
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 verifyFindInPageButton() = assertFindInPageButton()
fun verifyShareScrim() = assertShareScrim()
fun verifySendToDeviceTitle() = assertSendToDeviceTitle()
fun verifyShareALinkTitle() = assertShareALinkTitle()
fun verifyWhatsNewButton() = assertWhatsNewButton()
fun verifyAddFirefoxHome() = assertAddToFirefoxHome()
fun verifyAddToTopSitesButton() = assertAddToTopSitesButton()
fun verifyAddToMobileHome() = assertAddToMobileHome()
fun verifyDesktopSite() = assertDesktopSite()
fun verifyDownloadsButton() = assertDownloadsButton()
fun verifyShareTabsOverlay() = assertShareTabsOverlay()
fun verifyThreeDotMainMenuItems() {
if (FeatureFlags.toolbarMenuFeature) {
verifyDownloadsButton()
verifyHistoryButton()
verifyBookmarksButton()
verifySettingsButton()
verifyDesktopSite()
verifySaveCollection()
verifyShareButton()
verifyForwardButton()
verifyRefreshButton()
} else {
verifyAddOnsButton()
verifyDownloadsButton()
verifyHistoryButton()
verifyBookmarksButton()
verifySyncedTabsButton()
verifySettingsButton()
verifyFindInPageButton()
verifyAddFirefoxHome()
verifyAddToMobileHome()
verifyDesktopSite()
verifySaveCollection()
verifyAddBookmarkButton()
verifyShareButton()
verifyForwardButton()
verifyRefreshButton()
}
fun verifySignInToSyncButton() = assertSignInToSyncButton()
fun verifyNewTabButton() = assertNewTabButton()
fun verifyReportSiteIssueButton() = assertReportSiteIssueButton()
fun verifyPageThreeDotMainMenuItems() {
verifyNewTabButton()
verifyBookmarksButton()
verifyAddBookmarkButton()
verifyHistoryButton()
verifyDownloadsButton()
verifyAddOnsButton()
verifySignInToSyncButton()
threeDotMenuRecyclerView().perform(swipeUp())
verifyFindInPageButton()
verifyDesktopSite()
threeDotMenuRecyclerView().perform(swipeUp())
verifyReportSiteIssueButton()
verifyAddToTopSitesButton()
verifyAddToMobileHome()
verifySaveCollection()
verifySettingsButton()
verifyShareButton()
verifyForwardButton()
verifyRefreshButton()
}
private fun assertShareTabsOverlay() {
@ -171,11 +136,12 @@ class ThreeDotMenuMainRobot {
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
fun openSettings(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(swipeDown())
onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings)))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
.check(matches(isCompletelyDisplayed()))
.perform(ViewActions.click())
var maxSwipes = 3
while (!settingsButton().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
settingsButton().click()
SettingsRobot().interact()
return SettingsRobot.Transition()
@ -219,7 +185,7 @@ class ThreeDotMenuMainRobot {
}
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()
BrowserRobot().interact()
@ -227,10 +193,12 @@ class ThreeDotMenuMainRobot {
}
fun sharePage(interact: LibrarySubMenusMultipleSelectionToolbarRobot.() -> Unit): LibrarySubMenusMultipleSelectionToolbarRobot.Transition {
mDevice.waitNotNull(Until.findObject(By.desc("Share")), waitingTime)
var maxSwipes = 3
while (!shareButton().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
shareButton().click()
pressBack()
LibrarySubMenusMultipleSelectionToolbarRobot().interact()
return LibrarySubMenusMultipleSelectionToolbarRobot.Transition()
}
@ -244,7 +212,11 @@ class ThreeDotMenuMainRobot {
}
fun goForward(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitNotNull(Until.findObject(By.desc("Forward")), waitingTime)
var maxSwipes = 3
while (!forwardButton().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
forwardButton().click()
BrowserRobot().interact()
@ -278,8 +250,12 @@ class ThreeDotMenuMainRobot {
}
fun refreshPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
// TODO: this is not finding the button correctly
mDevice.waitNotNull(Until.findObject(By.desc("Refresh")), waitingTime)
var maxSwipes = 3
while (!refreshButton().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
assertRefreshButton()
refreshButton().click()
BrowserRobot().interact()
@ -346,6 +322,11 @@ class ThreeDotMenuMainRobot {
}
fun openReaderViewAppearance(interact: ReaderViewRobot.() -> Unit): ReaderViewRobot.Transition {
var maxSwipes = 3
while (!readerViewAppearanceToggle().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
readerViewAppearanceToggle().click()
ReaderViewRobot().interact()
@ -353,7 +334,7 @@ class ThreeDotMenuMainRobot {
}
fun addToFirefoxHome(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
addToFirefoxHomeButton().click()
addToTopSitesButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
@ -368,6 +349,11 @@ class ThreeDotMenuMainRobot {
}
fun clickInstall(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenRobot.Transition {
var maxSwipes = 3
while (!installPWAButton().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
installPWAButton().click()
AddToHomeScreenRobot().interact()
@ -407,15 +393,15 @@ class ThreeDotMenuMainRobot {
}
}
}
private fun threeDotMenuRecyclerView() =
onView(withId(R.id.mozac_browser_menu_recyclerView))
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 assertSettingsButton() = settingsButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
.check(matches(isCompletelyDisplayed()))
private fun settingsButton() = mDevice.findObject(UiSelector().text("Settings"))
private fun assertSettingsButton() = assertTrue(settingsButton().waitForExists(waitingTime))
private fun addOnsButton() = onView(allOf(withText("Add-ons")))
private fun assertAddOnsButton() {
@ -435,27 +421,28 @@ private fun syncedTabsButton() = onView(allOf(withText(R.string.library_synced_t
private fun assertSyncedTabsButton() = syncedTabsButton()
.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 assertHelpButton() = helpButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun forwardButton() = onView(ViewMatchers.withContentDescription("Forward"))
private fun assertForwardButton() = forwardButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun forwardButton() = mDevice.findObject(UiSelector().description("Forward"))
private fun assertForwardButton() = assertTrue(forwardButton().waitForExists(waitingTime))
private fun addBookmarkButton() = onView(ViewMatchers.withContentDescription("Bookmark"))
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(ViewMatchers.withContentDescription("Edit bookmark"))
private fun editBookmarkButton() = onView(withText("Edit"))
private fun assertEditBookmarkButton() = editBookmarkButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun refreshButton() = onView(ViewMatchers.withContentDescription("Refresh"))
private fun assertRefreshButton() = refreshButton()
.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"))
@ -467,9 +454,8 @@ private fun shareTabButton() = onView(allOf(withText("Share all tabs"))).inRoot(
private fun assertShareTabButton() = shareTabButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun shareButton() = onView(ViewMatchers.withContentDescription("Share"))
private fun assertShareButton() = shareButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun shareButton() = mDevice.findObject(UiSelector().description("Share"))
private fun assertShareButton() = assertTrue(shareButton().waitForExists(waitingTime))
private fun browserViewSaveCollectionButton() = onView(
allOf(
@ -497,6 +483,7 @@ private fun assertCollectionNameTextField() = collectionNameTextField()
.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")))
@ -531,17 +518,29 @@ private fun assertWhatsNewButton() = whatsNewButton()
private fun addToHomeScreenButton() = onView(withText("Add to Home screen"))
private fun readerViewAppearanceToggle() =
onView(allOf(withText(R.string.browser_menu_read_appearance)))
private fun assertReaderViewAppearanceButton(visible: Boolean) = readerViewAppearanceToggle()
.check(
if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else ViewAssertions.doesNotExist()
)
mDevice.findObject(UiSelector().text("Customize reader view"))
private fun assertReaderViewAppearanceButton(visible: Boolean) {
var maxSwipes = 3
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 addToTopSitesButton() =
onView(allOf(withText(R.string.browser_menu_add_to_top_sites)))
private fun assertAddToFirefoxHome() {
private fun assertAddToTopSitesButton() {
onView(withId(R.id.mozac_browser_menu_recyclerView))
.perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
@ -562,7 +561,7 @@ private fun assertAddToMobileHome() {
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun installPWAButton() = onView(allOf(withId(R.id.highlight_text), withText("Install")))
private fun installPWAButton() = mDevice.findObject(UiSelector().text("Install"))
private fun desktopSiteButton() =
onView(allOf(withText(R.string.browser_menu_desktop_site)))
@ -610,3 +609,5 @@ private fun assertShareAllTabsButton() {
.check(
matches(isDisplayed()))
}
private fun assertNewTabButton() = onView(withText("New tab")).check(matches(isDisplayed()))

Loading…
Cancel
Save