No Issue: Verify the page main menu items UI Test (#12336)
parent
cba27a3883
commit
1926ddbc22
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package org.mozilla.fenix.ui
|
package org.mozilla.fenix.ui
|
||||||
|
|
||||||
|
import androidx.core.net.toUri
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.uiautomator.UiDevice
|
import androidx.test.uiautomator.UiDevice
|
||||||
import okhttp3.mockwebserver.MockWebServer
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
|
@ -62,4 +63,158 @@ class SmokeTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyPageMainMenuItemsListInPortraitNormalModeTest() {
|
||||||
|
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
// Add this to check openInApp and youtube is a default app available in every Android emulator/device
|
||||||
|
val youtubeUrl = "www.youtube.com"
|
||||||
|
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
verifyThreeDotMainMenuItems()
|
||||||
|
verifySaveCollection()
|
||||||
|
}.clickAddOnsReportSiteIssue {
|
||||||
|
verifyUrl("webcompat.com/issues/new")
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openTab(defaultWebPage.title) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openHistory {
|
||||||
|
verifyTestPageUrl(defaultWebPage.url)
|
||||||
|
}.goBackToBrowser {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openBookmarks {
|
||||||
|
verifyBookmarksMenuView()
|
||||||
|
verifyEmptyBookmarksList()
|
||||||
|
}.goBackToBrowser {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSyncedTabs {
|
||||||
|
verifyNavigationToolBarHeader()
|
||||||
|
verifySyncedTabsStatus()
|
||||||
|
}.goBack {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSettings {
|
||||||
|
verifySettingsView()
|
||||||
|
}.goBackToBrowser {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openFindInPage {
|
||||||
|
verifyFindInPageSearchBarItems()
|
||||||
|
}.closeFindInPage {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.addToFirefoxHome {
|
||||||
|
verifySnackBarText("Added to top sites!")
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openHomeScreen {
|
||||||
|
verifyExistingTopSitesTabs(defaultWebPage.title)
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openTab(defaultWebPage.title) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openAddToHomeScreen {
|
||||||
|
verifyShortcutNameField(defaultWebPage.title)
|
||||||
|
clickAddShortcutButton()
|
||||||
|
clickAddAutomaticallyButton()
|
||||||
|
}.openHomeScreenShortcut(defaultWebPage.title) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSaveToCollection {
|
||||||
|
verifyCollectionNameTextField()
|
||||||
|
}.goBackToBrowser {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.bookmarkPage {
|
||||||
|
verifySnackBarText("Bookmark saved!")
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.sharePage {
|
||||||
|
verifyShareAppsLayout()
|
||||||
|
}.closeShareDialogReturnToPage {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.refreshPage {
|
||||||
|
verifyUrl(defaultWebPage.url.toString())
|
||||||
|
}.openTabDrawer {
|
||||||
|
closeTabViaXButton(defaultWebPage.title)
|
||||||
|
}.openHomeScreen {
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(youtubeUrl.toUri()) {
|
||||||
|
verifyBlueDot()
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
verifyOpenInAppButton()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun verifyPageMainMenuItemsListInPortraitPrivateModeTest() {
|
||||||
|
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||||
|
// Add this to check openInApp and also youtube is a default app available in every Android emulator/device
|
||||||
|
val youtubeUrl = "www.youtube.com"
|
||||||
|
|
||||||
|
homeScreen {
|
||||||
|
togglePrivateBrowsingModeOnOff()
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
verifyThreeDotMainMenuItems()
|
||||||
|
}.clickAddOnsReportSiteIssue {
|
||||||
|
verifyUrl("webcompat.com/issues/new")
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openTab(defaultWebPage.title) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openHistory {
|
||||||
|
verifyEmptyHistoryView()
|
||||||
|
}.goBackToBrowser {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openBookmarks {
|
||||||
|
verifyBookmarksMenuView()
|
||||||
|
verifyEmptyBookmarksList()
|
||||||
|
}.goBackToBrowser {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSyncedTabs {
|
||||||
|
verifyNavigationToolBarHeader()
|
||||||
|
verifySyncedTabsStatus()
|
||||||
|
}.goBack {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSettings {
|
||||||
|
verifySettingsView()
|
||||||
|
}.goBackToBrowser {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openFindInPage {
|
||||||
|
verifyFindInPageSearchBarItems()
|
||||||
|
}.closeFindInPage {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.addToFirefoxHome {
|
||||||
|
verifySnackBarText("Added to top sites!")
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openHomeScreen {
|
||||||
|
togglePrivateBrowsingModeOnOff()
|
||||||
|
verifyExistingTopSitesTabs(defaultWebPage.title)
|
||||||
|
togglePrivateBrowsingModeOnOff()
|
||||||
|
}.openTabDrawer {
|
||||||
|
}.openTab(defaultWebPage.title) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openAddToHomeScreen {
|
||||||
|
verifyShortcutNameField(defaultWebPage.title)
|
||||||
|
clickAddShortcutButton()
|
||||||
|
clickAddAutomaticallyButton()
|
||||||
|
}.openHomeScreenShortcut(defaultWebPage.title) {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.bookmarkPage {
|
||||||
|
verifySnackBarText("Bookmark saved!")
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.sharePage {
|
||||||
|
verifyShareAppsLayout()
|
||||||
|
}.closeShareDialogReturnToPage {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.refreshPage {
|
||||||
|
verifyUrl(defaultWebPage.url.toString())
|
||||||
|
}.openTabDrawer {
|
||||||
|
closeTabViaXButton(defaultWebPage.title)
|
||||||
|
}.openHomeScreen {
|
||||||
|
navigationToolbar {
|
||||||
|
}.enterURLAndEnterToBrowser(youtubeUrl.toUri()) {
|
||||||
|
verifyBlueDot()
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
verifyOpenInAppButton()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,19 @@ import android.os.Build
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.clearText
|
import androidx.test.espresso.action.ViewActions.clearText
|
||||||
import androidx.test.espresso.action.ViewActions.typeText
|
import androidx.test.espresso.action.ViewActions.typeText
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||||
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.uiautomator.By
|
import androidx.test.uiautomator.By
|
||||||
|
import androidx.test.uiautomator.By.text
|
||||||
import androidx.test.uiautomator.By.textContains
|
import androidx.test.uiautomator.By.textContains
|
||||||
import androidx.test.uiautomator.UiScrollable
|
import androidx.test.uiautomator.UiScrollable
|
||||||
import androidx.test.uiautomator.UiSelector
|
import androidx.test.uiautomator.UiSelector
|
||||||
import androidx.test.uiautomator.Until
|
import androidx.test.uiautomator.Until
|
||||||
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
import org.hamcrest.CoreMatchers.anyOf
|
import org.hamcrest.CoreMatchers.anyOf
|
||||||
|
import org.junit.Assert
|
||||||
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
|
||||||
|
@ -26,6 +31,8 @@ import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||||
*/
|
*/
|
||||||
class AddToHomeScreenRobot {
|
class AddToHomeScreenRobot {
|
||||||
|
|
||||||
|
fun verifyShortcutIcon() = assertShortcutIcon()
|
||||||
|
|
||||||
fun addShortcutName(title: String) {
|
fun addShortcutName(title: String) {
|
||||||
mDevice.waitNotNull(Until.findObject(By.text("Add to Home screen")), waitingTime)
|
mDevice.waitNotNull(Until.findObject(By.text("Add to Home screen")), waitingTime)
|
||||||
shortcutNameField()
|
shortcutNameField()
|
||||||
|
@ -33,6 +40,8 @@ class AddToHomeScreenRobot {
|
||||||
.perform(typeText(title))
|
.perform(typeText(title))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun verifyShortcutNameField(expectedText: String) = assertShortcutNameField(expectedText)
|
||||||
|
|
||||||
fun clickAddShortcutButton() = addButton().click()
|
fun clickAddShortcutButton() = addButton().click()
|
||||||
|
|
||||||
fun clickAddAutomaticallyButton() {
|
fun clickAddAutomaticallyButton() {
|
||||||
|
@ -77,7 +86,21 @@ fun addToHomeScreen(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenR
|
||||||
|
|
||||||
private fun shortcutNameField() = onView(withId(R.id.shortcut_text))
|
private fun shortcutNameField() = onView(withId(R.id.shortcut_text))
|
||||||
|
|
||||||
|
private fun assertShortcutNameField(expectedText: String) {
|
||||||
|
onView(allOf(withId(R.id.shortcut_text),
|
||||||
|
withText(expectedText)))
|
||||||
|
.check(matches(isCompletelyDisplayed()))
|
||||||
|
}
|
||||||
|
|
||||||
private fun addButton() = onView(anyOf(withText("ADD")))
|
private fun addButton() = onView(anyOf(withText("ADD")))
|
||||||
|
|
||||||
private fun addAutomaticallyButton() =
|
private fun addAutomaticallyButton() =
|
||||||
mDevice.findObject(UiSelector().textContains("add automatically"))
|
mDevice.findObject(UiSelector().textContains("add automatically"))
|
||||||
|
|
||||||
|
private fun assertShortcutIcon() {
|
||||||
|
mDevice.wait(
|
||||||
|
Until.findObject(text("Firefox Preview")),
|
||||||
|
waitingTime
|
||||||
|
)
|
||||||
|
Assert.assertTrue(mDevice.hasObject(By.text("Firefox Preview")))
|
||||||
|
}
|
||||||
|
|
|
@ -132,6 +132,8 @@ class BookmarksRobot {
|
||||||
addFolderButton().click()
|
addFolderButton().click()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clickdeleteBookmarkButton() = deleteBookmarkButton().click()
|
||||||
|
|
||||||
fun addNewFolderName(name: String) {
|
fun addNewFolderName(name: String) {
|
||||||
addFolderTitleField()
|
addFolderTitleField()
|
||||||
.click()
|
.click()
|
||||||
|
@ -188,6 +190,23 @@ class BookmarksRobot {
|
||||||
return Transition()
|
return Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
closeButton().click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun confirmBookmarkFolderDeletionAndGoBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
onView(withText(R.string.delete_browsing_data_prompt_allow))
|
||||||
|
.inRoot(RootMatchers.isDialog())
|
||||||
|
.check(matches(isDisplayed()))
|
||||||
|
.click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
fun openThreeDotMenu(interact: ThreeDotMenuBookmarksRobot.() -> Unit): ThreeDotMenuBookmarksRobot.Transition {
|
fun openThreeDotMenu(interact: ThreeDotMenuBookmarksRobot.() -> Unit): ThreeDotMenuBookmarksRobot.Transition {
|
||||||
mDevice.waitNotNull(Until.findObject(res("org.mozilla.fenix.debug:id/overflow_menu")))
|
mDevice.waitNotNull(Until.findObject(res("org.mozilla.fenix.debug:id/overflow_menu")))
|
||||||
threeDotMenu().click()
|
threeDotMenu().click()
|
||||||
|
@ -248,6 +267,8 @@ private fun addFolderTitleField() = onView(withId(R.id.bookmarkNameEdit))
|
||||||
|
|
||||||
private fun saveFolderButton() = onView(withId(R.id.confirm_add_folder_button))
|
private fun saveFolderButton() = onView(withId(R.id.confirm_add_folder_button))
|
||||||
|
|
||||||
|
private fun deleteBookmarkButton() = onView(withId(R.id.delete_bookmark_button))
|
||||||
|
|
||||||
private fun threeDotMenu(bookmarkUrl: Uri) = onView(
|
private fun threeDotMenu(bookmarkUrl: Uri) = onView(
|
||||||
allOf(
|
allOf(
|
||||||
withId(R.id.overflow_menu),
|
withId(R.id.overflow_menu),
|
||||||
|
|
|
@ -157,6 +157,8 @@ class BrowserRobot {
|
||||||
|
|
||||||
fun verifyMenuButton() = assertMenuButton()
|
fun verifyMenuButton() = assertMenuButton()
|
||||||
|
|
||||||
|
fun verifyBlueDot() = assertBlueDot()
|
||||||
|
|
||||||
fun verifyNavURLBarItems() {
|
fun verifyNavURLBarItems() {
|
||||||
verifyEnhancedTrackingOptions()
|
verifyEnhancedTrackingOptions()
|
||||||
pressBack()
|
pressBack()
|
||||||
|
@ -448,3 +450,10 @@ private fun mediaPlayerPlayButton() =
|
||||||
.clazz("android.widget.Button")
|
.clazz("android.widget.Button")
|
||||||
.textContains("Play")
|
.textContains("Play")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun assertBlueDot() {
|
||||||
|
onView(withId(R.id.notification_dot))
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addOnsReportSiteIssue() = onView(withText("Report Site Issue"))
|
||||||
|
|
|
@ -29,10 +29,18 @@ class FindInPageRobot {
|
||||||
|
|
||||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||||
|
|
||||||
|
fun verifyFindInPageQuery() = assertFindInPageQuery()!!
|
||||||
fun verifyFindInPageNextButton() = assertFindInPageNextButton()!!
|
fun verifyFindInPageNextButton() = assertFindInPageNextButton()!!
|
||||||
fun verifyFindInPagePrevButton() = assertFindInPagePrevButton()!!
|
fun verifyFindInPagePrevButton() = assertFindInPagePrevButton()!!
|
||||||
fun verifyFindInPageCloseButton() = assertFindInPageCloseButton()!!
|
fun verifyFindInPageCloseButton() = assertFindInPageCloseButton()!!
|
||||||
|
|
||||||
|
fun verifyFindInPageSearchBarItems() {
|
||||||
|
verifyFindInPageQuery()
|
||||||
|
verifyFindInPageNextButton()
|
||||||
|
verifyFindInPagePrevButton()
|
||||||
|
verifyFindInPageCloseButton()
|
||||||
|
}
|
||||||
|
|
||||||
fun enterFindInPageQuery(expectedText: String) {
|
fun enterFindInPageQuery(expectedText: String) {
|
||||||
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/find_in_page_query_text")), waitingTime)
|
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/find_in_page_query_text")), waitingTime)
|
||||||
findInPageQuery().perform(clearText())
|
findInPageQuery().perform(clearText())
|
||||||
|
@ -73,6 +81,9 @@ private fun findInPageNextButton() = onView(withId(R.id.find_in_page_next_btn))
|
||||||
private fun findInPagePrevButton() = onView(withId(R.id.find_in_page_prev_btn))
|
private fun findInPagePrevButton() = onView(withId(R.id.find_in_page_prev_btn))
|
||||||
private fun findInPageCloseButton() = onView(withId(R.id.find_in_page_close_btn))
|
private fun findInPageCloseButton() = onView(withId(R.id.find_in_page_close_btn))
|
||||||
|
|
||||||
|
private fun assertFindInPageQuery() = findInPageQuery()
|
||||||
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||||
|
|
||||||
private fun assertFindInPageNextButton() = findInPageNextButton()
|
private fun assertFindInPageNextButton() = findInPageNextButton()
|
||||||
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,13 @@ class HistoryRobot {
|
||||||
return Transition()
|
return Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
closeButton().click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
fun openThreeDotMenu(interact: ThreeDotMenuHistoryItemRobot.() -> Unit):
|
fun openThreeDotMenu(interact: ThreeDotMenuHistoryItemRobot.() -> Unit):
|
||||||
ThreeDotMenuHistoryItemRobot.Transition {
|
ThreeDotMenuHistoryItemRobot.Transition {
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
package org.mozilla.fenix.ui.robots
|
package org.mozilla.fenix.ui.robots
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
@ -14,12 +15,14 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withParent
|
import androidx.test.espresso.matcher.ViewMatchers.withParent
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withChild
|
import androidx.test.espresso.matcher.ViewMatchers.withChild
|
||||||
import androidx.test.uiautomator.By
|
import androidx.test.uiautomator.By
|
||||||
|
import androidx.test.uiautomator.UiSelector
|
||||||
import androidx.test.uiautomator.Until
|
import androidx.test.uiautomator.Until
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||||
import org.mozilla.fenix.helpers.click
|
import org.mozilla.fenix.helpers.click
|
||||||
import org.mozilla.fenix.helpers.ext.waitNotNull
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||||
import org.hamcrest.Matchers.allOf
|
import org.hamcrest.Matchers.allOf
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation of Robot Pattern for the multiple selection toolbar of History and Bookmarks menus.
|
* Implementation of Robot Pattern for the multiple selection toolbar of History and Bookmarks menus.
|
||||||
|
@ -38,6 +41,8 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
|
||||||
|
|
||||||
fun verifyShareOverlay() = assertShareOverlay()
|
fun verifyShareOverlay() = assertShareOverlay()
|
||||||
|
|
||||||
|
fun verifyShareAppsLayout() = assertShareAppsLayout()
|
||||||
|
|
||||||
fun verifyShareTabFavicon() = assertShareTabFavicon()
|
fun verifyShareTabFavicon() = assertShareTabFavicon()
|
||||||
|
|
||||||
fun verifyShareTabTitle() = assertShareTabTitle()
|
fun verifyShareTabTitle() = assertShareTabTitle()
|
||||||
|
@ -71,6 +76,12 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Transition {
|
class Transition {
|
||||||
|
fun closeShareDialogReturnToPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
fun closeToolbarReturnToHistory(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
|
fun closeToolbarReturnToHistory(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
|
||||||
closeToolbarButton().click()
|
closeToolbarButton().click()
|
||||||
|
|
||||||
|
@ -158,6 +169,15 @@ private fun assertShareBookmarksButton() =
|
||||||
private fun assertShareOverlay() =
|
private fun assertShareOverlay() =
|
||||||
onView(withId(R.id.shareWrapper)).check(matches(isDisplayed()))
|
onView(withId(R.id.shareWrapper)).check(matches(isDisplayed()))
|
||||||
|
|
||||||
|
private fun assertShareAppsLayout() = {
|
||||||
|
val sendToDeviceTitle = mDevice.findObject(
|
||||||
|
UiSelector()
|
||||||
|
.instance(0)
|
||||||
|
.className(TextView::class.java)
|
||||||
|
)
|
||||||
|
sendToDeviceTitle.waitForExists(TestAssetHelper.waitingTime)
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertShareTabTitle() =
|
private fun assertShareTabTitle() =
|
||||||
onView(withId(R.id.share_tab_title)).check(matches(isDisplayed()))
|
onView(withId(R.id.share_tab_title)).check(matches(isDisplayed()))
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,13 @@ class SettingsRobot {
|
||||||
return HomeScreenRobot.Transition()
|
return HomeScreenRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
goBackButton().click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
fun openAboutFirefoxPreview(interact: SettingsSubMenuAboutRobot.() -> Unit):
|
fun openAboutFirefoxPreview(interact: SettingsSubMenuAboutRobot.() -> Unit):
|
||||||
SettingsSubMenuAboutRobot.Transition {
|
SettingsSubMenuAboutRobot.Transition {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
package org.mozilla.fenix.ui.robots
|
||||||
|
|
||||||
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.uiautomator.UiDevice
|
||||||
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.helpers.click
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of Robot Pattern for Synced Tabs sub menu.
|
||||||
|
*/
|
||||||
|
class SyncedTabsRobot {
|
||||||
|
|
||||||
|
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
|
||||||
|
|
||||||
|
fun verifySyncedTabsStatus() = assertSyncedTabsStatus()
|
||||||
|
|
||||||
|
class Transition {
|
||||||
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||||
|
|
||||||
|
fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
goBackButton().click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun goBackButton() =
|
||||||
|
onView(allOf(withContentDescription("Navigate up")))
|
||||||
|
|
||||||
|
private fun assertNavigationToolBarHeader() {
|
||||||
|
onView(withText(R.string.synced_tabs))
|
||||||
|
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun assertSyncedTabsStatus() {
|
||||||
|
onView(withResourceName("sync_tabs_status"))
|
||||||
|
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ package org.mozilla.fenix.ui.robots
|
||||||
import android.view.View
|
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.UiController
|
||||||
import androidx.test.espresso.ViewAction
|
import androidx.test.espresso.ViewAction
|
||||||
import androidx.test.espresso.action.ViewActions
|
import androidx.test.espresso.action.ViewActions
|
||||||
|
@ -44,8 +45,10 @@ import org.mozilla.fenix.share.ShareFragment
|
||||||
*/
|
*/
|
||||||
class ThreeDotMenuMainRobot {
|
class ThreeDotMenuMainRobot {
|
||||||
fun verifySettingsButton() = assertSettingsButton()
|
fun verifySettingsButton() = assertSettingsButton()
|
||||||
|
fun verifyAddOnsButton() = assertAddOnsButton()
|
||||||
fun verifyHistoryButton() = assertHistoryButton()
|
fun verifyHistoryButton() = assertHistoryButton()
|
||||||
fun verifyBookmarksButton() = assertBookmarksButton()
|
fun verifyBookmarksButton() = assertBookmarksButton()
|
||||||
|
fun verifySyncedTabsButton() = assertSyncedTabsButton()
|
||||||
fun verifyHelpButton() = assertHelpButton()
|
fun verifyHelpButton() = assertHelpButton()
|
||||||
fun verifyThreeDotMenuExists() = threeDotMenuRecyclerViewExists()
|
fun verifyThreeDotMenuExists() = threeDotMenuRecyclerViewExists()
|
||||||
fun verifyForwardButton() = assertForwardButton()
|
fun verifyForwardButton() = assertForwardButton()
|
||||||
|
@ -106,12 +109,40 @@ class ThreeDotMenuMainRobot {
|
||||||
fun verifyShareALinkTitle() = assertShareALinkTitle()
|
fun verifyShareALinkTitle() = assertShareALinkTitle()
|
||||||
fun verifyWhatsNewButton() = assertWhatsNewButton()
|
fun verifyWhatsNewButton() = assertWhatsNewButton()
|
||||||
fun verifyAddFirefoxHome() = assertAddToFirefoxHome()
|
fun verifyAddFirefoxHome() = assertAddToFirefoxHome()
|
||||||
|
fun verifyAddToMobileHome() = assertAddToMobileHome()
|
||||||
|
fun verifyDesktopSite() = assertDesktopSite()
|
||||||
|
fun verifyOpenInAppButton() = assertOpenInAppButton()
|
||||||
|
|
||||||
|
fun verifyThreeDotMainMenuItems() {
|
||||||
|
verifyAddOnsButton()
|
||||||
|
verifyHistoryButton()
|
||||||
|
verifyBookmarksButton()
|
||||||
|
verifySyncedTabsButton()
|
||||||
|
verifySettingsButton()
|
||||||
|
verifyFindInPageButton()
|
||||||
|
verifyAddFirefoxHome()
|
||||||
|
verifyAddToMobileHome()
|
||||||
|
verifyDesktopSite()
|
||||||
|
verifyAddBookmarkButton()
|
||||||
|
verifyShareButton()
|
||||||
|
verifyForwardButton()
|
||||||
|
verifyRefreshButton()
|
||||||
|
}
|
||||||
|
|
||||||
class Transition {
|
class Transition {
|
||||||
|
|
||||||
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
|
|
||||||
|
fun clickAddOnsReportSiteIssue(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
addOnsButton().click()
|
||||||
|
addOnsReportSiteIssueButton().click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
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())
|
||||||
onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings)))
|
onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings)))
|
||||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
.check(matches(isCompletelyDisplayed()))
|
.check(matches(isCompletelyDisplayed()))
|
||||||
|
@ -121,7 +152,17 @@ class ThreeDotMenuMainRobot {
|
||||||
return SettingsRobot.Transition()
|
return SettingsRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openSyncedTabs(interact: SyncedTabsRobot.() -> Unit): SyncedTabsRobot.Transition {
|
||||||
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.text("Synced tabs")), waitingTime)
|
||||||
|
syncedTabsButton().click()
|
||||||
|
|
||||||
|
SyncedTabsRobot().interact()
|
||||||
|
return SyncedTabsRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
|
fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
|
||||||
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
|
||||||
mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime)
|
mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime)
|
||||||
bookmarksButton().click()
|
bookmarksButton().click()
|
||||||
|
|
||||||
|
@ -130,6 +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(ViewActions.swipeDown())
|
||||||
mDevice.waitNotNull(Until.findObject(By.text("History")), waitingTime)
|
mDevice.waitNotNull(Until.findObject(By.text("History")), waitingTime)
|
||||||
historyButton().click()
|
historyButton().click()
|
||||||
|
|
||||||
|
@ -137,6 +179,23 @@ class ThreeDotMenuMainRobot {
|
||||||
return HistoryRobot.Transition()
|
return HistoryRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun bookmarkPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.desc("Bookmark")), waitingTime)
|
||||||
|
addBookmarkButton().click()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sharePage(interact: LibrarySubMenusMultipleSelectionToolbarRobot.() -> Unit): LibrarySubMenusMultipleSelectionToolbarRobot.Transition {
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.desc("Share")), waitingTime)
|
||||||
|
shareButton().click()
|
||||||
|
pressBack()
|
||||||
|
|
||||||
|
LibrarySubMenusMultipleSelectionToolbarRobot().interact()
|
||||||
|
return LibrarySubMenusMultipleSelectionToolbarRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
fun openHelp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
fun openHelp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
mDevice.waitNotNull(Until.findObject(By.text("Help")), waitingTime)
|
mDevice.waitNotNull(Until.findObject(By.text("Help")), waitingTime)
|
||||||
helpButton().click()
|
helpButton().click()
|
||||||
|
@ -163,6 +222,13 @@ class ThreeDotMenuMainRobot {
|
||||||
return BrowserRobot.Transition()
|
return BrowserRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||||
|
mDevice.pressBack()
|
||||||
|
|
||||||
|
BrowserRobot().interact()
|
||||||
|
return BrowserRobot.Transition()
|
||||||
|
}
|
||||||
|
|
||||||
fun close(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
fun close(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||||
// Close three dot
|
// Close three dot
|
||||||
mDevice.pressBack()
|
mDevice.pressBack()
|
||||||
|
@ -196,6 +262,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())
|
||||||
mDevice.waitNotNull(Until.findObject(By.text("Find in page")), waitingTime)
|
mDevice.waitNotNull(Until.findObject(By.text("Find in page")), waitingTime)
|
||||||
findInPageButton().click()
|
findInPageButton().click()
|
||||||
|
|
||||||
|
@ -274,6 +341,13 @@ class ThreeDotMenuMainRobot {
|
||||||
HomeScreenRobot().interact()
|
HomeScreenRobot().interact()
|
||||||
return HomeScreenRobot.Transition()
|
return HomeScreenRobot.Transition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openSaveToCollection(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
|
||||||
|
mDevice.waitNotNull(Until.findObject(By.text("Save to collection")), waitingTime)
|
||||||
|
saveCollectionButton().click()
|
||||||
|
ThreeDotMenuMainRobot().interact()
|
||||||
|
return ThreeDotMenuMainRobot.Transition()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +360,11 @@ private fun assertSettingsButton() = settingsButton()
|
||||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
.check(matches(isCompletelyDisplayed()))
|
.check(matches(isCompletelyDisplayed()))
|
||||||
|
|
||||||
|
private fun addOnsButton() = onView(allOf(withText("Add-ons")))
|
||||||
|
private fun assertAddOnsButton() = addOnsButton()
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
private fun addOnsReportSiteIssueButton() = onView(allOf(withText("Report Site Issue…")))
|
||||||
|
|
||||||
private fun historyButton() = onView(allOf(withText(R.string.library_history)))
|
private fun historyButton() = onView(allOf(withText(R.string.library_history)))
|
||||||
private fun assertHistoryButton() = historyButton()
|
private fun assertHistoryButton() = historyButton()
|
||||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
@ -294,6 +373,10 @@ private fun bookmarksButton() = onView(allOf(withText(R.string.library_bookmarks
|
||||||
private fun assertBookmarksButton() = bookmarksButton()
|
private fun assertBookmarksButton() = bookmarksButton()
|
||||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
|
||||||
|
private fun syncedTabsButton() = onView(allOf(withText(R.string.library_synced_tabs)))
|
||||||
|
private fun assertSyncedTabsButton() = syncedTabsButton()
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
|
||||||
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)))
|
||||||
|
@ -399,3 +482,36 @@ private fun assertAddToFirefoxHome() {
|
||||||
)
|
)
|
||||||
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
).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 desktopSiteButton() =
|
||||||
|
onView(allOf(withText(R.string.browser_menu_desktop_site)))
|
||||||
|
private fun assertDesktopSite() {
|
||||||
|
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||||
|
.perform(
|
||||||
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||||
|
hasDescendant(withText(R.string.browser_menu_desktop_site))
|
||||||
|
)
|
||||||
|
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openInAppButton() =
|
||||||
|
onView(allOf(withText(R.string.browser_menu_open_app_link)))
|
||||||
|
private fun assertOpenInAppButton() {
|
||||||
|
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||||
|
.perform(
|
||||||
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||||
|
hasDescendant(withText(R.string.browser_menu_open_app_link))
|
||||||
|
)
|
||||||
|
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue