1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.fenix.ui
7 import androidx.compose.ui.test.junit4.AndroidComposeTestRule
8 import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
11 import org.mozilla.fenix.R
12 import org.mozilla.fenix.customannotations.SmokeTest
13 import org.mozilla.fenix.helpers.AppAndSystemHelper.registerAndCleanupIdlingResources
14 import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
15 import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
16 import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
17 import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem
18 import org.mozilla.fenix.helpers.TestHelper.mDevice
19 import org.mozilla.fenix.helpers.TestSetup
20 import org.mozilla.fenix.ui.robots.browserScreen
21 import org.mozilla.fenix.ui.robots.homeScreen
22 import org.mozilla.fenix.ui.robots.navigationToolbar
25 * Tests for verifying basic functionality of recently closed tabs history
28 class RecentlyClosedTabsTest : TestSetup() {
30 val activityTestRule = AndroidComposeTestRule(
31 HomeActivityIntentTestRule.withDefaultSettingsOverrides(
32 tabsTrayRewriteEnabled = true,
36 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1065414
37 // Verifies that a recently closed item is properly opened
40 fun openRecentlyClosedItemTest() {
41 val website = getGenericAsset(mockWebServer, 1)
44 }.openNavigationToolbar {
45 }.enterURLAndEnterToBrowser(website.url) {
47 }.openComposeTabDrawer(activityTestRule) {
53 }.openRecentlyClosedTabs {
55 registerAndCleanupIdlingResources(
56 RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.recently_closed_list), 1),
58 verifyRecentlyClosedTabsMenuView()
59 verifyRecentlyClosedTabsPageTitle("Test_Page_1")
60 verifyRecentlyClosedTabsUrl(website.url)
62 }.clickRecentlyClosedItem("Test_Page_1") {
63 verifyUrl(website.url.toString())
67 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2195812
68 // Verifies that tapping the "x" button removes a recently closed item from the list
71 fun deleteRecentlyClosedTabsItemTest() {
72 val website = getGenericAsset(mockWebServer, 1)
75 }.openNavigationToolbar {
76 }.enterURLAndEnterToBrowser(website.url) {
78 }.openComposeTabDrawer(activityTestRule) {
84 }.openRecentlyClosedTabs {
86 registerAndCleanupIdlingResources(
87 RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.recently_closed_list), 1),
89 verifyRecentlyClosedTabsMenuView()
91 clickDeleteRecentlyClosedTabs()
92 verifyEmptyRecentlyClosedTabsList()
96 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1605515
98 fun openMultipleRecentlyClosedTabsTest() {
99 val firstPage = getGenericAsset(mockWebServer, 1)
100 val secondPage = getGenericAsset(mockWebServer, 2)
103 }.enterURLAndEnterToBrowser(firstPage.url) {
105 }.openComposeTabDrawer(activityTestRule) {
107 }.submitQuery(secondPage.url.toString()) {
109 }.openComposeTabDrawer(activityTestRule) {
114 }.openRecentlyClosedTabs {
116 longTapSelectItem(firstPage.url)
117 longTapSelectItem(secondPage.url)
118 openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
119 }.clickOpenInNewTab(activityTestRule) {
120 // URL verification to be removed once https://bugzilla.mozilla.org/show_bug.cgi?id=1839179 is fixed.
122 verifyPageContent(secondPage.content)
123 verifyUrl(secondPage.url.toString())
124 }.openComposeTabDrawer(activityTestRule) {
125 verifyNormalBrowsingButtonIsSelected(true)
126 verifyExistingOpenTabs(firstPage.title, secondPage.title)
131 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/2198690
133 fun openRecentlyClosedTabsInPrivateBrowsingTest() {
134 val firstPage = getGenericAsset(mockWebServer, 1)
135 val secondPage = getGenericAsset(mockWebServer, 2)
138 }.enterURLAndEnterToBrowser(firstPage.url) {
140 }.openComposeTabDrawer(activityTestRule) {
142 }.submitQuery(secondPage.url.toString()) {
144 }.openComposeTabDrawer(activityTestRule) {
149 }.openRecentlyClosedTabs {
151 longTapSelectItem(firstPage.url)
152 longTapSelectItem(secondPage.url)
153 openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
154 }.clickOpenInPrivateTab(activityTestRule) {
155 // URL verification to be removed once https://bugzilla.mozilla.org/show_bug.cgi?id=1839179 is fixed.
157 verifyPageContent(secondPage.content)
158 verifyUrl(secondPage.url.toString())
159 }.openComposeTabDrawer(activityTestRule) {
160 verifyPrivateBrowsingButtonIsSelected(true)
161 verifyExistingOpenTabs(firstPage.title, secondPage.title)
166 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1605514
168 fun shareMultipleRecentlyClosedTabsTest() {
169 val firstPage = getGenericAsset(mockWebServer, 1)
170 val secondPage = getGenericAsset(mockWebServer, 2)
171 val sharingApp = "Gmail"
172 val urlString = "${firstPage.url}\n\n${secondPage.url}"
175 }.enterURLAndEnterToBrowser(firstPage.url) {
177 }.openComposeTabDrawer(activityTestRule) {
179 }.submitQuery(secondPage.url.toString()) {
181 }.openComposeTabDrawer(activityTestRule) {
186 }.openRecentlyClosedTabs {
188 longTapSelectItem(firstPage.url)
189 longTapSelectItem(secondPage.url)
191 verifyShareTabsOverlay(firstPage.title, secondPage.title)
192 verifySharingWithSelectedApp(sharingApp, urlString, "${firstPage.title}, ${secondPage.title}")
196 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1065438
198 fun closedPrivateTabsAreNotSavedInRecentlyClosedTabsTest() {
199 val firstPage = getGenericAsset(mockWebServer, 1)
200 val secondPage = getGenericAsset(mockWebServer, 2)
202 homeScreen {}.togglePrivateBrowsingMode()
204 }.enterURLAndEnterToBrowser(firstPage.url) {
206 }.openComposeTabDrawer(activityTestRule) {
208 }.submitQuery(secondPage.url.toString()) {
210 }.openComposeTabDrawer(activityTestRule) {
215 }.openRecentlyClosedTabs {
216 verifyEmptyRecentlyClosedTabsList()
220 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/1065439
222 fun deletingBrowserHistoryClearsRecentlyClosedTabsListTest() {
223 val firstPage = getGenericAsset(mockWebServer, 1)
224 val secondPage = getGenericAsset(mockWebServer, 2)
227 }.enterURLAndEnterToBrowser(firstPage.url) {
229 }.openComposeTabDrawer(activityTestRule) {
231 }.submitQuery(secondPage.url.toString()) {
233 }.openComposeTabDrawer(activityTestRule) {
238 }.openRecentlyClosedTabs {
240 }.goBackToHistoryMenu {
241 clickDeleteAllHistoryButton()
242 selectEverythingOption()
243 confirmDeleteAllHistory()
244 verifyEmptyHistoryView()
245 }.openRecentlyClosedTabs {
246 verifyEmptyRecentlyClosedTabsList()