Bug 1883331 - Convert private variables to functions so they don't get initialised

fenix/125.0
AndiAJ 3 months ago committed by mergify[bot]
parent 7805bb5580
commit 5473cc0881

@ -23,16 +23,16 @@ class SitePermissionsRobot {
fun verifyMicrophonePermissionPrompt(url: String) { fun verifyMicrophonePermissionPrompt(url: String) {
try { try {
assertUIObjectExists(itemWithText("Allow $url to use your microphone?")) assertUIObjectExists(itemWithText("Allow $url to use your microphone?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} catch (e: AssertionError) { } catch (e: AssertionError) {
browserScreen { browserScreen {
}.openThreeDotMenu { }.openThreeDotMenu {
}.refreshPage { }.refreshPage {
}.clickStartMicrophoneButton { }.clickStartMicrophoneButton {
assertUIObjectExists(itemWithText("Allow $url to use your microphone?")) assertUIObjectExists(itemWithText("Allow $url to use your microphone?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} }
} }
} }
@ -40,39 +40,39 @@ class SitePermissionsRobot {
fun verifyCameraPermissionPrompt(url: String) { fun verifyCameraPermissionPrompt(url: String) {
try { try {
assertUIObjectExists(itemWithText("Allow $url to use your camera?")) assertUIObjectExists(itemWithText("Allow $url to use your camera?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} catch (e: AssertionError) { } catch (e: AssertionError) {
browserScreen { browserScreen {
}.openThreeDotMenu { }.openThreeDotMenu {
}.refreshPage { }.refreshPage {
}.clickStartCameraButton { }.clickStartCameraButton {
assertUIObjectExists(itemWithText("Allow $url to use your camera?")) assertUIObjectExists(itemWithText("Allow $url to use your camera?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} }
} }
} }
fun verifyAudioVideoPermissionPrompt(url: String) { fun verifyAudioVideoPermissionPrompt(url: String) {
assertUIObjectExists(itemWithText("Allow $url to use your camera and microphone?")) assertUIObjectExists(itemWithText("Allow $url to use your camera and microphone?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} }
fun verifyLocationPermissionPrompt(url: String) { fun verifyLocationPermissionPrompt(url: String) {
try { try {
assertUIObjectExists(itemWithText("Allow $url to use your location?")) assertUIObjectExists(itemWithText("Allow $url to use your location?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} catch (e: AssertionError) { } catch (e: AssertionError) {
browserScreen { browserScreen {
}.openThreeDotMenu { }.openThreeDotMenu {
}.refreshPage { }.refreshPage {
}.clickGetLocationButton { }.clickGetLocationButton {
assertUIObjectExists(itemWithText("Allow $url to use your location?")) assertUIObjectExists(itemWithText("Allow $url to use your location?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} }
} }
} }
@ -81,16 +81,16 @@ class SitePermissionsRobot {
if (!blocked) { if (!blocked) {
try { try {
assertUIObjectExists(itemWithText("Allow $url to send notifications?")) assertUIObjectExists(itemWithText("Allow $url to send notifications?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Never") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Never")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Always") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Always")
} catch (e: AssertionError) { } catch (e: AssertionError) {
browserScreen { browserScreen {
}.openThreeDotMenu { }.openThreeDotMenu {
}.refreshPage { }.refreshPage {
}.clickOpenNotificationButton { }.clickOpenNotificationButton {
assertUIObjectExists(itemWithText("Allow $url to send notifications?")) assertUIObjectExists(itemWithText("Allow $url to send notifications?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Never") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Never")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Always") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Always")
} }
} }
} else { } else {
@ -103,16 +103,16 @@ class SitePermissionsRobot {
fun verifyPersistentStoragePermissionPrompt(url: String) { fun verifyPersistentStoragePermissionPrompt(url: String) {
try { try {
assertUIObjectExists(itemWithText("Allow $url to store data in persistent storage?")) assertUIObjectExists(itemWithText("Allow $url to store data in persistent storage?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} catch (e: AssertionError) { } catch (e: AssertionError) {
browserScreen { browserScreen {
}.openThreeDotMenu { }.openThreeDotMenu {
}.refreshPage { }.refreshPage {
}.clickRequestPersistentStorageAccessButton { }.clickRequestPersistentStorageAccessButton {
assertUIObjectExists(itemWithText("Allow $url to store data in persistent storage?")) assertUIObjectExists(itemWithText("Allow $url to store data in persistent storage?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} }
} }
} }
@ -120,16 +120,16 @@ class SitePermissionsRobot {
fun verifyDRMContentPermissionPrompt(url: String) { fun verifyDRMContentPermissionPrompt(url: String) {
try { try {
assertUIObjectExists(itemWithText("Allow $url to play DRM-controlled content?")) assertUIObjectExists(itemWithText("Allow $url to play DRM-controlled content?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} catch (e: AssertionError) { } catch (e: AssertionError) {
browserScreen { browserScreen {
}.openThreeDotMenu { }.openThreeDotMenu {
}.refreshPage { }.refreshPage {
}.clickRequestDRMControlledContentAccessButton { }.clickRequestDRMControlledContentAccessButton {
assertUIObjectExists(itemWithText("Allow $url to play DRM-controlled content?")) assertUIObjectExists(itemWithText("Allow $url to play DRM-controlled content?"))
assertItemTextEquals(denyPagePermissionButton, expectedText = "Dont allow") assertItemTextEquals(denyPagePermissionButton(), expectedText = "Dont allow")
assertItemTextEquals(allowPagePermissionButton, expectedText = "Allow") assertItemTextEquals(allowPagePermissionButton(), expectedText = "Allow")
} }
} }
} }
@ -155,18 +155,18 @@ class SitePermissionsRobot {
class Transition { class Transition {
fun clickPagePermissionButton(allow: Boolean, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickPagePermissionButton(allow: Boolean, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
if (allow) { if (allow) {
allowPagePermissionButton.waitForExists(waitingTime) allowPagePermissionButton().waitForExists(waitingTime)
allowPagePermissionButton.click() allowPagePermissionButton().click()
// sometimes flaky, the prompt is not dismissed, retrying // sometimes flaky, the prompt is not dismissed, retrying
if (!allowPagePermissionButton.waitUntilGone(waitingTime)) { if (!allowPagePermissionButton().waitUntilGone(waitingTime)) {
allowPagePermissionButton.click() allowPagePermissionButton().click()
} }
} else { } else {
denyPagePermissionButton.waitForExists(waitingTime) denyPagePermissionButton().waitForExists(waitingTime)
denyPagePermissionButton.click() denyPagePermissionButton().click()
// sometimes flaky, the prompt is not dismissed, retrying // sometimes flaky, the prompt is not dismissed, retrying
if (!denyPagePermissionButton.waitUntilGone(waitingTime)) { if (!denyPagePermissionButton().waitUntilGone(waitingTime)) {
denyPagePermissionButton.click() denyPagePermissionButton().click()
} }
} }
@ -177,8 +177,8 @@ class SitePermissionsRobot {
} }
// Page permission prompts buttons // Page permission prompts buttons
private val allowPagePermissionButton = private fun allowPagePermissionButton() =
mDevice.findObject(UiSelector().resourceId("$packageName:id/allow_button")) mDevice.findObject(UiSelector().resourceId("$packageName:id/allow_button"))
private val denyPagePermissionButton = private fun denyPagePermissionButton() =
mDevice.findObject(UiSelector().resourceId("$packageName:id/deny_button")) mDevice.findObject(UiSelector().resourceId("$packageName:id/deny_button"))

Loading…
Cancel
Save