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
10 import org.mozilla.fenix.R
11 import org.mozilla.fenix.customannotations.SmokeTest
12 import org.mozilla.fenix.helpers.AppAndSystemHelper.setNetworkEnabled
13 import org.mozilla.fenix.helpers.DataGenerationHelper.getStringResource
14 import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
15 import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
16 import org.mozilla.fenix.helpers.TestAssetHelper
17 import org.mozilla.fenix.helpers.TestAssetHelper.getStorageTestAsset
18 import org.mozilla.fenix.helpers.TestHelper.exitMenu
19 import org.mozilla.fenix.helpers.TestHelper.mDevice
20 import org.mozilla.fenix.helpers.TestHelper.restartApp
21 import org.mozilla.fenix.helpers.TestSetup
22 import org.mozilla.fenix.ui.robots.browserScreen
23 import org.mozilla.fenix.ui.robots.clickPageObject
24 import org.mozilla.fenix.ui.robots.homeScreen
25 import org.mozilla.fenix.ui.robots.navigationToolbar
26 import org.mozilla.fenix.ui.robots.settingsScreen
29 * Tests for verifying the Settings for:
30 * Delete Browsing Data
33 class ComposeSettingsDeleteBrowsingDataTest : TestSetup() {
36 AndroidComposeTestRule(
37 HomeActivityIntentTestRule.withDefaultSettingsOverrides(
38 skipOnboarding = true,
39 tabsTrayRewriteEnabled = true,
43 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/937561
45 fun deleteBrowsingDataOptionStatesTest() {
49 }.openSettingsSubMenuDeleteBrowsingData {
50 verifyAllCheckBoxesAreChecked()
51 switchBrowsingHistoryCheckBox()
52 switchCachedFilesCheckBox()
53 verifyOpenTabsCheckBox(true)
54 verifyBrowsingHistoryDetails(false)
55 verifyCookiesCheckBox(true)
56 verifyCachedFilesCheckBox(false)
57 verifySitePermissionsCheckBox(true)
58 verifyDownloadsCheckBox(true)
61 restartApp(composeTestRule.activityRule)
66 }.openSettingsSubMenuDeleteBrowsingData {
67 verifyOpenTabsCheckBox(true)
68 verifyBrowsingHistoryDetails(false)
69 verifyCookiesCheckBox(true)
70 verifyCachedFilesCheckBox(false)
71 verifySitePermissionsCheckBox(true)
72 verifyDownloadsCheckBox(true)
73 switchOpenTabsCheckBox()
74 switchBrowsingHistoryCheckBox()
75 switchCookiesCheckBox()
76 switchCachedFilesCheckBox()
77 switchSitePermissionsCheckBox()
78 switchDownloadsCheckBox()
79 verifyOpenTabsCheckBox(false)
80 verifyBrowsingHistoryDetails(true)
81 verifyCookiesCheckBox(false)
82 verifyCachedFilesCheckBox(true)
83 verifySitePermissionsCheckBox(false)
84 verifyDownloadsCheckBox(false)
87 restartApp(composeTestRule.activityRule)
92 }.openSettingsSubMenuDeleteBrowsingData {
93 verifyOpenTabsCheckBox(false)
94 verifyBrowsingHistoryDetails(true)
95 verifyCookiesCheckBox(false)
96 verifyCachedFilesCheckBox(true)
97 verifySitePermissionsCheckBox(false)
98 verifyDownloadsCheckBox(false)
102 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/517811
104 fun deleteOpenTabsBrowsingDataWithNoOpenTabsTest() {
108 }.openSettingsSubMenuDeleteBrowsingData {
109 verifyAllCheckBoxesAreChecked()
110 selectOnlyOpenTabsCheckBox()
111 clickDeleteBrowsingDataButton()
112 verifyDeleteBrowsingDataDialog()
113 confirmDeletionAndAssertSnackbar()
116 verifyGeneralHeading()
120 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/353531
123 fun deleteOpenTabsBrowsingDataTest() {
124 val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
127 }.enterURLAndEnterToBrowser(defaultWebPage.url) {
128 mDevice.waitForIdle()
131 }.openSettingsSubMenuDeleteBrowsingData {
132 verifyAllCheckBoxesAreChecked()
133 selectOnlyOpenTabsCheckBox()
134 clickDeleteBrowsingDataButton()
135 verifyDeleteBrowsingDataDialog()
136 clickDialogCancelButton()
137 verifyOpenTabsCheckBox(true)
138 clickDeleteBrowsingDataButton()
139 verifyDeleteBrowsingDataDialog()
140 confirmDeletionAndAssertSnackbar()
143 verifyGeneralHeading()
144 }.openSettingsSubMenuDeleteBrowsingData {
145 verifyOpenTabsDetails("0")
148 }.openComposeTabDrawer(composeTestRule) {
149 verifyNoOpenTabsInNormalBrowsing()
153 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/378864
156 fun deleteBrowsingHistoryTest() {
157 val genericPage = getStorageTestAsset(mockWebServer, "generic1.html").url
160 }.enterURLAndEnterToBrowser(genericPage) {
163 }.openSettingsSubMenuDeleteBrowsingData {
164 verifyBrowsingHistoryDetails("1")
165 selectOnlyBrowsingHistoryCheckBox()
166 clickDeleteBrowsingDataButton()
167 verifyDeleteBrowsingDataDialog()
168 clickDialogCancelButton()
169 verifyBrowsingHistoryDetails(true)
170 clickDeleteBrowsingDataButton()
171 verifyDeleteBrowsingDataDialog()
172 confirmDeletionAndAssertSnackbar()
173 verifyBrowsingHistoryDetails("0")
179 verifyEmptyHistoryView()
184 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/416041
187 fun deleteCookiesAndSiteDataTest() {
188 val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
189 val storageWritePage = getStorageTestAsset(mockWebServer, "storage_write.html").url
190 val storageCheckPage = getStorageTestAsset(mockWebServer, "storage_check.html").url
192 // Browsing a generic page to allow GV to load on a fresh run
194 }.enterURLAndEnterToBrowser(genericPage.url) {
195 }.openNavigationToolbar {
196 }.enterURLAndEnterToBrowser(storageWritePage) {
197 verifyPageContent("No cookies set")
198 clickPageObject(itemWithResId("setCookies"))
199 verifyPageContent("user=android")
200 }.openNavigationToolbar {
201 }.enterURLAndEnterToBrowser(storageCheckPage) {
202 verifyPageContent("Session storage has value")
203 verifyPageContent("Local storage has value")
206 }.openSettingsSubMenuDeleteBrowsingData {
207 selectOnlyCookiesCheckBox()
208 clickDeleteBrowsingDataButton()
209 verifyDeleteBrowsingDataDialog()
210 clickDialogCancelButton()
211 verifyCookiesCheckBox(status = true)
212 clickDeleteBrowsingDataButton()
213 verifyDeleteBrowsingDataDialog()
214 confirmDeletionAndAssertSnackbar()
218 }.enterURLAndEnterToBrowser(storageCheckPage) {
219 verifyPageContent("Session storage empty")
220 verifyPageContent("Local storage empty")
221 }.openNavigationToolbar {
222 }.enterURLAndEnterToBrowser(storageWritePage) {
223 verifyPageContent("No cookies set")
227 // TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/416042
230 fun deleteCachedFilesTest() {
231 val pocketTopArticles = getStringResource(R.string.pocket_pinned_top_articles)
234 verifyExistingTopSitesTabs(pocketTopArticles)
235 }.openTopSiteTabWithTitle(pocketTopArticles) {
237 }.openComposeTabDrawer(composeTestRule) {
239 }.submitQuery("about:cache") {
240 // disabling wifi to prevent downloads in the background
241 setNetworkEnabled(enabled = false)
244 }.openSettingsSubMenuDeleteBrowsingData {
245 selectOnlyCachedFilesCheckBox()
246 clickDeleteBrowsingDataButton()
247 verifyDeleteBrowsingDataDialog()
248 confirmDeletionAndAssertSnackbar()
254 verifyNetworkCacheIsEmpty("memory")
255 verifyNetworkCacheIsEmpty("disk")
257 setNetworkEnabled(enabled = true)