diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt index 45afd1884..da05bcc1e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt @@ -123,6 +123,38 @@ class HomeScreenTest { } } + @Test + fun verifyJumpBackInSectionTest() { + val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 4) + val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) + + navigationToolbar { + }.enterURLAndEnterToBrowser(firstWebPage.url) { + }.goToHomescreen { + verifyJumpBackInSectionIsDisplayed() + verifyJumpBackInItemTitle(firstWebPage.title) + verifyJumpBackInItemWithUrl(firstWebPage.url.toString()) + verifyJumpBackInShowAllButton() + }.clickJumpBackInShowAllButton { + verifyExistingOpenTabs(firstWebPage.title) + }.closeTabDrawer() { + } + homeScreen { + }.clickJumpBackInItemWithTitle(firstWebPage.title) { + verifyUrl(firstWebPage.url.toString()) + clickLinkMatchingText("Link 1") + }.goToHomescreen { + verifyJumpBackInSectionIsDisplayed() + verifyJumpBackInItemTitle(secondWebPage.title) + verifyJumpBackInItemWithUrl(secondWebPage.url.toString()) + }.openTabDrawer { + closeTab() + } + homeScreen { + verifyJumpBackInSectionIsNotDisplayed() + } + } + @Test fun dismissOnboardingUsingSettingsTest() { homeScreen { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt index f8a6d6197..954fdf71a 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt @@ -185,6 +185,9 @@ class HomeScreenRobot { fun verifyJumpBackInSectionIsDisplayed() = assertJumpBackInSectionIsDisplayed() fun verifyJumpBackInSectionIsNotDisplayed() = assertJumpBackInSectionIsNotDisplayed() + fun verifyJumpBackInItemTitle(itemTitle: String) = assertJumpBackInItemTitle(itemTitle) + fun verifyJumpBackInItemWithUrl(itemUrl: String) = assertJumpBackInItemWithUrl(itemUrl) + fun verifyJumpBackInShowAllButton() = assertJumpBackInShowAllButton() fun verifyRecentlyVisitedSectionIsDisplayed() = assertRecentlyVisitedSectionIsDisplayed() fun verifyRecentlyVisitedSectionIsNotDisplayed() = assertRecentlyVisitedSectionIsNotDisplayed() fun verifyRecentBookmarksSectionIsDisplayed() = assertRecentBookmarksSectionIsDisplayed() @@ -627,6 +630,29 @@ class HomeScreenRobot { SettingsSubMenuHomepageRobot().interact() return SettingsSubMenuHomepageRobot.Transition() } + + fun clickJumpBackInShowAllButton(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition { + mDevice + .findObject( + UiSelector() + .textContains(getStringResource(R.string.recent_tabs_show_all)), + ).clickAndWaitForNewWindow(waitingTime) + + TabDrawerRobot().interact() + return TabDrawerRobot.Transition() + } + + fun clickJumpBackInItemWithTitle(itemTitle: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { + mDevice + .findObject( + UiSelector() + .resourceId("recent.tab.title") + .textContains(itemTitle), + ).clickAndWaitForNewWindow(waitingTime) + + BrowserRobot().interact() + return BrowserRobot.Transition() + } } } @@ -943,6 +969,35 @@ private fun assertJumpBackInSectionIsDisplayed() = assertTrue(jumpBackInSection( private fun assertJumpBackInSectionIsNotDisplayed() = assertFalse(jumpBackInSection().waitForExists(waitingTimeShort)) +private fun assertJumpBackInItemTitle(itemTitle: String) = + assertTrue( + mDevice + .findObject( + UiSelector() + .resourceId("recent.tab.title") + .textContains(itemTitle), + ).waitForExists(waitingTime), + ) + +private fun assertJumpBackInItemWithUrl(itemUrl: String) = + assertTrue( + mDevice + .findObject( + UiSelector() + .resourceId("recent.tab.url") + .textContains(itemUrl), + ).waitForExists(waitingTime), + ) + +private fun assertJumpBackInShowAllButton() = + assertTrue( + mDevice + .findObject( + UiSelector() + .textContains(getStringResource(R.string.recent_tabs_show_all)), + ).waitForExists(waitingTime), + ) + private fun assertRecentlyVisitedSectionIsDisplayed() = assertTrue(recentlyVisitedSection().waitForExists(waitingTime)) private fun assertRecentlyVisitedSectionIsNotDisplayed() = assertFalse(recentlyVisitedSection().waitForExists(waitingTime))