No issue: verify ETP toolbar shield icon is not displayed if ETP is OFF globally in ETP UI tests (#12623)
parent
6ab6f3efe9
commit
899f6e63ad
|
@ -215,4 +215,39 @@ class SmokeTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifyETPToolbarShieldIconIsNotDisplayedIfETPIsOFFGloballyTest() {
|
||||
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
clickEnhancedTrackingProtectionDefaults()
|
||||
verifyEnhancedTrackingProtectionOptionsGrayedOut()
|
||||
}.goBackToHomeScreen {
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
verifyEnhancedTrackingProtectionPanelNotVisible()
|
||||
}.openThreeDotMenu {
|
||||
}.clickAddOnsReportSiteIssue {
|
||||
verifyUrl("webcompat.com/issues/new")
|
||||
verifyTabCounter("2")
|
||||
}.openTabDrawer {
|
||||
}.openHomeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openEnhancedTrackingProtectionSubMenu {
|
||||
clickEnhancedTrackingProtectionDefaults()
|
||||
}.goBackToHomeScreen {
|
||||
}.openTabDrawer {
|
||||
}.openTab(defaultWebPage.title) {
|
||||
clickEnhancedTrackingProtectionPanel()
|
||||
verifyEnhancedTrackingProtectionSwitch()
|
||||
// Turning off TP Switch results in adding the WebPage to exception list
|
||||
clickEnhancedTrackingProtectionSwitchOffOn()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
|||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.By
|
||||
|
@ -144,6 +145,8 @@ class BrowserRobot {
|
|||
|
||||
fun verifyEnhancedTrackingProtectionSwitch() = assertEnhancedTrackingProtectionSwitch()
|
||||
|
||||
fun clickEnhancedTrackingProtectionSwitchOffOn() = onView(withResourceName("switch_widget")).click()
|
||||
|
||||
fun verifyProtectionSettingsButton() = assertProtectionSettingsButton()
|
||||
|
||||
fun verifyEnhancedTrackingOptions() {
|
||||
|
@ -188,6 +191,8 @@ class BrowserRobot {
|
|||
|
||||
fun clickEnhancedTrackingProtectionPanel() = enhancedTrackingProtectionPanel().click()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionPanelNotVisible() = assertEnhancedTrackingProtectionPanelNotVisible()
|
||||
|
||||
fun clickContextOpenLinkInNewTab() {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
mDevice.waitNotNull(
|
||||
|
@ -420,6 +425,11 @@ private fun assertNavURLBar() = navURLBar()
|
|||
|
||||
fun enhancedTrackingProtectionPanel() = onView(withId(R.id.mozac_browser_toolbar_tracking_protection_indicator))
|
||||
|
||||
private fun assertEnhancedTrackingProtectionPanelNotVisible() {
|
||||
enhancedTrackingProtectionPanel()
|
||||
.check(matches(withEffectiveVisibility(Visibility.GONE)))
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionSwitch() {
|
||||
withText(R.id.trackingProtectionSwitch)
|
||||
.matches(withEffectiveVisibility(Visibility.VISIBLE))
|
||||
|
|
|
@ -141,6 +141,7 @@ class SettingsRobot {
|
|||
}
|
||||
|
||||
fun openEnhancedTrackingProtectionSubMenu(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition {
|
||||
scrollToElementByText("Enhanced Tracking Protection")
|
||||
fun enhancedTrackingProtectionButton() =
|
||||
onView(withText("Enhanced Tracking Protection"))
|
||||
enhancedTrackingProtectionButton().click()
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.mozilla.fenix.ui.robots
|
|||
import androidx.preference.R
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.Espresso.pressBack
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||
|
@ -23,9 +24,11 @@ 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.assertIsChecked
|
||||
import org.mozilla.fenix.helpers.click
|
||||
import org.mozilla.fenix.helpers.isChecked
|
||||
import org.mozilla.fenix.helpers.isEnabled
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the settings Enhanced Tracking Protection sub menu.
|
||||
|
@ -44,8 +47,12 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
|
|||
|
||||
fun verifyEnhancedTrackingProtectionOptions() = assertEnhancedTrackingProtectionOptions()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionOptionsGrayedOut() = assertEnhancedTrackingProtectionOptionsGrayedOut()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionDefaults() = assertEnhancedTrackingProtectionDefaults()
|
||||
|
||||
fun clickEnhancedTrackingProtectionDefaults() = onView(withResourceName("switch_widget")).click()
|
||||
|
||||
fun verifyRadioButtonDefaults() = assertRadioButtonDefaults()
|
||||
|
||||
fun verifyEnhancedTrackingProtectionProtectionSubMenuItems() {
|
||||
|
@ -61,6 +68,16 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
|
|||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
||||
|
||||
fun goBackToHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
||||
// To settings
|
||||
goBackButton().click()
|
||||
// To HomeScreen
|
||||
pressBack()
|
||||
|
||||
HomeScreenRobot().interact()
|
||||
return HomeScreenRobot.Transition()
|
||||
}
|
||||
|
||||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||
goBackButton().click()
|
||||
|
||||
|
@ -141,6 +158,31 @@ private fun assertEnhancedTrackingProtectionOptions() {
|
|||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionOptionsGrayedOut() {
|
||||
onView(withText("Standard (default)"))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
val stdText = "Blocks fewer trackers. Pages will load normally."
|
||||
onView(withText(stdText))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
onView(withText("Strict"))
|
||||
.check(matches(not(isEnabled(true))))
|
||||
|
||||
val strictText =
|
||||
"Blocks more trackers, ads, and popups. Pages load faster, but some functionality might not work."
|
||||
onView(withText(strictText))
|
||||
.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))))
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionDefaults() {
|
||||
onView(withResourceName("switch_widget")).check(
|
||||
matches(
|
||||
|
|
Loading…
Reference in New Issue