For #21002: Add testETPOffGlobally UI smoke test
This commit is contained in:
parent
4fe3d6db02
commit
b1dab8170c
|
@ -25,6 +25,10 @@ class FeatureSettingsHelper {
|
|||
settings.showRecentTabsFeature = enabled
|
||||
}
|
||||
|
||||
fun setStrictETPEnabled() {
|
||||
settings.setStrictETP()
|
||||
}
|
||||
|
||||
// Important:
|
||||
// Use this after each test if you have modified these feature settings
|
||||
// to make sure the app goes back to the default state
|
||||
|
|
|
@ -448,7 +448,7 @@ class SmokeTest {
|
|||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
verifyEnhancedTrackingProtectionOptions()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
selectTrackingProtectionOption("Custom")
|
||||
verifyCustomTrackingProtectionSettings()
|
||||
}.goBackToHomeScreen {}
|
||||
|
|
|
@ -9,8 +9,9 @@ import org.junit.After
|
|||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.FeatureSettingsHelper
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.ui.robots.enhancedTrackingProtection
|
||||
|
@ -33,6 +34,7 @@ import org.mozilla.fenix.ui.robots.settingsSubMenuEnhancedTrackingProtection
|
|||
|
||||
class StrictEnhancedTrackingProtectionTest {
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
private val featureSettingsHelper = FeatureSettingsHelper()
|
||||
|
||||
@get:Rule
|
||||
val activityTestRule = HomeActivityTestRule()
|
||||
|
@ -43,15 +45,14 @@ class StrictEnhancedTrackingProtectionTest {
|
|||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
|
||||
val settings = activityTestRule.activity.settings()
|
||||
settings.setStrictETP()
|
||||
settings.shouldShowJumpBackInCFR = false
|
||||
featureSettingsHelper.setStrictETPEnabled()
|
||||
featureSettingsHelper.setJumpBackCFREnabled(false)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
featureSettingsHelper.resetAllFeatureFlags()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -63,13 +64,46 @@ class StrictEnhancedTrackingProtectionTest {
|
|||
verifyEnhancedTrackingProtectionValue("On")
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
verifyEnhancedTrackingProtectionHeader()
|
||||
verifyEnhancedTrackingProtectionOptions()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
verifyTrackingProtectionSwitchEnabled()
|
||||
}.openExceptions {
|
||||
verifyDefault()
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun testETPOffGlobally() {
|
||||
val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
switchEnhancedTrackingProtectionToggle()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled(false)
|
||||
}.goBack {
|
||||
}.goBack { }
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(genericPage.url) { }
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
verifyETPSwitchVisibility(false)
|
||||
}.closeEnhancedTrackingProtectionSheet {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
switchEnhancedTrackingProtectionToggle()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled(true)
|
||||
}.goBack {
|
||||
}.goBackToBrowser { }
|
||||
enhancedTrackingProtection {
|
||||
}.openEnhancedTrackingProtectionSheet {
|
||||
verifyETPSwitchVisibility(true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStrictVisitProtectionSheet() {
|
||||
val genericPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
|
@ -113,7 +147,7 @@ class StrictEnhancedTrackingProtectionTest {
|
|||
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||||
}.openProtectionSettings {
|
||||
verifyEnhancedTrackingProtectionHeader()
|
||||
verifyEnhancedTrackingProtectionOptions()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
verifyTrackingProtectionSwitchEnabled()
|
||||
}
|
||||
|
||||
|
|
|
@ -160,19 +160,10 @@ class BrowserRobot {
|
|||
)
|
||||
}
|
||||
|
||||
fun verifyNavURLBar() = assertNavURLBar()
|
||||
|
||||
fun verifyNavURLBarHidden() = assertNavURLBarHidden()
|
||||
|
||||
fun verifySecureConnectionLockIcon() = assertSecureConnectionLockIcon()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionSwitch() = assertEnhancedTrackingProtectionSwitch()
|
||||
|
||||
fun verifyEnhancedTrackingOptions() {
|
||||
onView(withId(R.id.mozac_browser_toolbar_security_indicator)).click()
|
||||
verifyEnhancedTrackingProtectionSwitch()
|
||||
}
|
||||
|
||||
fun verifyMenuButton() = assertMenuButton()
|
||||
|
||||
fun verifyNavURLBarItems() {
|
||||
|
@ -674,16 +665,6 @@ private fun assertNavURLBar() = assertTrue(navURLBar().waitForExists(waitingTime
|
|||
|
||||
private fun assertNavURLBarHidden() = assertTrue(navURLBar().waitUntilGone(waitingTime))
|
||||
|
||||
private fun assertEnhancedTrackingProtectionSwitch() {
|
||||
withText(R.id.trackingProtectionSwitch)
|
||||
.matches(withEffectiveVisibility(Visibility.VISIBLE))
|
||||
}
|
||||
|
||||
private fun assertProtectionSettingsButton() {
|
||||
onView(withId(R.id.protection_settings))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertSecureConnectionLockIcon() {
|
||||
onView(withId(R.id.mozac_browser_toolbar_security_indicator))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
|
|
|
@ -21,6 +21,7 @@ import androidx.test.uiautomator.UiSelector
|
|||
import androidx.test.uiautomator.Until
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.hamcrest.Matchers.containsString
|
||||
import org.hamcrest.Matchers.not
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||
import org.mozilla.fenix.helpers.TestHelper.packageName
|
||||
|
@ -41,6 +42,8 @@ class EnhancedTrackingProtectionRobot {
|
|||
fun verifyEnhancedTrackingProtectionDetailsStatus(status: String) =
|
||||
assertEnhancedTrackingProtectionDetailsStatus(status)
|
||||
|
||||
fun verifyETPSwitchVisibility(visible: Boolean) = assertETPSwitchVisibility(visible)
|
||||
|
||||
fun verifyTrackingCookiesBlocked() = assertTrackingCookiesBlocked()
|
||||
|
||||
fun verifyFingerprintersBlocked() = assertFingerprintersBlocked()
|
||||
|
@ -86,7 +89,7 @@ class EnhancedTrackingProtectionRobot {
|
|||
}
|
||||
|
||||
fun disableEnhancedTrackingProtectionFromSheet(interact: EnhancedTrackingProtectionRobot.() -> Unit): Transition {
|
||||
disableEnhancedTrackingProtection().click()
|
||||
enhancedTrackingProtectionSwitch().click()
|
||||
|
||||
EnhancedTrackingProtectionRobot().interact()
|
||||
return Transition()
|
||||
|
@ -116,6 +119,16 @@ fun enhancedTrackingProtection(interact: EnhancedTrackingProtectionRobot.() -> U
|
|||
return EnhancedTrackingProtectionRobot.Transition()
|
||||
}
|
||||
|
||||
private fun assertETPSwitchVisibility(visible: Boolean) {
|
||||
if (visible) {
|
||||
enhancedTrackingProtectionSwitch()
|
||||
.check(matches(isDisplayed()))
|
||||
} else {
|
||||
enhancedTrackingProtectionSwitch()
|
||||
.check(matches(not(isDisplayed())))
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionSheetStatus(status: String, state: Boolean) {
|
||||
mDevice.waitNotNull(Until.findObjects(By.textContains(status)))
|
||||
onView(ViewMatchers.withResourceName("switch_widget")).check(
|
||||
|
@ -134,7 +147,7 @@ private fun assertEnhancedTrackingProtectionDetailsStatus(status: String) {
|
|||
private fun openEnhancedTrackingProtectionSheet() =
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_security_indicator"))
|
||||
|
||||
private fun disableEnhancedTrackingProtection() =
|
||||
private fun enhancedTrackingProtectionSwitch() =
|
||||
onView(ViewMatchers.withResourceName("switch_widget"))
|
||||
|
||||
private fun trackingProtectionSettingsButton() =
|
||||
|
|
|
@ -25,7 +25,6 @@ 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.hamcrest.CoreMatchers.not
|
||||
import org.mozilla.fenix.helpers.TestHelper.appName
|
||||
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
|
||||
import org.mozilla.fenix.helpers.assertIsChecked
|
||||
|
@ -48,7 +47,7 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
|
|||
|
||||
fun verifyEnhancedTrackingProtectionTextWithSwitchWidget() = assertEnhancedTrackingProtectionTextWithSwitchWidget()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionOptions() = assertEnhancedTrackingProtectionOptions()
|
||||
fun verifyEnhancedTrackingProtectionOptionsEnabled(enabled: Boolean = true) = assertEnhancedTrackingProtectionOptionsState(enabled)
|
||||
|
||||
fun verifyTrackingProtectionSwitchEnabled() = assertTrackingProtectionSwitchEnabled()
|
||||
|
||||
|
@ -63,7 +62,7 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
|
|||
verifyEnhancedTrackingProtectionTextWithSwitchWidget()
|
||||
verifyTrackingProtectionSwitchEnabled()
|
||||
verifyRadioButtonDefaults()
|
||||
verifyEnhancedTrackingProtectionOptions()
|
||||
verifyEnhancedTrackingProtectionOptionsEnabled()
|
||||
}
|
||||
|
||||
fun verifyCustomTrackingProtectionSettings() = assertCustomTrackingProtectionSettings()
|
||||
|
@ -153,48 +152,24 @@ private fun assertEnhancedTrackingProtectionTextWithSwitchWidget() {
|
|||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionOptions() {
|
||||
private fun assertEnhancedTrackingProtectionOptionsState(enabled: Boolean) {
|
||||
onView(withText("Standard (default)"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_standard_description_4))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText("Strict"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_strict_description_3))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
onView(withText("Custom"))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
|
||||
val customText =
|
||||
"Choose which trackers and scripts to block."
|
||||
onView(withText(customText))
|
||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionOptionsGrayedOut() {
|
||||
onView(withText("Standard (default)"))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_standard_description_4))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
onView(withText("Strict"))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_strict_description_3))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
onView(withText("Custom"))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
val customText =
|
||||
"Choose which trackers and scripts to block."
|
||||
onView(withText(customText))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_custom_description_2))
|
||||
.check(matches(isEnabled(enabled)))
|
||||
}
|
||||
|
||||
private fun assertTrackingProtectionSwitchEnabled() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user