Skip to content

Commit

Permalink
Delete browsing data tests UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiAJ authored and mergify[bot] committed Sep 28, 2021
1 parent 06292ac commit bf3b669
Show file tree
Hide file tree
Showing 4 changed files with 301 additions and 221 deletions.
280 changes: 123 additions & 157 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.mozilla.fenix.ui.robots.addToHomeScreen
import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.robots.settingsScreen

/**
* Tests for verifying the main three dot menu options
Expand Down Expand Up @@ -380,175 +381,140 @@ class SettingsPrivacyTest {
}
}

@Ignore("This is a stub test, ignore for now")
@Test
fun toggleTrackingProtection() {
// Open static test website to verify TP is turned on (default): https://github.com/rpappalax/testapp
// (static content needs to be migrated to assets folder)
// Open 3dot (main) menu
// Select settings
// Toggle Tracking Protection to 'off'
// Back arrow to Home
// Open static test website to verify TP is now off: https://github.com/rpappalax/testapp
}
fun deleteBrowsingDataOptionStatesTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSettingsSubMenuDeleteBrowsingData {
verifyAllCheckBoxesAreChecked()
switchBrowsingHistoryCheckBox()
switchCachedFilesCheckBox()
verifyOpenTabsCheckBox(true)
verifyBrowsingHistoryDetails(false)
verifyCookiesCheckBox(true)
verifyCachedFilesCheckBox(false)
verifySitePermissionsCheckBox(true)
verifyDownloadsCheckBox(true)
}

@Ignore("This is a stub test, ignore for now")
@Test
fun verifySitePermissions() {
// Open 3dot (main) menu
// Select settings
// Click on: "Site permissions"
// Verify sub-menu items...
// Click on: "Exceptions"
// Verify: "No site exceptions"
// TBD: create a site exception
// TBD: return to this UI and verify

//
// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: geolocation"
// Verify that geolocation permissions dialogue is opened
// Verify text: "Allow <website URL> to use your geolocation?
// Verify toggle: 'Remember decision for this site?"
// Verify button: "Don't Allow"
// Verify button: "Allow" (default)
// Select "Remember decision for this site"
// Refresh page
// Click on "Test site permissions: geolocation"
// Verify that geolocation permissions dialogue is not opened
//
//
// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: camera"
// Verify that camera permissions dialogue is opened
// Verify text: "Allow <website URL> to use your camera?
// Verify toggle: 'Remember decision for this site?"
// Verify button: "Don't Allow"
// Verify button: "Allow" (default)
// Select "Remember decision for this site"
// Refresh page
// Click on "Test site permissions: camera"
// Verify that camera permissions dialogue is not opened
//
//
// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: microphone"
// Verify that microphone permissions dialogue is opened
// Verify text: "Allow <website URL> to use your microphone?
// Verify toggle: 'Remember decision for this site?"
// Verify button: "Don't Allow"
// Verify button: "Allow" (default)
// Select "Remember decision for this site"
// Refresh page
// Click on "Test site permissions: microphone"
// Verify that microphone permissions dialogue is not opened
//
//
// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: notifications dialogue"
// Verify that notifications dialogue permissions dialogue is opened
// Verify text: "Allow <website URL> to send notifications?
// Verify toggle: 'Remember decision for this site?"
// Verify button: "Never"
// Verify button: "Always" (default)
// Select "Remember decision for this site"
// Refresh page
// Click on "Test site permissions: notifications dialogue"
// Verify that notifications dialogue permissions dialogue is not opened
//

// Open 3dot (main) menu
// Select settings
// Click on: "Site permissions"
// Select: Camera
// Switch from "ask to allow" (default) to "blocked"
// Click back arrow
//
// Select: Location
// Switch from "ask to allow" (default) to "blocked"
// Click back arrow
//
// Select: Microphone
// Switch from "ask to allow" (default) to "blocked"
// Click back arrow
//
// Select: Notification
// Switch from "ask to allow" (default) to "blocked"
// Click back arrow
//

// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: camera dialogue"
// Verify that notifications dialogue permissions dialogue is not opened
//
// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: geolocation dialogue"
// Verify that notifications dialogue permissions dialogue is not opened
//
// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: microphone dialogue"
// Verify that notifications dialogue permissions dialogue is not opened
//
// Open browser to static test website: https://github.com/rpappalax/testapp
// Click on "Test site permissions: notifications dialogue"
// Verify that notifications dialogue permissions dialogue is not opened
}
restartApp(activityTestRule)

@Ignore("This is a stub test, ignore for now")
@Test
fun deleteBrowsingData() {
// Setup:
// Open 2 websites as 2 tabs
// Save as 1 collection
// Open 2 more websites in 2 other tabs
// Save as a 2nd collection

// Open 3dot (main) menu
// Select settings
// Click on "Delete browsing data"
// Verify correct number of tabs, addresses and collections are indicated
// Select all 3 checkboxes
// Click on "Delete browsing data button"
// Return to home screen and verify that all tabs, history and collection are gone
//
// Verify xxx
//
// New: If coming from tab -> settings -> delete browsing data
// then expect to return to home screen
// If coming from tab -> home -> settings -> delete browsing data
// then expect return to settings (after which you can return to home manually)
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSettingsSubMenuDeleteBrowsingData {
verifyOpenTabsCheckBox(true)
verifyBrowsingHistoryDetails(false)
verifyCookiesCheckBox(true)
verifyCachedFilesCheckBox(false)
verifySitePermissionsCheckBox(true)
verifyDownloadsCheckBox(true)
switchOpenTabsCheckBox()
switchBrowsingHistoryCheckBox()
switchCookiesCheckBox()
switchCachedFilesCheckBox()
switchSitePermissionsCheckBox()
switchDownloadsCheckBox()
verifyOpenTabsCheckBox(false)
verifyBrowsingHistoryDetails(true)
verifyCookiesCheckBox(false)
verifyCachedFilesCheckBox(true)
verifySitePermissionsCheckBox(false)
verifyDownloadsCheckBox(false)
}

restartApp(activityTestRule)

homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSettingsSubMenuDeleteBrowsingData {
verifyOpenTabsCheckBox(false)
verifyBrowsingHistoryDetails(true)
verifyCookiesCheckBox(false)
verifyCachedFilesCheckBox(true)
verifySitePermissionsCheckBox(false)
verifyDownloadsCheckBox(false)
}
}

@Ignore("This is a stub test, ignore for now")
@Test
fun verifyDataCollection() {
// Open 3dot (main) menu
// Select settings
// Click on "Data collection"
// Verify header: "Usage and technical data"
// Verify text: "Shares performance, usage, hardware and customization data about your browser with Mozilla"
// " to help us make Firefox preview better"
// Verify toggle is on by default
// TBD:
// see: telemetry testcases
fun deleteTabsDataWithNoOpenTabsTest() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSettingsSubMenuDeleteBrowsingData {
verifyAllCheckBoxesAreChecked()
selectOnlyOpenTabsCheckBox()
clickDeleteBrowsingDataButton()
confirmDeletionAndAssertSnackbar()
}
settingsScreen {
verifyBasicsHeading()
}
}

@Ignore("This is a stub test, ignore for now")
@Test
fun openPrivacyNotice() {
// Open 3dot (main) menu
// Select settings
// Click on "Privacy notice"
// Verify redirect to: mozilla.org Privacy notice page"
fun deleteTabsDataTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)

navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
mDevice.waitForIdle()
}.openThreeDotMenu {
}.openSettings {
}.openSettingsSubMenuDeleteBrowsingData {
verifyAllCheckBoxesAreChecked()
selectOnlyOpenTabsCheckBox()
clickDeleteBrowsingDataButton()
clickDialogCancelButton()
verifyOpenTabsCheckBox(true)
clickDeleteBrowsingDataButton()
confirmDeletionAndAssertSnackbar()
}
settingsScreen {
verifyBasicsHeading()
}.openSettingsSubMenuDeleteBrowsingData {
verifyOpenTabsDetails("0")
}.goBack {
}.goBack {
}.openTabDrawer {
verifyNoTabsOpened()
}
}

@Ignore("This is a stub test, ignore for now")
@Test
fun checkLeakCanary() {
// Open 3dot (main) menu
// Select settings
// Click on Leak Canary toggle
// Verify 'dump' message
fun deleteDeleteBrowsingHistoryDataTest() {
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val secondWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 2)

navigationToolbar {
}.enterURLAndEnterToBrowser(firstWebPage.url) {
mDevice.waitForIdle()
}.openNavigationToolbar {
}.enterURLAndEnterToBrowser(secondWebPage.url) {
mDevice.waitForIdle()
}.openThreeDotMenu {
}.openSettings {
}.openSettingsSubMenuDeleteBrowsingData {
verifyBrowsingHistoryDetails("2")
selectOnlyBrowsingHistoryCheckBox()
clickDeleteBrowsingDataButton()
clickDialogCancelButton()
verifyBrowsingHistoryDetails(true)
clickDeleteBrowsingDataButton()
confirmDeletionAndAssertSnackbar()
verifyBrowsingHistoryDetails("0")
}.goBack {
verifyBasicsHeading()
}.goBack {
}
navigationToolbar {
}.openThreeDotMenu {
}.openHistory {
verifyEmptyHistoryView()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ class SettingsRobot {
}
}

fun settingsScreen(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
SettingsRobot().interact()
return SettingsRobot.Transition()
}

private fun assertSettingsView() {
// verify that we are in the correct library view
assertGeneralHeading()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class SettingsSubMenuDeleteBrowsingDataOnQuitRobot {

fun clickDeleteBrowsingOnQuitButtonSwitchDefaultChange() = verifyDeleteBrowsingOnQuitButtonSwitchDefault().click()

fun verifyAllTheCheckBoxesText() = assertAllTheCheckBoxesText()
fun verifyAllTheCheckBoxesText() = assertAllOptionsAndCheckBoxes()

fun verifyAllTheCheckBoxesChecked() = assertAllTheCheckBoxesChecked()
fun verifyAllTheCheckBoxesChecked() = assertAllCheckBoxesAreChecked()

fun verifyDeleteBrowsingDataOnQuitSubMenuItems() {
verifyDeleteBrowsingOnQuitButton()
Expand Down Expand Up @@ -88,7 +88,7 @@ private fun assertDeleteBrowsingOnQuitButtonSummary() = onView(
private fun assertDeleteBrowsingOnQuitButtonSwitchDefault() = onView(withResourceName("switch_widget"))
.check(matches(isChecked(false)))

private fun assertAllTheCheckBoxesText() {
private fun assertAllOptionsAndCheckBoxes() {
onView(withText(R.string.preferences_delete_browsing_data_tabs_title_2))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))

Expand All @@ -111,6 +111,6 @@ private fun assertAllTheCheckBoxesText() {
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}

private fun assertAllTheCheckBoxesChecked() {
private fun assertAllCheckBoxesAreChecked() {
// Only verifying the options, checkboxes default value can't be verified due to issue #9471
}

0 comments on commit bf3b669

Please sign in to comment.