Bug 1881028 - Add logs to SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot

fenix/125.0
AndiAJ 3 months ago committed by mergify[bot]
parent 1daa2ba0df
commit f9ac7cfc7d

@ -4,19 +4,19 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import android.util.Log
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.hasSibling import androidx.test.espresso.matcher.ViewMatchers.hasSibling
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
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.withText import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.UiSelector import androidx.test.uiautomator.UiSelector
import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.allOf
import org.hamcrest.CoreMatchers.containsString import org.hamcrest.CoreMatchers.containsString
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants.TAG
import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists import org.mozilla.fenix.helpers.MatcherHelper.assertUIObjectExists
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
@ -30,37 +30,51 @@ import org.mozilla.fenix.helpers.click
*/ */
class SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot { class SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot {
fun verifyNavigationToolBarHeader() = assertNavigationToolBarHeader()
fun verifyTPExceptionsDefaultView() { fun verifyTPExceptionsDefaultView() {
assertUIObjectExists( assertUIObjectExists(
itemWithText("Exceptions let you disable tracking protection for selected sites."), itemWithText("Exceptions let you disable tracking protection for selected sites."),
) )
Log.i(TAG, "verifyTPExceptionsDefaultView: Trying to verify that the ETP exceptions learn more link is displayed")
learnMoreLink().check(matches(isDisplayed())) learnMoreLink().check(matches(isDisplayed()))
Log.i(TAG, "verifyTPExceptionsDefaultView: Verified that the ETP exceptions learn more link is displayed")
} }
fun openExceptionsLearnMoreLink() = learnMoreLink().click() fun openExceptionsLearnMoreLink() {
Log.i(TAG, "openExceptionsLearnMoreLink: Trying to click the ETP exceptions learn more link")
learnMoreLink().click()
Log.i(TAG, "openExceptionsLearnMoreLink: Clicked the ETP exceptions learn more link")
}
fun removeOneSiteException(siteHost: String) { fun removeOneSiteException(siteHost: String) {
Log.i(TAG, "removeOneSiteException: Waiting for $waitingTime ms for exceptions list to exist to exist")
exceptionsList().waitForExists(waitingTime) exceptionsList().waitForExists(waitingTime)
Log.i(TAG, "removeOneSiteException: Waited for $waitingTime ms for exceptions list to exist to exist")
Log.i(TAG, "removeOneSiteException: Trying to click the delete site exception button")
removeSiteExceptionButton(siteHost).click() removeSiteExceptionButton(siteHost).click()
Log.i(TAG, "removeOneSiteException: Clicked the delete site exception button")
} }
fun verifySiteExceptionExists(siteUrl: String, shouldExist: Boolean) { fun verifySiteExceptionExists(siteUrl: String, shouldExist: Boolean) {
Log.i(TAG, "verifySiteExceptionExists: Waiting for $waitingTime ms for exceptions list to exist to exist")
exceptionsList().waitForExists(waitingTime) exceptionsList().waitForExists(waitingTime)
Log.i(TAG, "verifySiteExceptionExists: Waited for $waitingTime ms for exceptions list to exist to exist")
assertUIObjectExists(itemContainingText(siteUrl), exists = shouldExist) assertUIObjectExists(itemContainingText(siteUrl), exists = shouldExist)
} }
class Transition { class Transition {
fun goBack(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition { fun goBack(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): SettingsSubMenuEnhancedTrackingProtectionRobot.Transition {
Log.i(TAG, "goBack: Trying to click the navigate up toolbar button")
goBackButton().click() goBackButton().click()
Log.i(TAG, "goBack: Clicked the navigate up toolbar button")
SettingsSubMenuEnhancedTrackingProtectionRobot().interact() SettingsSubMenuEnhancedTrackingProtectionRobot().interact()
return SettingsSubMenuEnhancedTrackingProtectionRobot.Transition() return SettingsSubMenuEnhancedTrackingProtectionRobot.Transition()
} }
fun disableExceptions(interact: SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.() -> Unit): Transition { fun disableExceptions(interact: SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.() -> Unit): Transition {
Log.i(TAG, "disableExceptions: Trying to click the \"Turn on for all sites\" button")
disableAllExceptionsButton().click() disableAllExceptionsButton().click()
Log.i(TAG, "disableExceptions: Clicked the \"Turn on for all sites\" button")
SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot().interact() SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot().interact()
return Transition() return Transition()
@ -71,15 +85,9 @@ class SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot {
private fun goBackButton() = private fun goBackButton() =
onView(allOf(withContentDescription("Navigate up"))) onView(allOf(withContentDescription("Navigate up")))
private fun assertNavigationToolBarHeader() {
onView(withText(R.string.preferences_tracking_protection_exceptions))
.check((matches(withEffectiveVisibility(Visibility.VISIBLE))))
}
private fun learnMoreLink() = onView(withText("Learn more")) private fun learnMoreLink() = onView(withText("Learn more"))
private fun disableAllExceptionsButton() = private fun disableAllExceptionsButton() = onView(withId(R.id.removeAllExceptions))
onView(withId(R.id.removeAllExceptions)).click()
private fun removeSiteExceptionButton(siteHost: String) = private fun removeSiteExceptionButton(siteHost: String) =
onView( onView(

Loading…
Cancel
Save