2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

Bug 1822050 - Verify cookie banner reduction summary updates in UI tests

This commit is contained in:
AndiAJ 2023-03-13 15:55:00 +02:00 committed by mergify[bot]
parent 479fbd0206
commit e94bc0b1e6
3 changed files with 32 additions and 4 deletions

View File

@ -5,7 +5,6 @@ import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.exitMenu
import org.mozilla.fenix.helpers.TestHelper.restartApp
import org.mozilla.fenix.ui.robots.browserScreen
@ -28,10 +27,13 @@ class CookieBannerReductionTest {
verifyCookieBannerExists(exists = true)
}.openThreeDotMenu {
}.openSettings {
verifyCookieBannerReductionSummary("Off")
}.openCookieBannerReductionSubMenu {
verifyCookieBannerView(isCookieBannerReductionChecked = false)
clickCookieBannerReductionToggle()
verifyCheckedCookieBannerReductionToggle(isCookieBannerReductionChecked = true)
}.goBack {
verifyCookieBannerReductionSummary("On")
}
exitMenu()
@ -40,7 +42,7 @@ class CookieBannerReductionTest {
verifyCookieBannerExists(exists = false)
}
TestHelper.restartApp(activityTestRule)
restartApp(activityTestRule)
browserScreen {
verifyCookieBannerExists(exists = false)
@ -74,12 +76,17 @@ class CookieBannerReductionTest {
verifyCookieBannerExists(exists = true)
}.openThreeDotMenu {
}.openSettings {
verifyCookieBannerReductionSummary("Off")
}.openCookieBannerReductionSubMenu {
verifyCookieBannerView(isCookieBannerReductionChecked = false)
clickCookieBannerReductionToggle()
verifyCheckedCookieBannerReductionToggle(isCookieBannerReductionChecked = true)
exitMenu()
}.goBack {
verifyCookieBannerReductionSummary("On")
}
exitMenu()
browserScreen {
verifyCookieBannerExists(exists = false)
}

View File

@ -94,6 +94,18 @@ class SettingsRobot {
hasSibling(withText(HTTPSOnlyModeSummary)),
),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
fun verifyCookieBannerReductionSummary(cookieBannerReductionSummary: String) {
scrollToElementByText(getStringResource(R.string.preferences_cookie_banner_reduction))
onView(
allOf(
withText(R.string.preferences_cookie_banner_reduction),
hasSibling(withText(cookieBannerReductionSummary)),
),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}
fun verifyEnhancedTrackingProtectionButton() = assertEnhancedTrackingProtectionButton()
fun verifyLoginsAndPasswordsButton() = assertLoginsAndPasswordsButton()
fun verifyEnhancedTrackingProtectionState(option: String) =

View File

@ -11,7 +11,9 @@ import org.mozilla.fenix.helpers.MatcherHelper.checkedItemWithResId
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
import org.mozilla.fenix.helpers.TestHelper.getStringResource
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.click
/**
* Implementation of Robot Pattern for the settings Cookie Banner Reduction sub menu.
@ -25,7 +27,14 @@ class SettingsSubMenuCookieBannerReductionRobot {
fun verifyCheckedCookieBannerReductionToggle(isCookieBannerReductionChecked: Boolean) =
assertCheckedItemWithResIdExists(checkedCookieBannerOptionToggle(isCookieBannerReductionChecked))
class Transition
class Transition {
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
mDevice.pressBack()
SettingsRobot().interact()
return SettingsRobot.Transition()
}
}
}
private val cookieBannerOptionTitle =