Unverified Commit 2e45244b authored by TejaswiKarasani's avatar TejaswiKarasani Committed by GitHub
Browse files

no issue: Added settings_privacy_items_test (#10474)

parent 9177871e
......@@ -54,63 +54,105 @@ class SettingsPrivacyTest {
@Test
// Walks through settings privacy menu and sub-menus to ensure all items are present
fun settingsPrivacyItemsTest() {
// Open 3dot (main) menu
// Select settings
// Verify header: "Privacy"
// Verify item: "Tracking Protection" and default value: "On"
// Verify item: "Tracking Protection" and default value: "On"
// Verify item: "Logins"
// Verify item: "Site Permissions"
// Click on: "Site permissions"
// Verify sub-menu items...
// Verify item: Exceptions
// Verify item: header: "Permissions"
// Verify item: "Camera" and default value: "ask to allow"
// Verify item: "Location" and default value: "ask to allow"
// Verify item: "Microphone" and default value: "ask to allow"
// Verify item: "Notification" and default value: "ask to allow"
// Verify item: "Delete browsing data"
// Click on: "Delete browsing data"
// Verify sub-menu items...
// Verify item: "Open tabs"
// Verify item" <tab count> tabs
// Verify item: "Browsing history and site data"
// Verify item" <address count> addresses
// Verify item: "Collections
// Verify item" <collection count> collections
// Verify item button: "Delete browsing data"
// Verify item: "Data collection"
// Click on: "Data collection"
// Verify sub-menu items...
// Verify header: "Usage and technical data"
// Verify description: "Shares performance, usage, hardware and customization data about your browser with Mozilla to help us make Firefox Preview better"
// Verify item: toggle default value: 'on'
// Verify item: "Privacy notice"
// Verify item: "Leak Canary" and default toggle value: "Off"
homeScreen {
}.openThreeDotMenu {
}.openSettings {
// PRIVACY
verifyPrivacyHeading()
// PRIVATE BROWSING
verifyPrivateBrowsingButton()
}.openPrivateBrowsingSubMenu {
verifyNavigationToolBarHeader()
}.goBack {
// ENHANCED TRACKING PROTECTION
verifyEnhancedTrackingProtectionButton()
verifyEnhancedTrackingProtectionValue("On")
// Logins
verifyLoginsButton()
// drill down to submenu
verifyPrivateBrowsingButton()
}.openEnhancedTrackingProtectionSubMenu {
verifyNavigationToolBarHeader()
verifyEnhancedTrackingProtectionProtectionSubMenuItems()
// ENHANCED TRACKING PROTECTION EXCEPTION
}.openExceptions {
verifyNavigationToolBarHeader()
verifyEnhancedTrackingProtectionProtectionExceptionsSubMenuItems()
}.goBack {
}.goBack {
// SITE PERMISSIONS
verifySitePermissionsButton()
// drill down on search
}.openSettingsSubMenuSitePermissions {
verifyNavigationToolBarHeader()
verifySitePermissionsSubMenuItems()
// SITE PERMISSIONS AUTOPLAY
}.openAutoPlay {
verifyNavigationToolBarHeader("Autoplay")
verifySitePermissionsAutoPlaySubMenuItems()
}.goBack {
// SITE PERMISSIONS CAMERA
}.openCamera {
verifyNavigationToolBarHeader("Camera")
verifySitePermissionsCommonSubMenuItems()
verifyToggleNameToON("3. Toggle Camera to ON")
}.goBack {
// SITE PERMISSIONS LOCATION
}.openLocation {
verifyNavigationToolBarHeader("Location")
verifySitePermissionsCommonSubMenuItems()
verifyToggleNameToON("3. Toggle Location to ON")
}.goBack {
// SITE PERMISSIONS MICROPHONE
}.openMicrophone {
verifyNavigationToolBarHeader("Microphone")
verifySitePermissionsCommonSubMenuItems()
verifyToggleNameToON("3. Toggle Microphone to ON")
}.goBack {
// SITE PERMISSIONS NOTIFICATION
}.openNotification {
verifyNavigationToolBarHeader("Notification")
verifySitePermissionsNotificationSubMenuItems()
}.goBack {
// SITE PERMISSIONS EXCEPTIONS
}.openExceptions {
verifyNavigationToolBarHeader()
verifySitePermissionsExceptionSubMenuItems()
}.goBack {
}.goBack {
// DELETE BROWSING DATA
verifyDeleteBrowsingDataButton()
}.openSettingsSubMenuDeleteBrowsingData {
verifyNavigationToolBarHeader()
verifyDeleteBrowsingDataSubMenuItems()
}.goBack {
// DELETE BROWSING DATA ON QUIT
verifyDeleteBrowsingDataOnQuitButton()
verifyDeleteBrowsingDataOnQuitValue("Off")
}.openSettingsSubMenuDeleteBrowsingDataOnQuit {
verifyNavigationToolBarHeader()
verifyDeleteBrowsingDataOnQuitSubMenuItems()
}.goBack {
// DATA COLLECTION
verifyDataCollectionButton()
}.openSettingsSubMenuDataCollection {
verifyNavigationToolBarHeader()
verifyDataCollectionSubMenuItems()
}.goBack {
// OPEN LINKS IN APPS
verifyOpenLinksInAppsButton()
verifyOpenLinksInAppsSwitchDefault()
}.goBack {
verifyHomeComponent()
}
}
......
......@@ -32,6 +32,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants.PackageName.GOOGLE_PLAY_SERVICES
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
import org.mozilla.fenix.helpers.assertIsEnabled
import org.mozilla.fenix.helpers.click
/**
......@@ -55,19 +56,22 @@ class SettingsRobot {
fun verifyLoginsButton() = assertLoginsButton()
fun verifyEnhancedTrackingProtectionValue(state: String) =
assertEnhancedTrackingProtectionValue(state)
fun verifyPrivateBrowsingButton() = assertPrivateBrowsingButton()
fun verifySitePermissionsButton() = assertSitePermissionsButton()
fun verifyDeleteBrowsingDataButton() = assertDeleteBrowsingDataButton()
fun verifyDeleteBrowsingDataOnQuitButton() = assertDeleteBrowsingDataOnQuitButton()
fun verifyDeleteBrowsingDataOnQuitValue(state: String) =
assertDeleteBrowsingDataValue(state)
fun verifyDataCollectionButton() = assertDataCollectionButton()
fun verifyLeakCanaryButton() = assertLeakCanaryButton()
fun verifyOpenLinksInAppsButton() = assertOpenLinksInAppsButton()
fun verifyOpenLinksInAppsSwitchDefault() = assertOpenLinksInAppsValue()
fun verifySettingsView() = assertSettingsView()
// ADVANCED SECTION
fun verifyAdvancedHeading() = assertAdvancedHeading()
fun verifyAddons() = assertAddons()
fun verifyRemoteDebug() = assertRemoteDebug()
fun verifyLeakCanaryButton() = assertLeakCanaryButton()
// ABOUT SECTION
fun verifyAboutHeading() = assertAboutHeading()
......@@ -167,6 +171,42 @@ class SettingsRobot {
SettingsSubMenuPrivateBrowsingRobot().interact()
return SettingsSubMenuPrivateBrowsingRobot.Transition()
}
fun openSettingsSubMenuSitePermissions(interact: SettingsSubMenuSitePermissionsRobot.() -> Unit): SettingsSubMenuSitePermissionsRobot.Transition {
scrollToElementByText("Site permissions")
fun sitePermissionButton() = mDevice.findObject(textContains("Site permissions"))
sitePermissionButton().click()
SettingsSubMenuSitePermissionsRobot().interact()
return SettingsSubMenuSitePermissionsRobot.Transition()
}
fun openSettingsSubMenuDeleteBrowsingData(interact: SettingsSubMenuDeleteBrowsingDataRobot.() -> Unit): SettingsSubMenuDeleteBrowsingDataRobot.Transition {
scrollToElementByText("Delete browsing data")
fun deleteBrowsingDataButton() = mDevice.findObject(textContains("Delete browsing data"))
deleteBrowsingDataButton().click()
SettingsSubMenuDeleteBrowsingDataRobot().interact()
return SettingsSubMenuDeleteBrowsingDataRobot.Transition()
}
fun openSettingsSubMenuDeleteBrowsingDataOnQuit(interact: SettingsSubMenuDeleteBrowsingDataOnQuitRobot.() -> Unit): SettingsSubMenuDeleteBrowsingDataOnQuitRobot.Transition {
scrollToElementByText("Delete browsing data on quit")
fun deleteBrowsingDataOnQuitButton() = mDevice.findObject(textContains("Delete browsing data on quit"))
deleteBrowsingDataOnQuitButton().click()
SettingsSubMenuDeleteBrowsingDataOnQuitRobot().interact()
return SettingsSubMenuDeleteBrowsingDataOnQuitRobot.Transition()
}
fun openSettingsSubMenuDataCollection(interact: SettingsSubMenuDataCollectionRobot.() -> Unit): SettingsSubMenuDataCollectionRobot.Transition {
scrollToElementByText("Data collection")
fun dataCollectionButton() = mDevice.findObject(textContains("Data collection"))
dataCollectionButton().click()
SettingsSubMenuDataCollectionRobot().interact()
return SettingsSubMenuDataCollectionRobot.Transition()
}
}
}
......@@ -252,13 +292,26 @@ private fun assertDeleteBrowsingDataOnQuitButton() {
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertDeleteBrowsingDataValue(state: String) {
mDevice.wait(Until.findObject(By.text("Delete browsing data on quit")), waitingTime)
onView(withText(state)).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertDataCollectionButton() = onView(withText("Data collection"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertLeakCanaryButton() {
scrollToElementByText("LeakCanary")
onView(withText("LeakCanary"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun openLinksInAppsButton() = onView(withText("Open links in apps"))
private fun assertOpenLinksInAppsButton() = openLinksInAppsButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertOpenLinksInAppsValue() = openLinksInAppsButton()
.assertIsEnabled(isEnabled = true)
// DEVELOPER TOOLS SECTION
private fun assertDeveloperToolsHeading() {
scrollToElementByText("Developer tools")
onView(withText("Developer tools"))
}
// ADVANCED SECTION
......@@ -280,6 +333,12 @@ private fun assertRemoteDebug() {
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertLeakCanaryButton() {
scrollToElementByText("LeakCanary")
onView(withText("LeakCanary"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
// ABOUT SECTION
private fun assertAboutHeading(): ViewInteraction {
scrollToElementByText("About")
......@@ -299,7 +358,7 @@ private fun assertAboutFirefoxPreview(): ViewInteraction {
.check(matches(isCompletelyDisplayed()))
}
fun swipeToBottom() = onView(ViewMatchers.withId(R.id.recycler_view)).perform(ViewActions.swipeUp())
fun swipeToBottom() = onView(withId(R.id.recycler_view)).perform(ViewActions.swipeUp())
fun clickRateButtonGooglePlay() {
assertRateOnGooglePlay().click()
......
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withParent
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.hamcrest.CoreMatchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.assertIsEnabled
import org.mozilla.fenix.helpers.click
/**
* Implementation of Robot Pattern for the settings Data Collection sub menu.
*/
class SettingsSubMenuDataCollectionRobot {
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
fun verifyDataCollectionOptions() = assertDataCollectionOptions()
fun verifyUsageAndTechnicalDataSwitchDefault() = assertUsageAndTechnicalDataSwitchDefault()
fun verifyMarketingDataSwitchDefault() = assertMarketingDataValueSwitchDefault()
fun verifyDataCollectionSubMenuItems() {
verifyDataCollectionOptions()
verifyUsageAndTechnicalDataSwitchDefault()
verifyMarketingDataSwitchDefault()
}
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
goBackButton().click()
SettingsRobot().interact()
return SettingsRobot.Transition()
}
}
}
private fun goBackButton() =
onView(withContentDescription("Navigate up"))
private fun assertNavigationToolBarHeader() = onView(
allOf(withParent(withId(R.id.navigationToolbar)),
withText(R.string.preferences_data_collection)))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertDataCollectionOptions() {
onView(withText(R.string.preference_usage_data))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
val usageAndTechnicalDataText =
"Shares performance, usage, hardware and customization data about your browser with Mozilla to help us make Firefox Preview better"
onView(withText(usageAndTechnicalDataText))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withText(R.string.preferences_marketing_data))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
val marketingDataText =
"Shares data about what features you use in Firefox Preview with Leanplum, our mobile marketing vendor."
onView(withText(marketingDataText))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun usageAndTechnicalDataButton() = onView(withText(R.string.preference_usage_data))
private fun assertUsageAndTechnicalDataSwitchDefault() = usageAndTechnicalDataButton()
.assertIsEnabled(isEnabled = true)
private fun marketingDataButton() = onView(withText(R.string.preferences_marketing_data))
private fun assertMarketingDataValueSwitchDefault() = marketingDataButton()
.assertIsEnabled(isEnabled = true)
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.withChild
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withParentIndex
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.hamcrest.CoreMatchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.isChecked
/**
* Implementation of Robot Pattern for the settings Delete Browsing Data On Quit sub menu.
*/
class SettingsSubMenuDeleteBrowsingDataOnQuitRobot {
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
fun verifyDeleteBrowsingOnQuitButton() = assertDeleteBrowsingOnQuitButton()
fun verifyDeleteBrowsingOnQuitButtonSummary() = assertDeleteBrowsingOnQuitButtonSummary()
fun verifyDeleteBrowsingOnQuitButtonSwitchDefault() = assertDeleteBrowsingOnQuitButtonSwitchDefault()
fun clickDeleteBrowsingOnQuitButtonSwitchDefaultChange() = verifyDeleteBrowsingOnQuitButtonSwitchDefault().click()
fun verifyAllTheCheckBoxesText() = assertAllTheCheckBoxesText()
fun verifyAllTheCheckBoxesChecked() = assertAllTheCheckBoxesChecked()
fun verifyDeleteBrowsingDataOnQuitSubMenuItems() {
verifyDeleteBrowsingOnQuitButton()
verifyDeleteBrowsingOnQuitButtonSummary()
verifyDeleteBrowsingOnQuitButtonSwitchDefault()
clickDeleteBrowsingOnQuitButtonSwitchDefaultChange()
verifyAllTheCheckBoxesText()
verifyAllTheCheckBoxesChecked()
}
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
goBackButton().click()
SettingsRobot().interact()
return SettingsRobot.Transition()
}
}
}
private fun goBackButton() = onView(withContentDescription("Navigate up"))
private fun assertNavigationToolBarHeader() = onView(allOf(withId(R.id.navigationToolbar),
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun deleteBrowsingOnQuitButton() = onView(allOf(withParentIndex(0),
withChild(withText(R.string.preferences_delete_browsing_data_on_quit))))
private fun assertDeleteBrowsingOnQuitButton() = deleteBrowsingOnQuitButton()
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertDeleteBrowsingOnQuitButtonSummary() = onView(
withText(R.string.preference_summary_delete_browsing_data_on_quit_2))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertDeleteBrowsingOnQuitButtonSwitchDefault() = onView(withResourceName("switch_widget"))
.check(matches(isChecked(false)))
private fun assertAllTheCheckBoxesText() {
onView(withText(R.string.preferences_delete_browsing_data_tabs_title))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withText(R.string.preferences_delete_browsing_data_on_quit_browsing_history))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withText(R.string.preferences_delete_browsing_data_cookies))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withText(R.string.preferences_delete_browsing_data_cookies_subtitle))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withText(R.string.preferences_delete_browsing_data_cached_files))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withText(R.string.preferences_delete_browsing_data_cached_files_subtitle))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withText(R.string.preferences_delete_browsing_data_site_permissions))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
private fun assertAllTheCheckBoxesChecked() {
// Only verifying the options, checkboxes default value can't be verified due to issue #9471
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
import androidx.test.espresso.matcher.ViewMatchers.withChild
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.assertIsChecked
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.TestAssetHelper
/**
* Implementation of Robot Pattern for the settings Delete Browsing Data sub menu.
*/
class SettingsSubMenuDeleteBrowsingDataRobot {
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
fun verifyDeleteBrowsingDataButton() = assertDeleteBrowsingDataButton()
fun verifyClickDeleteBrowsingDataButton() = assertClickDeleteBrowsingDataButton()
fun verifyMessageInDialogBox() = assertMessageInDialogBox()
fun verifyDeleteButtonInDialogBox() = assertDeleteButtonInDialogBox()
fun verifyCancelButtonInDialogBox() = assertCancelButtonInDialogBox()
fun verifyAllTheCheckBoxesText() = assertAllTheCheckBoxesText()
fun verifyAllTheCheckBoxesChecked() = assertAllTheCheckBoxesChecked()
fun verifyContentsInDialogBox() {
verifyMessageInDialogBox()
verifyDeleteButtonInDialogBox()
verifyCancelButtonInDialogBox()
}
fun clickCancelButtonInDialogBoxAndVerifyContentsInDialogBox() {
mDevice.wait(
Until.findObject(By.text("Delete browsing data")),
TestAssetHelper.waitingTime
)
verifyClickDeleteBrowsingDataButton()
verifyContentsInDialogBox()
cancelButton().click()
}
fun verifyDeleteBrowsingDataSubMenuItems() {
verifyDeleteBrowsingDataButton()
clickCancelButtonInDialogBoxAndVerifyContentsInDialogBox()
verifyAllTheCheckBoxesText()
verifyAllTheCheckBoxesChecked()
}
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
goBackButton().click()
SettingsRobot().interact()
return SettingsRobot.Transition()
}
}
}
private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up")))
private fun assertNavigationToolBarHeader() {
onView(allOf(withId(R.id.navigationToolbar),
withChild(withText(R.string.preferences_delete_browsing_data))))
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
}
private fun assertDeleteBrowsingDataButton() {
onView(withId(R.id.delete_data))
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
}