2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/21002: added page main menu items tests

This commit is contained in:
Oana Horvath 2021-08-25 16:06:34 +03:00 committed by mergify[bot]
parent 690f3e72f5
commit e619f4b030
6 changed files with 145 additions and 66 deletions

View File

@ -5,6 +5,7 @@ object Constants {
object PackageName { object PackageName {
const val GOOGLE_PLAY_SERVICES = "com.android.vending" const val GOOGLE_PLAY_SERVICES = "com.android.vending"
const val GOOGLE_APPS_PHOTOS = "com.google.android.apps.photos" const val GOOGLE_APPS_PHOTOS = "com.google.android.apps.photos"
const val YOUTUBE_APP = "com.google.android.youtube"
} }
const val LONG_CLICK_DURATION: Long = 5000 const val LONG_CLICK_DURATION: Long = 5000

View File

@ -8,6 +8,7 @@ import android.app.PendingIntent
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Color import android.graphics.Color
@ -21,6 +22,8 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.IdlingRegistry import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.action.ViewActions.longClick import androidx.test.espresso.action.ViewActions.longClick
import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.matcher.IntentMatchers
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
@ -190,4 +193,35 @@ object TestHelper {
canvas.drawColor(Color.GREEN) canvas.drawColor(Color.GREEN)
return bitmap return bitmap
} }
fun isPackageInstalled(packageName: String): Boolean {
return try {
val packageManager = InstrumentationRegistry.getInstrumentation().context.packageManager
packageManager.getApplicationInfo(packageName, 0).enabled
} catch (exception: PackageManager.NameNotFoundException) {
false
}
}
fun assertExternalAppOpens(appPackageName: String) {
if (isPackageInstalled(appPackageName)) {
Intents.intended(IntentMatchers.toPackage(appPackageName))
} else {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.waitNotNull(
Until.findObject(By.text("Could not open file")),
waitingTime
)
}
}
fun returnToBrowser() {
val urlBar =
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_url_view"))
do {
mDevice.pressBack()
} while (
!urlBar.waitForExists(waitingTime)
)
}
} }

View File

