No issue: Add a couple Tabs Tray UI tests
parent
9ed85510ae
commit
661835a35c
|
@ -32,7 +32,9 @@ import org.mozilla.fenix.ui.robots.notificationShade
|
|||
* - Swipe to close tab (temporarily disabled)
|
||||
* - Undo close tab
|
||||
* - Close private tabs persistent notification
|
||||
*
|
||||
* - Empty tab tray state
|
||||
* - Tab tray details
|
||||
* - Shortcut context menu navigation
|
||||
*/
|
||||
|
||||
class TabbedBrowsingTest {
|
||||
|
@ -224,4 +226,86 @@ class TabbedBrowsingTest {
|
|||
verifyHomeScreen()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyEmptyTabTray() {
|
||||
homeScreen { }.dismissOnboarding()
|
||||
|
||||
navigationToolbar {
|
||||
}.openTabTray {
|
||||
verifyNoTabsOpened()
|
||||
verifyNewTabButton()
|
||||
verifyTabTrayOverflowMenu(false)
|
||||
}.toggleToPrivateTabs {
|
||||
verifyNoTabsOpened()
|
||||
verifyNewTabButton()
|
||||
verifyTabTrayOverflowMenu(false)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyOpenTabDetails() {
|
||||
homeScreen { }.dismissOnboarding()
|
||||
|
||||
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
// verifyPageContent(defaultWebPage.content)
|
||||
}.openTabDrawer {
|
||||
verifyExistingTabList()
|
||||
verifyNewTabButton()
|
||||
verifyTabTrayOverflowMenu(true)
|
||||
verifyExistingOpenTabs(defaultWebPage.title)
|
||||
verifyCloseTabsButton(defaultWebPage.title)
|
||||
}.openHomeScreen {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyContextMenuShortcuts() {
|
||||
homeScreen { }.dismissOnboarding()
|
||||
|
||||
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
// verifyPageContent(defaultWebPage.content)
|
||||
}.openTabDrawer {
|
||||
verifyExistingTabList()
|
||||
verifyNewTabButton()
|
||||
verifyTabTrayOverflowMenu(true)
|
||||
verifyExistingOpenTabs(defaultWebPage.title)
|
||||
verifyCloseTabsButton(defaultWebPage.title)
|
||||
}.closeTabDrawer {
|
||||
}.openTabButtonShortcutsMenu {
|
||||
verifyTabButtonShortcutMenuItems()
|
||||
}.closeTabFromShortcutsMenu {
|
||||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
}.openTabButtonShortcutsMenu {
|
||||
}.openNewPrivateTabFromShortcutsMenu {
|
||||
verifyHomeScreen()
|
||||
verifyNavigationToolbar()
|
||||
verifyHomePrivateBrowsingButton()
|
||||
verifyHomeMenu()
|
||||
verifyHomeWordmark()
|
||||
verifyTabButton()
|
||||
verifyPrivateSessionMessage()
|
||||
verifyHomeToolbar()
|
||||
verifyHomeComponent()
|
||||
}
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
|
||||
}.openTabButtonShortcutsMenu {
|
||||
}.openTabFromShortcutsMenu {
|
||||
verifyHomeScreen()
|
||||
verifyNavigationToolbar()
|
||||
verifyHomeMenu()
|
||||
verifyHomeWordmark()
|
||||
verifyTabButton()
|
||||
verifyHomeToolbar()
|
||||
verifyHomeComponent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ import androidx.test.espresso.intent.matcher.BundleMatchers
|
|||
import androidx.test.espresso.intent.matcher.IntentMatchers
|
||||
import androidx.test.espresso.matcher.RootMatchers.isDialog
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
|
@ -392,6 +392,17 @@ class BrowserRobot {
|
|||
return TabDrawerRobot.Transition()
|
||||
}
|
||||
|
||||
fun openTabButtonShortcutsMenu(interact: NavigationToolbarRobot.() -> Unit): NavigationToolbarRobot.Transition {
|
||||
mDevice.waitForIdle(waitingTime)
|
||||
|
||||
tabsCounter().perform(
|
||||
ViewActions.longClick()
|
||||
)
|
||||
|
||||
NavigationToolbarRobot().interact()
|
||||
return NavigationToolbarRobot.Transition()
|
||||
}
|
||||
|
||||
fun openNotificationShade(interact: NotificationRobot.() -> Unit): NotificationRobot.Transition {
|
||||
mDevice.openNotification()
|
||||
|
||||
|
|
|
@ -7,13 +7,16 @@
|
|||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.IdlingResource
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.action.ViewActions.pressImeActionButton
|
||||
import androidx.test.espresso.action.ViewActions.replaceText
|
||||
import androidx.test.espresso.action.ViewActions.typeText
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
|
@ -47,6 +50,8 @@ class NavigationToolbarRobot {
|
|||
|
||||
fun verifyNoHistoryBookmarks() = assertNoHistoryBookmarks()
|
||||
|
||||
fun verifyTabButtonShortcutMenuItems() = assertTabButtonShortcutMenuItems()
|
||||
|
||||
class Transition {
|
||||
|
||||
private lateinit var sessionLoadedIdlingResource: SessionLoadedIdlingResource
|
||||
|
@ -113,12 +118,25 @@ class NavigationToolbarRobot {
|
|||
return ThreeDotMenuMainRobot.Transition()
|
||||
}
|
||||
|
||||
fun openTabTray(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
|
||||
onView(withId(R.id.tab_button))
|
||||
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
tabTrayButton().click()
|
||||
|
||||
TabDrawerRobot().interact()
|
||||
return TabDrawerRobot.Transition()
|
||||
}
|
||||
|
||||
fun openNewTabAndEnterToBrowser(
|
||||
url: Uri,
|
||||
interact: BrowserRobot.() -> Unit
|
||||
): BrowserRobot.Transition {
|
||||
sessionLoadedIdlingResource = SessionLoadedIdlingResource()
|
||||
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/toolbar")), waitingTime)
|
||||
mDevice.waitNotNull(
|
||||
Until.findObject(By.res("org.mozilla.fenix.debug:id/toolbar")),
|
||||
waitingTime
|
||||
)
|
||||
|
||||
urlBar().click()
|
||||
awesomeBar().perform(replaceText(url.toString()), pressImeActionButton())
|
||||
|
@ -165,6 +183,54 @@ class NavigationToolbarRobot {
|
|||
HomeScreenRobot().interact()
|
||||
return HomeScreenRobot.Transition()
|
||||
}
|
||||
|
||||
fun closeTabFromShortcutsMenu(interact: NavigationToolbarRobot.() -> Unit): NavigationToolbarRobot.Transition {
|
||||
mDevice.waitForIdle(waitingTime)
|
||||
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||
.perform(
|
||||
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
|
||||
hasDescendant(
|
||||
withText("Close tab")
|
||||
), ViewActions.click()
|
||||
)
|
||||
)
|
||||
|
||||
NavigationToolbarRobot().interact()
|
||||
return NavigationToolbarRobot.Transition()
|
||||
}
|
||||
|
||||
fun openTabFromShortcutsMenu(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||
mDevice.waitForIdle(waitingTime)
|
||||
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||
.perform(
|
||||
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
|
||||
hasDescendant(
|
||||
withText("New tab")
|
||||
), ViewActions.click()
|
||||
)
|
||||
)
|
||||
|
||||
HomeScreenRobot().interact()
|
||||
return HomeScreenRobot.Transition()
|
||||
}
|
||||
|
||||
fun openNewPrivateTabFromShortcutsMenu(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||
mDevice.waitForIdle(waitingTime)
|
||||
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||
.perform(
|
||||
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
|
||||
hasDescendant(
|
||||
withText("New private tab")
|
||||
), ViewActions.click()
|
||||
)
|
||||
)
|
||||
|
||||
HomeScreenRobot().interact()
|
||||
return HomeScreenRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,10 +262,18 @@ private fun assertNoHistoryBookmarks() {
|
|||
.check(matches(not(hasDescendant(withText("Test_Page_3")))))
|
||||
}
|
||||
|
||||
private fun assertTabButtonShortcutMenuItems() {
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
||||
.check(matches(hasDescendant(withText("Close tab"))))
|
||||
.check(matches(hasDescendant(withText("New private tab"))))
|
||||
.check(matches(hasDescendant(withText("New tab"))))
|
||||
}
|
||||
|
||||
private fun dismissOnboardingButton() = onView(withId(R.id.close_onboarding))
|
||||
private fun urlBar() = onView(withId(R.id.toolbar))
|
||||
private fun awesomeBar() = onView(withId(R.id.mozac_browser_toolbar_edit_url_view))
|
||||
private fun threeDotButton() = onView(withId(R.id.mozac_browser_toolbar_menu))
|
||||
private fun tabTrayButton() = onView(withId(R.id.tab_button))
|
||||
private fun fillLinkButton() = onView(withId(R.id.fill_link_from_clipboard))
|
||||
private fun clearAddressBar() = onView(withId(R.id.mozac_browser_toolbar_clear_view))
|
||||
private fun goBackButton() = mDevice.pressBack()
|
||||
|
|
|
@ -47,6 +47,8 @@ class TabDrawerRobot {
|
|||
fun verifyNoTabsOpened() = assertNoTabsOpenedText()
|
||||
fun verifyPrivateModeSelected() = assertPrivateModeSelected()
|
||||
fun verifyNormalModeSelected() = assertNormalModeSelected()
|
||||
fun verifyNewTabButton() = assertNewTabButton()
|
||||
fun verifyTabTrayOverflowMenu(visibility: Boolean) = assertTabTrayOverflowButton(visibility)
|
||||
|
||||
fun closeTab() {
|
||||
closeTabButton().click()
|
||||
|
@ -119,6 +121,18 @@ class TabDrawerRobot {
|
|||
return TabDrawerRobot.Transition()
|
||||
}
|
||||
|
||||
fun closeTabDrawer(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
mDevice.waitForIdle(waitingTime)
|
||||
|
||||
// Dismisses the tab tray bottom sheet with 2 handle clicks
|
||||
onView(withId(R.id.handle)).perform(
|
||||
click(),
|
||||
click()
|
||||
)
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun openHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||
mDevice.waitForIdle()
|
||||
|
||||
|
@ -196,6 +210,10 @@ private fun assertNoTabsOpenedText() =
|
|||
onView(withId(R.id.tab_tray_empty_view))
|
||||
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
private fun assertNewTabButton() =
|
||||
onView(withId(R.id.new_tab_button))
|
||||
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
private fun assertNormalModeSelected() =
|
||||
normalBrowsingButton()
|
||||
.check(matches(ViewMatchers.isSelected()))
|
||||
|
@ -204,6 +222,10 @@ private fun assertPrivateModeSelected() =
|
|||
privateBrowsingButton()
|
||||
.check(matches(ViewMatchers.isSelected()))
|
||||
|
||||
private fun assertTabTrayOverflowButton(visible: Boolean) =
|
||||
onView(withId(R.id.tab_tray_overflow))
|
||||
.check(matches(withEffectiveVisibility(visibleOrGone(visible))))
|
||||
|
||||
private fun tab(title: String) =
|
||||
onView(
|
||||
allOf(
|
||||
|
@ -213,3 +235,6 @@ private fun tab(title: String) =
|
|||
)
|
||||
|
||||
private fun tabsCounter() = onView(withId(R.id.tab_button))
|
||||
|
||||
private fun visibleOrGone(visibility: Boolean) =
|
||||
if (visibility) ViewMatchers.Visibility.VISIBLE else ViewMatchers.Visibility.GONE
|
||||
|
|
Loading…
Reference in New Issue