Bug 1884363 - Remove redundant assertion functions from ThreeDotMenuMainRobot

fenix/125.0
AndiAJ 3 months ago committed by mergify[bot]
parent 2b246de4f7
commit a6755ca5df

@ -52,14 +52,31 @@ import org.mozilla.fenix.nimbus.FxNimbus
*/ */
@Suppress("ForbiddenComment") @Suppress("ForbiddenComment")
class ThreeDotMenuMainRobot { class ThreeDotMenuMainRobot {
fun verifyShareAllTabsButton() = assertShareAllTabsButton() fun verifyShareAllTabsButton() = shareAllTabsButton().check(matches(isDisplayed()))
fun verifySettingsButton() = assertUIObjectExists(settingsButton()) fun verifySettingsButton() = assertUIObjectExists(settingsButton())
fun verifyHistoryButton() = assertUIObjectExists(historyButton()) fun verifyHistoryButton() = assertUIObjectExists(historyButton())
fun verifyThreeDotMenuExists() = threeDotMenuRecyclerViewExists() fun verifyThreeDotMenuExists() = threeDotMenuRecyclerView().check(matches(isDisplayed()))
fun verifyAddBookmarkButton() = assertUIObjectExists(addBookmarkButton()) fun verifyAddBookmarkButton() = assertUIObjectExists(addBookmarkButton())
fun verifyEditBookmarkButton() = assertEditBookmarkButton() fun verifyEditBookmarkButton() =
fun verifyCloseAllTabsButton() = assertCloseAllTabsButton() editBookmarkButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyReaderViewAppearance(visible: Boolean) = assertReaderViewAppearanceButton(visible) fun verifyCloseAllTabsButton() =
closeAllTabsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyReaderViewAppearance(visible: Boolean) {
var maxSwipes = 3
if (visible) {
while (!readerViewAppearanceToggle().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
assertUIObjectExists(readerViewAppearanceToggle())
} else {
while (!readerViewAppearanceToggle().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
assertUIObjectExists(readerViewAppearanceToggle(), exists = false)
}
}
fun verifyQuitButtonExists() { fun verifyQuitButtonExists() {
// Need to double swipe the menu, to make this button visible. // Need to double swipe the menu, to make this button visible.
@ -73,14 +90,25 @@ class ThreeDotMenuMainRobot {
onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeUp()) onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeUp())
} }
fun verifyShareTabButton() = assertShareTabButton() fun verifyShareTabButton() = shareTabButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifySelectTabs() = assertSelectTabsButton() fun verifySelectTabs() = selectTabsButton().check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyFindInPageButton() = assertUIObjectExists(findInPageButton()) fun verifyFindInPageButton() = assertUIObjectExists(findInPageButton())
fun verifyAddToShortcutsButton(shouldExist: Boolean) = fun verifyAddToShortcutsButton(shouldExist: Boolean) =
assertUIObjectExists(addToShortcutsButton(), exists = shouldExist) assertUIObjectExists(addToShortcutsButton(), exists = shouldExist)
fun verifyRemoveFromShortcutsButton() = assertRemoveFromShortcutsButton() fun verifyRemoveFromShortcutsButton() =
fun verifyShareTabsOverlay() = assertShareTabsOverlay() onView(withId(R.id.mozac_browser_menu_recyclerView))
.perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
hasDescendant(withText(R.string.browser_menu_settings)),
),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyShareTabsOverlay() {
onView(withId(R.id.shared_site_list)).check(matches(isDisplayed()))
onView(withId(R.id.share_tab_title)).check(matches(isDisplayed()))
onView(withId(R.id.share_tab_favicon)).check(matches(isDisplayed()))
onView(withId(R.id.share_tab_url)).check(matches(isDisplayed()))
}
fun verifyDesktopSiteModeEnabled(isRequestDesktopSiteEnabled: Boolean) { fun verifyDesktopSiteModeEnabled(isRequestDesktopSiteEnabled: Boolean) {
expandMenu() expandMenu()
@ -139,13 +167,6 @@ class ThreeDotMenuMainRobot {
) )
} }
private fun assertShareTabsOverlay() {
onView(withId(R.id.shared_site_list)).check(matches(isDisplayed()))
onView(withId(R.id.share_tab_title)).check(matches(isDisplayed()))
onView(withId(R.id.share_tab_favicon)).check(matches(isDisplayed()))
onView(withId(R.id.share_tab_url)).check(matches(isDisplayed()))
}
fun openAddonsSubList() { fun openAddonsSubList() {
// when there are add-ons installed, there is an overflow Add-ons sub-menu // when there are add-ons installed, there is an overflow Add-ons sub-menu
// in that case we use this method instead or before openAddonsManagerMenu() // in that case we use this method instead or before openAddonsManagerMenu()
@ -493,60 +514,22 @@ class ThreeDotMenuMainRobot {
private fun threeDotMenuRecyclerView() = private fun threeDotMenuRecyclerView() =
onView(withId(R.id.mozac_browser_menu_recyclerView)) onView(withId(R.id.mozac_browser_menu_recyclerView))
private fun threeDotMenuRecyclerViewExists() {
threeDotMenuRecyclerView().check(matches(isDisplayed()))
}
private fun editBookmarkButton() = onView(withText("Edit")) private fun editBookmarkButton() = onView(withText("Edit"))
private fun assertEditBookmarkButton() = editBookmarkButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun stopLoadingButton() = onView(ViewMatchers.withContentDescription("Stop")) private fun stopLoadingButton() = onView(ViewMatchers.withContentDescription("Stop"))
private fun closeAllTabsButton() = onView(allOf(withText("Close all tabs"))).inRoot(RootMatchers.isPlatformPopup()) private fun closeAllTabsButton() = onView(allOf(withText("Close all tabs"))).inRoot(RootMatchers.isPlatformPopup())
private fun assertCloseAllTabsButton() = closeAllTabsButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun shareTabButton() = onView(allOf(withText("Share all tabs"))).inRoot(RootMatchers.isPlatformPopup()) private fun shareTabButton() = onView(allOf(withText("Share all tabs"))).inRoot(RootMatchers.isPlatformPopup())
private fun assertShareTabButton() = shareTabButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun selectTabsButton() = onView(allOf(withText("Select tabs"))).inRoot(RootMatchers.isPlatformPopup()) private fun selectTabsButton() = onView(allOf(withText("Select tabs"))).inRoot(RootMatchers.isPlatformPopup())
private fun assertSelectTabsButton() = selectTabsButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun readerViewAppearanceToggle() = private fun readerViewAppearanceToggle() =
mDevice.findObject(UiSelector().text("Customize reader view")) 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--
}
assertUIObjectExists(readerViewAppearanceToggle())
} else {
while (!readerViewAppearanceToggle().exists() && maxSwipes != 0) {
threeDotMenuRecyclerView().perform(swipeUp())
maxSwipes--
}
assertUIObjectExists(readerViewAppearanceToggle(), exists = false)
}
}
private fun removeFromShortcutsButton() = private fun removeFromShortcutsButton() =
onView(allOf(withText(R.string.browser_menu_remove_from_shortcuts))) onView(allOf(withText(R.string.browser_menu_remove_from_shortcuts)))
private fun assertRemoveFromShortcutsButton() {
onView(withId(R.id.mozac_browser_menu_recyclerView))
.perform(
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
hasDescendant(withText(R.string.browser_menu_settings)),
),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun installPWAButton() = mDevice.findObject(UiSelector().text("Install")) private fun installPWAButton() = mDevice.findObject(UiSelector().text("Install"))
private fun openInAppButton() = private fun openInAppButton() =
@ -565,13 +548,6 @@ private fun clickAddonsManagerButton() {
private fun shareAllTabsButton() = private fun shareAllTabsButton() =
onView(allOf(withText("Share all tabs"))).inRoot(RootMatchers.isPlatformPopup()) onView(allOf(withText("Share all tabs"))).inRoot(RootMatchers.isPlatformPopup())
private fun assertShareAllTabsButton() {
shareAllTabsButton()
.check(
matches(isDisplayed()),
)
}
private fun bookmarksButton() = private fun bookmarksButton() =
itemContainingText(getStringResource(R.string.library_bookmarks)) itemContainingText(getStringResource(R.string.library_bookmarks))
private fun historyButton() = private fun historyButton() =

Loading…
Cancel
Save