mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
Bug 1877939 - Remove redundant assertion functions from EnhancedTrackingProtectionRobot
This commit is contained in:
parent
dd0e9e1918
commit
30b306f1d9
@ -38,10 +38,29 @@ import org.mozilla.fenix.helpers.isChecked
|
||||
* Implementation of Robot Pattern for Enhanced Tracking Protection UI.
|
||||
*/
|
||||
class EnhancedTrackingProtectionRobot {
|
||||
fun verifyEnhancedTrackingProtectionSheetStatus(status: String, state: Boolean) =
|
||||
assertEnhancedTrackingProtectionSheetStatus(status, state)
|
||||
fun verifyEnhancedTrackingProtectionSheetStatus(status: String, state: Boolean) {
|
||||
mDevice.waitNotNull(Until.findObjects(By.text("Protections are $status for this site")))
|
||||
onView(ViewMatchers.withResourceName("switch_widget")).check(
|
||||
matches(
|
||||
isChecked(
|
||||
state,
|
||||
),
|
||||
),
|
||||
)
|
||||
Log.i(TAG, "verifyEnhancedTrackingProtectionSheetStatus: Verified ETP toggle is checked: $state")
|
||||
}
|
||||
|
||||
fun verifyETPSwitchVisibility(visible: Boolean) = assertETPSwitchVisibility(visible)
|
||||
fun verifyETPSwitchVisibility(visible: Boolean) {
|
||||
if (visible) {
|
||||
enhancedTrackingProtectionSwitch()
|
||||
.check(matches(isDisplayed()))
|
||||
Log.i(TAG, "verifyETPSwitchVisibility: Verified ETP toggle is displayed")
|
||||
} else {
|
||||
enhancedTrackingProtectionSwitch()
|
||||
.check(matches(not(isDisplayed())))
|
||||
Log.i(TAG, "verifyETPSwitchVisibility: Verified ETP toggle is not displayed")
|
||||
}
|
||||
}
|
||||
|
||||
fun verifyCrossSiteCookiesBlocked(isBlocked: Boolean) {
|
||||
assertUIObjectExists(itemWithResId("$packageName:id/cross_site_tracking"))
|
||||
@ -184,7 +203,10 @@ class EnhancedTrackingProtectionRobot {
|
||||
pageSecurityIndicator().waitForExists(waitingTime)
|
||||
pageSecurityIndicator().click()
|
||||
Log.i(TAG, "openEnhancedTrackingProtectionSheet: Clicked site security button")
|
||||
assertSecuritySheetIsCompletelyDisplayed()
|
||||
Log.i(TAG, "openEnhancedTrackingProtectionSheet: Looking for quick actions sheet")
|
||||
mDevice.findObject(UiSelector().description(getStringResource(R.string.quick_settings_sheet)))
|
||||
.waitForExists(waitingTime)
|
||||
assertUIObjectExists(itemWithResId("$packageName:id/quick_action_sheet"))
|
||||
|
||||
EnhancedTrackingProtectionRobot().interact()
|
||||
return Transition()
|
||||
@ -236,30 +258,6 @@ fun enhancedTrackingProtection(interact: EnhancedTrackingProtectionRobot.() -> U
|
||||
return EnhancedTrackingProtectionRobot.Transition()
|
||||
}
|
||||
|
||||
private fun assertETPSwitchVisibility(visible: Boolean) {
|
||||
if (visible) {
|
||||
enhancedTrackingProtectionSwitch()
|
||||
.check(matches(isDisplayed()))
|
||||
Log.i(TAG, "assertETPSwitchVisibility: Verified ETP toggle is displayed")
|
||||
} else {
|
||||
enhancedTrackingProtectionSwitch()
|
||||
.check(matches(not(isDisplayed())))
|
||||
Log.i(TAG, "assertETPSwitchVisibility: Verified ETP toggle is not displayed")
|
||||
}
|
||||
}
|
||||
|
||||
private fun assertEnhancedTrackingProtectionSheetStatus(status: String, state: Boolean) {
|
||||
mDevice.waitNotNull(Until.findObjects(By.text("Protections are $status for this site")))
|
||||
onView(ViewMatchers.withResourceName("switch_widget")).check(
|
||||
matches(
|
||||
isChecked(
|
||||
state,
|
||||
),
|
||||
),
|
||||
)
|
||||
Log.i(TAG, "assertEnhancedTrackingProtectionSheetStatus: Verified ETP toggle is checked: $state")
|
||||
}
|
||||
|
||||
private fun pageSecurityIndicator() =
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_security_indicator"))
|
||||
|
||||
@ -315,10 +313,3 @@ private fun fingerprintersBlockListButton() =
|
||||
withText("Fingerprinters"),
|
||||
),
|
||||
)
|
||||
|
||||
private fun assertSecuritySheetIsCompletelyDisplayed() {
|
||||
Log.i(TAG, "assertSecuritySheetIsCompletelyDisplayed: Looking for quick actions sheet")
|
||||
mDevice.findObject(UiSelector().description(getStringResource(R.string.quick_settings_sheet)))
|
||||
.waitForExists(waitingTime)
|
||||
assertUIObjectExists(itemWithResId("$packageName:id/quick_action_sheet"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user