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.isDisplayed
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.uiautomator.By
|
import androidx.test.uiautomator.By
|
||||||
|
@ -144,6 +145,8 @@ class BrowserRobot {
|
||||||
|
|
||||||
fun verifyEnhancedTrackingProtectionSwitch() = assertEnhancedTrackingProtectionSwitch()
|
fun verifyEnhancedTrackingProtectionSwitch() = assertEnhancedTrackingProtectionSwitch()
|
||||||
|
|
||||||
|
fun clickEnhancedTrackingProtectionSwitchOffOn() = onView(withResourceName("switch_widget")).click()
|
||||||
|
|
||||||
fun verifyProtectionSettingsButton() = assertProtectionSettingsButton()
|
fun verifyProtectionSettingsButton() = assertProtectionSettingsButton()
|
||||||
|
|
||||||
fun verifyEnhancedTrackingOptions() {
|
fun verifyEnhancedTrackingOptions() {
|
||||||
|
@ -188,6 +191,8 @@ class BrowserRobot {
|
||||||
|
|
||||||
fun clickEnhancedTrackingProtectionPanel() = enhancedTrackingProtectionPanel().click()
|
fun clickEnhancedTrackingProtectionPanel() = enhancedTrackingProtectionPanel().click()
|
||||||
|
|
||||||
|
fun verifyEnhancedTrackingProtectionPanelNotVisible() = assertEnhancedTrackingProtectionPanelNotVisible()
|
||||||
|
|
||||||
fun clickContextOpenLinkInNewTab() {
|
fun clickContextOpenLinkInNewTab() {
|
||||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||||
mDevice.waitNotNull(
|
mDevice.waitNotNull(
|
||||||
|
@ -420,6 +425,11 @@ private fun assertNavURLBar() = navURLBar()
|
||||||
|
|
||||||
fun enhancedTrackingProtectionPanel() = onView(withId(R.id.mozac_browser_toolbar_tracking_protection_indicator))
|
fun enhancedTrackingProtectionPanel() = onView(withId(R.id.mozac_browser_toolbar_tracking_protection_indicator))
|
||||||
|
|
||||||
|
private fun assertEnhancedTrackingProtectionPanelNotVisible() {
|
||||||
|
enhancedTrackingProtectionPanel()
|
||||||
|
.check(matches(withEffectiveVisibility(Visibility.GONE)))
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertEnhancedTrackingProtectionSwitch() {
|
private fun assertEnhancedTrackingProtectionSwitch() {
|
||||||
withText(R.id.trackingProtectionSwitch)
|
withText(R.id.trackingProtectionSwitch)
|
||||||
.matches(withEffectiveVisibility(Visibility.VISIBLE))
|
.matches(withEffectiveVisibility(Visibility.VISIBLE))
|
||||||
|
|
|
@ -141,6 +141,7 @@ class SettingsRobot {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openEnhancedTrackingProtectionSubMenu(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition {
|
fun openEnhancedTrackingProtectionSubMenu(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition {
|
||||||
|
scrollToElementByText("Enhanced Tracking Protection")
|
||||||
fun enhancedTrackingProtectionButton() =
|
fun enhancedTrackingProtectionButton() =
|
||||||
onView(withText("Enhanced Tracking Protection"))
|
onView(withText("Enhanced Tracking Protection"))
|
||||||
enhancedTrackingProtectionButton().click()
|
enhancedTrackingProtectionButton().click()
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.mozilla.fenix.ui.robots
|
||||||
import androidx.preference.R
|
import androidx.preference.R
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
|
import androidx.test.espresso.Espresso.pressBack
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
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.platform.app.InstrumentationRegistry
|
||||||
import androidx.test.uiautomator.UiDevice
|
import androidx.test.uiautomator.UiDevice
|
||||||
import org.hamcrest.CoreMatchers.allOf
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
|
import org.hamcrest.CoreMatchers.not
|
||||||
import org.mozilla.fenix.helpers.assertIsChecked
|
import org.mozilla.fenix.helpers.assertIsChecked
|
||||||
import org.mozilla.fenix.helpers.click
|
import org.mozilla.fenix.helpers.click
|
||||||
import org.mozilla.fenix.helpers.isChecked
|
import org.mozilla.fenix.helpers.isChecked
|
||||||
|
import org.mozilla.fenix.helpers.isEnabled
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of Robot Pattern for the settings Enhanced Tracking Protection sub menu.
|
* Implementation of Robot Pattern for the settings Enhanced Tracking Protection sub menu.
|
||||||
|
@ -44,8 +47,12 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
|
||||||
|
|
||||||
fun verifyEnhancedTrackingProtectionOptions() = assertEnhancedTrackingProtectionOptions()
|
fun verifyEnhancedTrackingProtectionOptions() = assertEnhancedTrackingProtectionOptions()
|
||||||
|
|
||||||
|
fun verifyEnhancedTrackingProtectionOptionsGrayedOut() = assertEnhancedTrackingProtectionOptionsGrayedOut()
|
||||||
|
|
||||||
fun verifyEnhancedTrackingProtectionDefaults() = assertEnhancedTrackingProtectionDefaults()
|
fun verifyEnhancedTrackingProtectionDefaults() = assertEnhancedTrackingProtectionDefaults()
|
||||||
|
|
||||||
|
fun clickEnhancedTrackingProtectionDefaults() = onView(withResourceName("switch_widget")).click()
|
||||||
|
|
||||||
fun verifyRadioButtonDefaults() = assertRadioButtonDefaults()
|
fun verifyRadioButtonDefaults() = assertRadioButtonDefaults()
|
||||||
|
|
||||||
fun verifyEnhancedTrackingProtectionProtectionSubMenuItems() {
|
fun verifyEnhancedTrackingProtectionProtectionSubMenuItems() {
|
||||||
|
@ -61,6 +68,16 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
|
||||||
class Transition {
|
class Transition {
|
||||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!!
|
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 {
|
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||||
goBackButton().click()
|
goBackButton().click()
|
||||||
|
|
||||||
|
@ -141,6 +158,31 @@ private fun assertEnhancedTrackingProtectionOptions() {
|
||||||
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
.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() {
|
private fun assertEnhancedTrackingProtectionDefaults() {
|
||||||
onView(withResourceName("switch_widget")).check(
|
onView(withResourceName("switch_widget")).check(
|
||||||
matches(
|
matches(
|
||||||
|
|
Loading…
Reference in New Issue