@ -25,14 +25,18 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.Constants.PackageName.YOUTUBE_APP
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.appName import org.mozilla.fenix.helpers.TestHelper.appName
import org.mozilla.fenix.helpers.TestHelper.assertExternalAppOpens
import org.mozilla.fenix.helpers.TestHelper.createCustomTabIntent import org.mozilla.fenix.helpers.TestHelper.createCustomTabIntent
import org.mozilla.fenix.helpers.TestHelper.deleteDownloadFromStorage import org.mozilla.fenix.helpers.TestHelper.deleteDownloadFromStorage
import org.mozilla.fenix.helpers.TestHelper.isPackageInstalled
import org.mozilla.fenix.helpers.TestHelper.restartApp import org.mozilla.fenix.helpers.TestHelper.restartApp
import org.mozilla.fenix.helpers.TestHelper.returnToBrowser
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.ui.robots.browserScreen import org.mozilla.fenix.ui.robots.browserScreen
@ -238,10 +242,13 @@ class SmokeTest {
@Test @Test
// Verifies the History menu opens from a tab's 3 dot menu // Verifies the History menu opens from a tab's 3 dot menu
fun openMainMenuHistoryItemTest() { fun openMainMenuHistoryItemTest() {
homeScreen { val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu { }.openThreeDotMenu {
}.openHistory { }.openHistory {
verifyHistoryMenuView() verifyHistoryListExists()
} }
} }
@ -249,7 +256,10 @@ class SmokeTest {
@Test @Test
// Verifies the Bookmarks menu opens from a tab's 3 dot menu // Verifies the Bookmarks menu opens from a tab's 3 dot menu
fun openMainMenuBookmarksItemTest() { fun openMainMenuBookmarksItemTest() {
homeScreen { val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu { }.openThreeDotMenu {
}.openBookmarks { }.openBookmarks {
verifyBookmarksMenuView() verifyBookmarksMenuView()
@ -260,7 +270,10 @@ class SmokeTest {
// Verifies the Synced tabs menu or Sync Sign In menu opens from a tab's 3 dot menu. // Verifies the Synced tabs menu or Sync Sign In menu opens from a tab's 3 dot menu.
// The test is assuming we are NOT signed in. // The test is assuming we are NOT signed in.
fun openMainMenuSyncItemTest() { fun openMainMenuSyncItemTest() {
homeScreen { val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu { }.openThreeDotMenu {
}.openSyncSignIn { }.openSyncSignIn {
verifySyncSignInMenuHeader() verifySyncSignInMenuHeader()
@ -272,7 +285,10 @@ class SmokeTest {
// caution when making changes to it, so they don't block the builds // caution when making changes to it, so they don't block the builds
// Verifies the Settings menu opens from a tab's 3 dot menu // Verifies the Settings menu opens from a tab's 3 dot menu
fun openMainMenuSettingsItemTest() { fun openMainMenuSettingsItemTest() {
homeScreen { val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu { }.openThreeDotMenu {
}.openSettings { }.openSettings {
verifySettingsView() verifySettingsView()
@ -362,6 +378,37 @@ class SmokeTest {
} }
} }
@Test
// Verifies the Open in app button when an app is installed
fun mainMenuOpenInAppTest() {
val youtubeUrl = "m.youtube.com"
if (isPackageInstalled(YOUTUBE_APP)) {
navigationToolbar {
}.enterURLAndEnterToBrowser(youtubeUrl.toUri()) {
verifyNotificationDotOnMainMenu()
}.openThreeDotMenu {
}.clickOpenInApp {
assertExternalAppOpens(YOUTUBE_APP)
returnToBrowser()
verifyUrl(youtubeUrl)
}
}
}
@Test
// Verifies the Desktop site toggle in a tab's 3 dot menu
fun mainMenuDesktopSiteTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
}.switchDesktopSiteMode {
}.openThreeDotMenu {
verifyDesktopSiteModeEnabled(true)
}
}
@Test @Test
// Verifies the Share button in a tab's 3 dot menu // Verifies the Share button in a tab's 3 dot menu
fun mainMenuShareButtonTest() { fun mainMenuShareButtonTest() {

View File

@ -28,6 +28,7 @@ import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_APPS_PHOTOS
import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.assertExternalAppOpens
import org.mozilla.fenix.helpers.TestHelper.packageName import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull import org.mozilla.fenix.helpers.ext.waitNotNull
@ -42,7 +43,7 @@ class DownloadRobot {
fun verifyDownloadNotificationPopup() = assertDownloadNotificationPopup() fun verifyDownloadNotificationPopup() = assertDownloadNotificationPopup()
fun verifyPhotosAppOpens() = assertPhotosOpens() fun verifyPhotosAppOpens() = assertExternalAppOpens(GOOGLE_APPS_PHOTOS)
fun verifyDownloadedFileName(fileName: String) { fun verifyDownloadedFileName(fileName: String) {
mDevice.findObject(UiSelector().text(fileName)).waitForExists(waitingTime) mDevice.findObject(UiSelector().text(fileName)).waitForExists(waitingTime)
@ -144,18 +145,6 @@ private fun clickOpenButton() =
matches(isDisplayed()) matches(isDisplayed())
) )
private fun assertPhotosOpens() {
if (isPackageInstalled(GOOGLE_APPS_PHOTOS)) {
Intents.intended(IntentMatchers.toPackage(GOOGLE_APPS_PHOTOS))
} else {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mDevice.waitNotNull(
Until.findObject(By.text("Could not open file")),
TestAssetHelper.waitingTime
)
}
}
private fun downloadedFile(fileName: String) = onView(withText(fileName)) private fun downloadedFile(fileName: String) = onView(withText(fileName))
private fun assertDownloadedFileIcon() = onView(withId(R.id.favicon)).check(matches(isDisplayed())) private fun assertDownloadedFileIcon() = onView(withId(R.id.favicon)).check(matches(isDisplayed()))

View File

@ -6,7 +6,6 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import android.content.pm.PackageManager
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.ViewInteraction import androidx.test.espresso.ViewInteraction
@ -34,6 +33,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_PLAY_SERVICES import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_PLAY_SERVICES
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper.appName import org.mozilla.fenix.helpers.TestHelper.appName
import org.mozilla.fenix.helpers.TestHelper.isPackageInstalled
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
import org.mozilla.fenix.helpers.assertIsEnabled import org.mozilla.fenix.helpers.assertIsEnabled
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
@ -493,15 +493,6 @@ private fun assertGooglePlayRedirect() {
} }
} }
fun isPackageInstalled(packageName: String): Boolean {
return try {
val packageManager = InstrumentationRegistry.getInstrumentation().context.packageManager
packageManager.getApplicationInfo(packageName, 0).enabled
} catch (exception: PackageManager.NameNotFoundException) {
false
}
}
private fun addonsManagerButton() = onView(withText(R.string.preferences_addons)) private fun addonsManagerButton() = onView(withText(R.string.preferences_addons))
private fun goBackButton() = private fun goBackButton() =

View File

@ -16,6 +16,7 @@ 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.isChecked
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
@ -28,6 +29,7 @@ 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.Matchers.allOf import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.not
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.mozilla.fenix.R import org.mozilla.fenix.R
@ -66,11 +68,6 @@ class ThreeDotMenuMainRobot {
} }
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)
} }
@ -93,6 +90,13 @@ class ThreeDotMenuMainRobot {
fun verifyNewTabButton() = assertNewTabButton() fun verifyNewTabButton() = assertNewTabButton()
fun verifyReportSiteIssueButton() = assertReportSiteIssueButton() fun verifyReportSiteIssueButton() = assertReportSiteIssueButton()
fun verifyDesktopSiteModeEnabled(state: Boolean) {
expandMenu()
if (state) {
desktopSiteButton().check(matches(isChecked()))
} else desktopSiteButton().check(matches(not(isChecked())))
}
fun verifyPageThreeDotMainMenuItems() { fun verifyPageThreeDotMainMenuItems() {
verifyNewTabButton() verifyNewTabButton()
verifyBookmarksButton() verifyBookmarksButton()
@ -139,7 +143,7 @@ class ThreeDotMenuMainRobot {
} }
fun openDownloadsManager(interact: DownloadRobot.() -> Unit): DownloadRobot.Transition { fun openDownloadsManager(interact: DownloadRobot.() -> Unit): DownloadRobot.Transition {
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(swipeDown()) threeDotMenuRecyclerView().perform(swipeDown())
downloadsButton().click() downloadsButton().click()
DownloadRobot().interact() DownloadRobot().interact()
@ -147,7 +151,7 @@ class ThreeDotMenuMainRobot {
} }
fun openSyncSignIn(interact: SyncSignInRobot.() -> Unit): SyncSignInRobot.Transition { fun openSyncSignIn(interact: SyncSignInRobot.() -> Unit): SyncSignInRobot.Transition {
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(swipeDown()) threeDotMenuRecyclerView().perform(swipeDown())
mDevice.waitNotNull(Until.findObject(By.text("Sign in to sync")), waitingTime) mDevice.waitNotNull(Until.findObject(By.text("Sign in to sync")), waitingTime)
signInToSyncButton().click() signInToSyncButton().click()
@ -156,7 +160,7 @@ class ThreeDotMenuMainRobot {
} }
fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition { fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(swipeDown()) threeDotMenuRecyclerView().perform(swipeDown())
mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime) mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime)
bookmarksButton().click() bookmarksButton().click()
@ -167,7 +171,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(swipeDown()) threeDotMenuRecyclerView().perform(swipeDown())
mDevice.waitNotNull(Until.findObject(By.text("History")), waitingTime) mDevice.waitNotNull(Until.findObject(By.text("History")), waitingTime)
historyButton().click() historyButton().click()
@ -185,6 +189,7 @@ class ThreeDotMenuMainRobot {
fun sharePage(interact: LibrarySubMenusMultipleSelectionToolbarRobot.() -> Unit): LibrarySubMenusMultipleSelectionToolbarRobot.Transition { fun sharePage(interact: LibrarySubMenusMultipleSelectionToolbarRobot.() -> Unit): LibrarySubMenusMultipleSelectionToolbarRobot.Transition {
shareButton().click() shareButton().click()
LibrarySubMenusMultipleSelectionToolbarRobot().interact() LibrarySubMenusMultipleSelectionToolbarRobot().interact()
return LibrarySubMenusMultipleSelectionToolbarRobot.Transition() return LibrarySubMenusMultipleSelectionToolbarRobot.Transition()
} }
@ -205,10 +210,7 @@ class ThreeDotMenuMainRobot {
} }
fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
// Close three dot backButton().click()
mDevice.pressBack()
// Nav back to previous page
mDevice.pressBack()
BrowserRobot().interact() BrowserRobot().interact()
return BrowserRobot.Transition() return BrowserRobot.Transition()
@ -238,14 +240,6 @@ class ThreeDotMenuMainRobot {
return BrowserRobot.Transition() return BrowserRobot.Transition()
} }
fun stopPageLoad(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitNotNull(Until.findObject(By.desc("Stop")), waitingTime)
stopLoadingButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
fun closeAllTabs(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { fun closeAllTabs(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
closeAllTabsButton().click() closeAllTabsButton().click()
@ -254,6 +248,8 @@ class ThreeDotMenuMainRobot {
} }
fun openReportSiteIssue(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun openReportSiteIssue(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp())
reportSiteIssueButton().click() reportSiteIssueButton().click()
BrowserRobot().interact() BrowserRobot().interact()
@ -261,7 +257,8 @@ 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(swipeDown()) threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp())
mDevice.waitNotNull(Until.findObject(By.text("Find in page")), waitingTime) mDevice.waitNotNull(Until.findObject(By.text("Find in page")), waitingTime)
findInPageButton().click() findInPageButton().click()
@ -278,11 +275,8 @@ class ThreeDotMenuMainRobot {
} }
fun openReaderViewAppearance(interact: ReaderViewRobot.() -> Unit): ReaderViewRobot.Transition { fun openReaderViewAppearance(interact: ReaderViewRobot.() -> Unit): ReaderViewRobot.Transition {
var maxSwipes = 3 threeDotMenuRecyclerView().perform(swipeUp())
while (!readerViewAppearanceToggle().exists() && maxSwipes != 0) { threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
readerViewAppearanceToggle().click() readerViewAppearanceToggle().click()
ReaderViewRobot().interact() ReaderViewRobot().interact()
@ -305,11 +299,8 @@ class ThreeDotMenuMainRobot {
} }
fun clickInstall(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenRobot.Transition { fun clickInstall(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenRobot.Transition {
var maxSwipes = 3 threeDotMenuRecyclerView().perform(swipeUp())
while (!installPWAButton().exists() && maxSwipes != 0) { threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
installPWAButton().click() installPWAButton().click()
AddToHomeScreenRobot().interact() AddToHomeScreenRobot().interact()
@ -318,9 +309,8 @@ class ThreeDotMenuMainRobot {
fun openSaveToCollection(interact: CollectionRobot.() -> Unit): CollectionRobot.Transition { fun openSaveToCollection(interact: CollectionRobot.() -> Unit): CollectionRobot.Transition {
// Ensure the menu is expanded and fully scrolled to the bottom. // Ensure the menu is expanded and fully scrolled to the bottom.
for (i in 0..3) { threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp()) 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()
@ -337,6 +327,24 @@ class ThreeDotMenuMainRobot {
SettingsSubMenuAddonsManagerRobot().interact() SettingsSubMenuAddonsManagerRobot().interact()
return SettingsSubMenuAddonsManagerRobot.Transition() return SettingsSubMenuAddonsManagerRobot.Transition()
} }
fun clickOpenInApp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp())
openInAppButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
fun switchDesktopSiteMode(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
threeDotMenuRecyclerView().perform(swipeUp())
threeDotMenuRecyclerView().perform(swipeUp())
desktopSiteButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
} }
} }
private fun threeDotMenuRecyclerView() = private fun threeDotMenuRecyclerView() =
@ -373,6 +381,8 @@ private fun assertHelpButton() = helpButton()
private fun forwardButton() = mDevice.findObject(UiSelector().description("Forward")) private fun forwardButton() = mDevice.findObject(UiSelector().description("Forward"))
private fun assertForwardButton() = assertTrue(forwardButton().waitForExists(waitingTime)) 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 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())
@ -488,13 +498,20 @@ private fun assertAddToMobileHome() {
private fun installPWAButton() = mDevice.findObject(UiSelector().text("Install")) private fun installPWAButton() = mDevice.findObject(UiSelector().text("Install"))
private fun desktopSiteButton() = private fun desktopSiteButton() = onView(withId(R.id.switch_widget))
onView(allOf(withText(R.string.browser_menu_desktop_site)))
private fun assertDesktopSite() { private fun assertDesktopSite() {
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeUp()) threeDotMenuRecyclerView().perform(swipeUp())
desktopSiteButton().check(matches(isDisplayed())) desktopSiteButton().check(matches(isDisplayed()))
} }
private fun openInAppButton() =
onView(
allOf(
withText("Open in app"),
withEffectiveVisibility(Visibility.VISIBLE)
)
)
private fun downloadsButton() = onView(withText(R.string.library_downloads)) private fun downloadsButton() = onView(withText(R.string.library_downloads))
private fun assertDownloadsButton() { private fun assertDownloadsButton() {
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown()) onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown())