Skip to content

Commit

Permalink
Bug 1821430 - Update strings in the ETP settings screen part 2. Use t…
Browse files Browse the repository at this point in the history
…he new strings and update the layout (#1213)

Co-authored-by: t-p-white <t-p-white>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
t-p-white and mergify[bot] committed Mar 31, 2023
1 parent e83ae92 commit 4ea5308
Show file tree
Hide file tree
Showing 13 changed files with 386 additions and 260 deletions.
Expand Up @@ -123,7 +123,7 @@ class DeepLinkTest {
@Test
fun openSettingsTrackingProtection() {
robot.openSettingsTrackingProtection {
verifyEnhancedTrackingProtectionHeader()
verifyEnhancedTrackingProtectionSummary()
}
}

Expand Down
Expand Up @@ -33,7 +33,6 @@ import org.mozilla.fenix.ui.robots.navigationToolbar
* Including
* - Verifying default states
* - Verifying Enhanced Tracking Protection notification bubble
* - Verifying Enhanced Tracking Protection notification shield
* - Verifying Enhanced Tracking Protection content sheet
* - Verifying Enhanced Tracking Protection content sheet details
* - Verifying Enhanced Tracking Protection toggle
Expand Down Expand Up @@ -72,8 +71,7 @@ class EnhancedTrackingProtectionTest {
verifyEnhancedTrackingProtectionButton()
verifySettingsOptionSummary("Enhanced Tracking Protection", "Standard")
}.openEnhancedTrackingProtectionSubMenu {
verifyEnhancedTrackingProtectionHeader()
verifyEnhancedTrackingProtectionHeaderDescription()
verifyEnhancedTrackingProtectionSummary()
verifyLearnMoreText()
verifyEnhancedTrackingProtectionTextWithSwitchWidget()
verifyTrackingProtectionSwitchEnabled()
Expand Down
Expand Up @@ -40,9 +40,7 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {

fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()

fun verifyEnhancedTrackingProtectionHeader() = assertEnhancedTrackingProtectionHeader()

fun verifyEnhancedTrackingProtectionHeaderDescription() = assertEnhancedTrackingProtectionHeaderDescription()
fun verifyEnhancedTrackingProtectionSummary() = assertEnhancedTrackingProtectionSummary()

fun verifyLearnMoreText() = assertLearnMoreText()

Expand All @@ -61,25 +59,30 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {

fun verifyTrackingProtectionSwitchEnabled() = assertTrackingProtectionSwitchEnabled()

fun switchEnhancedTrackingProtectionToggle() = onView(withResourceName("switch_widget")).click()
fun switchEnhancedTrackingProtectionToggle() = onView(
allOf(
withText("Enhanced Tracking Protection"),
hasSibling(withResourceName("checkbox")),
),
).click()

fun verifyStandardOptionDescription() {
onView(withText(R.string.preference_enhanced_tracking_protection_standard_description_4))
onView(withText(R.string.preference_enhanced_tracking_protection_standard_description_5))
.check(matches(isDisplayed()))
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_standard_info_button))
.check(matches(isDisplayed()))
}

fun verifyStrictOptionDescription() {
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_strict_description_3))
onView(withText(R.string.preference_enhanced_tracking_protection_strict_description_4))
.check(matches(isDisplayed()))
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_strict_info_button))
.check(matches(isDisplayed()))
}

fun verifyCustomTrackingProtectionSettings() {
scrollToElementByText("Redirect Trackers")
onView(withText(org.mozilla.fenix.R.string.preference_enhanced_tracking_protection_custom_description_2))
onView(withText(R.string.preference_enhanced_tracking_protection_custom_description_2))
.check(matches(isDisplayed()))
onView(withContentDescription(R.string.preference_enhanced_tracking_protection_custom_info_button))
.check(matches(isDisplayed()))
Expand Down Expand Up @@ -171,22 +174,15 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot {
private fun assertNavigationToolBarHeader() {
onView(
allOf(
withParent(withId(org.mozilla.fenix.R.id.navigationToolbar)),
withParent(withId(R.id.navigationToolbar)),
withText("Enhanced Tracking Protection"),
),
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}

private fun assertEnhancedTrackingProtectionHeader() {
onView(withText("Browse without being followed"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}

private fun assertEnhancedTrackingProtectionHeaderDescription() {
onView(
withText("Keep your data to yourself. $appName protects you from many of the most common trackers that follow what you do online."),
)
private fun assertEnhancedTrackingProtectionSummary() {
onView(withText("$appName protects you from many of the most common trackers that follow what you do online."))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}

Expand All @@ -206,7 +202,7 @@ private fun assertEnhancedTrackingProtectionTextWithSwitchWidget() {
}

private fun assertTrackingProtectionSwitchEnabled() {
onView(withResourceName("switch_widget")).check(
onView(withResourceName("checkbox")).check(
matches(
isChecked(
true,
Expand Down
@@ -0,0 +1,26 @@
/* 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.settings

import android.content.Context
import android.util.AttributeSet
import androidx.preference.CheckBoxPreference
import androidx.preference.SwitchPreference
import org.mozilla.fenix.R

/**
* Switch Preference that adheres to Fenix styling.
*
* **Note:** The [SwitchPreference] layout internal id "switch_widget" has a min API of 24, so we use
* [CheckBoxPreference] instead and use the layout internal id "checkbox".
*/
class FenixSwitchPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
) : CheckBoxPreference(context, attrs) {
init {
layoutResource = R.layout.preference_widget_switch_fenix_style
}
}
Expand Up @@ -11,7 +11,6 @@ import androidx.preference.CheckBoxPreference
import androidx.preference.DropDownPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.HomeActivity
Expand Down Expand Up @@ -72,7 +71,7 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {

// Tracking Protection Switch
val preferenceTP =
requirePreference<SwitchPreference>(R.string.pref_key_tracking_protection)
requirePreference<FenixSwitchPreference>(R.string.pref_key_tracking_protection)

preferenceTP.isChecked = requireContext().settings().shouldUseTrackingProtection
preferenceTP.setOnPreferenceChangeListener<Boolean> { preference, trackingProtectionOn ->
Expand All @@ -97,7 +96,7 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
true
}
learnMorePreference.summary = getString(
R.string.preference_enhanced_tracking_protection_explanation,
R.string.preference_enhanced_tracking_protection_explanation_2,
getString(R.string.app_name),
)

Expand Down

0 comments on commit 4ea5308

Please sign in to comment.