Commit ae407a73 authored by Oana Horvath's avatar Oana Horvath
Browse files

Closes #13217: fixed UI test for main menu items

parent 4570f5a1
......@@ -204,7 +204,7 @@ class SettingsBasicsTest {
checkTextSizeOnWebsite(textSizePercentage, fenixApp.components)
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
}.openThreeDotMenu {
}.openSettings {
}.openAccessibilitySubMenu {
......
......@@ -197,7 +197,7 @@ class SettingsPrivacyTest {
saveLoginFromPrompt("Save")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
}.openThreeDotMenu {
}.openSettings {
TestHelper.scrollToElementByText("Logins and passwords")
......@@ -223,7 +223,7 @@ class SettingsPrivacyTest {
saveLoginFromPrompt("Never save")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
}.openThreeDotMenu {
}.openSettings {
}.openLoginsAndPasswordSubMenu {
......@@ -278,7 +278,7 @@ class SettingsPrivacyTest {
browserScreen {
}.openTabDrawer {
verifyPrivateModeSelected()
}.openNewTab { }.dismiss { }
}.openNewTab { }.dismissSearchBar { }
setOpenLinksInPrivateOff()
......@@ -325,7 +325,7 @@ class SettingsPrivacyTest {
clickAddAutomaticallyButton()
}.openHomeScreenShortcut(pageShortcutName) {
}.openTabDrawer {
}.openNewTab { }.dismiss { }
}.openNewTab { }.dismissSearchBar { }
setOpenLinksInPrivateOff()
restartApp(activityTestRule)
......@@ -336,7 +336,7 @@ class SettingsPrivacyTest {
}.openTabDrawer {
verifyNormalModeSelected()
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
}.openThreeDotMenu {
}.openSettings {
}.openPrivateBrowsingSubMenu {
......
......@@ -4,6 +4,7 @@
package org.mozilla.fenix.ui
import androidx.core.net.toUri
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
......@@ -58,15 +59,14 @@ class SmokeTest {
}.openTabDrawer {
verifyExistingTabList()
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyHomeScreen()
}
}
}
@Ignore("Failing, see: https://github.com/mozilla-mobile/fenix/issues/13217")
@Test
fun verifyPageMainMenuItemsListInPortraitNormalModeTest() {
fun verifyPageMainMenuItemsTest() {
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"
......@@ -75,24 +75,16 @@ class SmokeTest {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
verifyThreeDotMainMenuItems()
verifySaveCollection()
}.clickAddOnsReportSiteIssue {
verifyUrl("webcompat.com/issues/new")
}.openTabDrawer {
}.openTab(defaultWebPage.title) {
}.openThreeDotMenu {
}.openHistory {
verifyTestPageUrl(defaultWebPage.url)
verifyHistoryMenuView()
}.goBackToBrowser {
}.openThreeDotMenu {
}.openBookmarks {
verifyBookmarksMenuView()
verifyEmptyBookmarksList()
}.goBackToBrowser {
}.openThreeDotMenu {
}.openSyncedTabs {
verifyNavigationToolBarHeader()
verifySyncedTabsStatus()
verifySyncedTabsMenuHeader()
}.goBack {
}.openThreeDotMenu {
}.openSettings {
......@@ -107,7 +99,7 @@ class SmokeTest {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyExistingTopSitesTabs(defaultWebPage.title)
}.openTabDrawer {
}.openTab(defaultWebPage.title) {
......@@ -120,7 +112,7 @@ class SmokeTest {
}.openThreeDotMenu {
}.openSaveToCollection {
verifyCollectionNameTextField()
}.goBackToBrowser {
}.exitSaveCollection {
}.openThreeDotMenu {
}.bookmarkPage {
verifySnackBarText("Bookmark saved!")
......@@ -131,93 +123,13 @@ class SmokeTest {
}.openThreeDotMenu {
}.refreshPage {
verifyUrl(defaultWebPage.url.toString())
}.openTabDrawer {
closeTabViaXButton(defaultWebPage.title)
}.openNewTab {
}.submitQuery(youtubeUrl) {
verifyBlueDot()
}.openNavigationToolbar {
}.enterURLAndEnterToBrowser(youtubeUrl.toUri()) {
}.openThreeDotMenu {
verifyOpenInAppButton()
}
}
@Ignore("Failing, see: https://github.com/mozilla-mobile/fenix/issues/13217")
@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 {
}.openNewTab {
}.dismiss {
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)
}.openNewTab {
}.submitQuery(youtubeUrl) {
verifyBlueDot()
}.openThreeDotMenu {
verifyOpenInAppButton()
}
}
}
@Ignore("Flaky test: https://github.com/mozilla-mobile/fenix/issues/12899")
@Test
fun verifyETPToolbarShieldIconIsNotDisplayedIfETPIsOFFGloballyTest() {
......@@ -234,13 +146,6 @@ class SmokeTest {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
verifyEnhancedTrackingProtectionPanelNotVisible()
}.openThreeDotMenu {
}.clickAddOnsReportSiteIssue {
verifyUrl("webcompat.com/issues/new")
verifyTabCounter("2")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openSettings {
}.openEnhancedTrackingProtectionSubMenu {
clickEnhancedTrackingProtectionDefaults()
......
......@@ -188,7 +188,7 @@ class TabbedBrowsingTest {
}.openTabDrawer {
verifyExistingOpenTabs("Test_Page_1")
}.openNewTab {
}.dismiss { }
}.dismissSearchBar { }
}
@Test
......@@ -312,7 +312,7 @@ class TabbedBrowsingTest {
verifyExistingOpenTabs(defaultWebPage.title)
verifyCloseTabsButton(defaultWebPage.title)
}.openNewTab {
}.dismiss { }
}.dismissSearchBar { }
}
@Test
......
......@@ -69,13 +69,13 @@ class ThreeDotMenuMainTest {
verifyHelpUrl()
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
}.openThreeDotMenu {
}.openWhatsNew {
verifyWhatsNewURL()
}.openTabDrawer {
}.openNewTab {
}.dismiss { }
}.dismissSearchBar { }
homeScreen {
}.openThreeDotMenu {
......
......@@ -59,7 +59,7 @@ class TopSitesTest {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}
......@@ -78,14 +78,14 @@ class TopSitesTest {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openTopSiteTabWithTitle(title = defaultWebPageTitle) {
verifyUrl(defaultWebPage.url.toString().replace("http://", ""))
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) {
......@@ -109,7 +109,7 @@ class TopSitesTest {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) {
......@@ -133,7 +133,7 @@ class TopSitesTest {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) {
......@@ -157,7 +157,7 @@ class TopSitesTest {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openNewTab {
}.dismiss {
}.dismissSearchBar {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) {
......
......@@ -155,8 +155,6 @@ class BrowserRobot {
fun verifyMenuButton() = assertMenuButton()
fun verifyBlueDot() = assertBlueDot()
fun verifyNavURLBarItems() {
verifyEnhancedTrackingOptions()
pressBack()
......@@ -453,10 +451,3 @@ private fun mediaPlayerPlayButton() =
.className("android.widget.Button")
.text("Play")
)
private fun assertBlueDot() {
onView(withId(R.id.notification_dot))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun addOnsReportSiteIssue() = onView(withText("Report Site Issue"))
......@@ -87,6 +87,8 @@ class HistoryRobot {
class Transition {
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.pressBack()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
......
......@@ -126,7 +126,7 @@ class SearchRobot {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
private lateinit var sessionLoadedIdlingResource: SessionLoadedIdlingResource
fun dismiss(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
fun dismissSearchBar(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
mDevice.waitForIdle()
mDevice.pressBack()
HomeScreenRobot().interact()
......
......@@ -8,7 +8,6 @@ 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
......@@ -22,9 +21,7 @@ import org.mozilla.fenix.helpers.click
*/
class SyncedTabsRobot {
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
fun verifySyncedTabsStatus() = assertSyncedTabsStatus()
fun verifySyncedTabsMenuHeader() = assertSyncedTabsMenuHeader()
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
......@@ -41,12 +38,7 @@ class SyncedTabsRobot {
private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up")))
private fun assertNavigationToolBarHeader() {
private fun assertSyncedTabsMenuHeader() {
onView(withText(R.string.synced_tabs))
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
}
private fun assertSyncedTabsStatus() {
onView(withResourceName("sync_tabs_status"))
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
}
......@@ -15,6 +15,7 @@ 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
......@@ -114,9 +115,11 @@ class ThreeDotMenuMainRobot {
fun verifyAddToMobileHome() = assertAddToMobileHome()
fun verifyDesktopSite() = assertDesktopSite()
fun verifyOpenInAppButton() = assertOpenInAppButton()
fun verifyDownloadsButton() = assertDownloadsButton()
fun verifyThreeDotMainMenuItems() {
verifyAddOnsButton()
verifyDownloadsButton()
verifyHistoryButton()
verifyBookmarksButton()
verifySyncedTabsButton()
......@@ -125,6 +128,7 @@ class ThreeDotMenuMainRobot {
verifyAddFirefoxHome()
verifyAddToMobileHome()
verifyDesktopSite()
verifySaveCollection()
verifyAddBookmarkButton()
verifyShareButton()
verifyForwardButton()
......@@ -135,14 +139,6 @@ class ThreeDotMenuMainRobot {
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 {
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings)))
......@@ -224,13 +220,6 @@ class ThreeDotMenuMainRobot {
return BrowserRobot.Transition()
}
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.pressBack()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
fun close(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
// Close three dot
mDevice.pressBack()
......@@ -359,6 +348,13 @@ class ThreeDotMenuMainRobot {
SettingsSubMenuAddonsManagerRobot().interact()
return SettingsSubMenuAddonsManagerRobot.Transition()
}
fun exitSaveCollection(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
exitSaveCollectionButton().click()
BrowserRobot().interact()
return BrowserRobot.Transition()
}
}
}
......@@ -372,9 +368,10 @@ private fun assertSettingsButton() = settingsButton()
.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 assertAddOnsButton() {
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown())
addOnsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun historyButton() = onView(allOf(withText(R.string.library_history)))
private fun assertHistoryButton() = historyButton()
......@@ -397,8 +394,10 @@ private fun assertForwardButton() = forwardButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun addBookmarkButton() = onView(ViewMatchers.withContentDescription("Bookmark"))
private fun assertAddBookmarkButton() = addBookmarkButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
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 assertEditBookmarkButton() = editBookmarkButton()
......@@ -454,10 +453,10 @@ private fun SendToDeviceTitle() =
private fun assertSendToDeviceTitle() = SendToDeviceTitle()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun ShareALinkTitle() =
private fun shareALinkTitle() =
onView(allOf(withText("ALL ACTIONS"), withResourceName("apps_link_header")))
private fun assertShareALinkTitle() = ShareALinkTitle()
private fun assertShareALinkTitle() = shareALinkTitle()
private fun whatsNewButton() = onView(
allOf(
......@@ -511,12 +510,8 @@ private fun assertAddToMobileHome() {
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)))
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeUp())
desktopSiteButton().check(matches(isDisplayed()))
}
private fun openInAppButton() =
......@@ -530,9 +525,15 @@ private fun assertOpenInAppButton() {
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun addonsManagerButton() = onView(withText("Add-ons Manager"))
private fun downloadsButton() = onView(withText(R.string.library_downloads))
private fun assertDownloadsButton() {
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown())
downloadsButton().check(matches(isDisplayed()))
}
private fun clickAddonsManagerButton() {
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeDown())
onView(withText("Add-ons")).check(matches(isCompletelyDisplayed())).click()
addOnsButton().check(matches(isCompletelyDisplayed())).click()
}
private fun exitSaveCollectionButton() = onView(withId(R.id.back_button)).check(matches(isDisplayed()))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment