mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
Bug 1826524 - Improve coverage for total cookie protection CFR related UI tests
This commit is contained in:
parent
632b1eedb8
commit
5a8103260a
@ -57,9 +57,13 @@ object MatcherHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun assertItemContainingTextExists(vararg appItems: UiObject) {
|
||||
fun assertItemContainingTextExists(vararg appItems: UiObject, exists: Boolean = true) {
|
||||
for (appItem in appItems) {
|
||||
assertTrue(appItem.waitForExists(waitingTime))
|
||||
if (exists) {
|
||||
assertTrue(appItem.waitForExists(waitingTime))
|
||||
} else {
|
||||
assertFalse(appItem.waitForExists(waitingTime))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.customannotations.SmokeTest
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||
@ -51,7 +52,7 @@ class ContextualHintsTest {
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(genericPage.url) {
|
||||
verifyCookiesProtectionHint()
|
||||
verifyCookiesProtectionHintIsDisplayed(true)
|
||||
// One back press to dismiss the TCP hint
|
||||
mDevice.pressBack()
|
||||
}.goToHomescreen {
|
||||
@ -59,13 +60,29 @@ class ContextualHintsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun cookieProtectionHintTest() {
|
||||
fun openTotalCookieProtectionLearnMoreLinkTest() {
|
||||
val genericPage = getGenericAsset(mockWebServer, 1)
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(genericPage.url) {
|
||||
verifyCookiesProtectionHint()
|
||||
verifyCookiesProtectionHintIsDisplayed(true)
|
||||
clickTotalCookieProtectionLearnMoreLink()
|
||||
verifyUrl("support.mozilla.org/en-US/kb/enhanced-tracking-protection-firefox-android")
|
||||
}
|
||||
}
|
||||
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun dismissTotalCookieProtectionHintTest() {
|
||||
val genericPage = getGenericAsset(mockWebServer, 1)
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(genericPage.url) {
|
||||
verifyCookiesProtectionHintIsDisplayed(true)
|
||||
clickTotalCookieProtectionCloseButton()
|
||||
verifyCookiesProtectionHintIsDisplayed(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,11 @@ import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
|
||||
import org.mozilla.fenix.helpers.Constants.RETRY_COUNT
|
||||
import org.mozilla.fenix.helpers.MatcherHelper
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemContainingTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithDescriptionExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
|
||||
import org.mozilla.fenix.helpers.SessionLoadedIdlingResource
|
||||
@ -762,15 +764,34 @@ class BrowserRobot {
|
||||
|
||||
fun clickSetCookiesButton() = clickPageObject(webPageItemWithResourceId("setCookies"))
|
||||
|
||||
fun verifyCookiesProtectionHint() {
|
||||
val hintMessage =
|
||||
mDevice.findObject(
|
||||
UiSelector()
|
||||
.textContains(getStringResource(R.string.tcp_cfr_message)),
|
||||
fun verifyCookiesProtectionHintIsDisplayed(isDisplayed: Boolean) {
|
||||
if (isDisplayed) {
|
||||
assertItemContainingTextExists(
|
||||
totalCookieProtectionHintMessage,
|
||||
totalCookieProtectionHintLearnMoreLink,
|
||||
)
|
||||
assertTrue(hintMessage.waitForExists(waitingTime))
|
||||
assertItemWithDescriptionExists(
|
||||
totalCookieProtectionHintCloseButton,
|
||||
)
|
||||
} else {
|
||||
assertItemContainingTextExists(
|
||||
totalCookieProtectionHintMessage,
|
||||
totalCookieProtectionHintLearnMoreLink,
|
||||
exists = isDisplayed,
|
||||
)
|
||||
assertItemWithDescriptionExists(
|
||||
totalCookieProtectionHintCloseButton,
|
||||
exists = isDisplayed,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun clickTotalCookieProtectionLearnMoreLink() =
|
||||
totalCookieProtectionHintLearnMoreLink.clickAndWaitForNewWindow(waitingTime)
|
||||
|
||||
fun clickTotalCookieProtectionCloseButton() =
|
||||
totalCookieProtectionHintCloseButton.click()
|
||||
|
||||
fun clickForm(formType: String) {
|
||||
when (formType) {
|
||||
"Calendar Form" -> {
|
||||
@ -1424,3 +1445,9 @@ private val currentDay = currentDate.dayOfMonth
|
||||
private val currentMonth = currentDate.month
|
||||
private val currentYear = currentDate.year
|
||||
private val cookieBanner = itemWithResId("CybotCookiebotDialog")
|
||||
private val totalCookieProtectionHintMessage =
|
||||
itemContainingText(getStringResource(R.string.tcp_cfr_message))
|
||||
private val totalCookieProtectionHintLearnMoreLink =
|
||||
itemContainingText(getStringResource(R.string.tcp_cfr_learn_more))
|
||||
private val totalCookieProtectionHintCloseButton =
|
||||
itemWithDescription(getStringResource(R.string.mozac_cfr_dismiss_button_content_description))
|
||||
|
Loading…
Reference in New Issue
Block a user