Bug 1880620 - Add logs to SettingsSubMenuAddonsManagerRobot

fenix/124.1.0
AndiAJ 3 months ago committed by mergify[bot]
parent 9012bd1624
commit a494c9808d

@ -55,12 +55,15 @@ class SettingsSubMenuAddonsManagerRobot {
fun verifyAddonsListIsDisplayed(shouldBeDisplayed: Boolean) =
assertUIObjectExists(addonsList(), exists = shouldBeDisplayed)
fun verifyAddonDownloadOverlay() =
fun verifyAddonDownloadOverlay() {
Log.i(TAG, "verifyAddonDownloadOverlay: Trying to verify that the \"Downloading and verifying add-on\" prompt is displayed")
onView(withText(R.string.mozac_add_on_install_progress_caption)).check(matches(isDisplayed()))
Log.i(TAG, "verifyAddonDownloadOverlay: Verified that the \"Downloading and verifying add-on\" prompt is displayed")
}
fun verifyAddonPermissionPrompt(addonName: String) {
mDevice.waitNotNull(Until.findObject(By.text("Add $addonName?")), waitingTime)
Log.i(TAG, "verifyAddonPermissionPrompt: Trying to verify that the add-ons permission prompt items are displayed")
onView(
allOf(
withText("Add $addonName?"),
@ -71,11 +74,14 @@ class SettingsSubMenuAddonsManagerRobot {
)
.inRoot(isDialog())
.check(matches(isDisplayed()))
Log.i(TAG, "verifyAddonPermissionPrompt: Verified that the add-ons permission prompt items are displayed")
}
fun clickInstallAddon(addonName: String) {
Log.i(TAG, "clickInstallAddon: Looking for $addonName install button")
Log.i(TAG, "clickInstallAddon: Waiting for $waitingTime ms for add-ons list to exist")
addonsList().waitForExists(waitingTime)
Log.i(TAG, "clickInstallAddon: Waited for $waitingTime ms for add-ons list to exist")
Log.i(TAG, "clickInstallAddon: Trying to scroll into view the install $addonName button")
addonsList().scrollIntoView(
mDevice.findObject(
UiSelector()
@ -83,6 +89,8 @@ class SettingsSubMenuAddonsManagerRobot {
.childSelector(UiSelector().text(addonName)),
),
)
Log.i(TAG, "clickInstallAddon: Scrolled into view the install $addonName button")
Log.i(TAG, "clickInstallAddon: Trying to ensure the full visibility of the the install $addonName button")
addonsList().ensureFullyVisible(
mDevice.findObject(
UiSelector()
@ -90,22 +98,24 @@ class SettingsSubMenuAddonsManagerRobot {
.childSelector(UiSelector().text(addonName)),
),
)
Log.i(TAG, "clickInstallAddon: Found $addonName install button")
Log.i(TAG, "clickInstallAddon: Ensured the full visibility of the the install $addonName button")
Log.i(TAG, "clickInstallAddon: Trying to click the install $addonName button")
installButtonForAddon(addonName).click()
Log.i(TAG, "clickInstallAddon: Clicked Install $addonName button")
Log.i(TAG, "clickInstallAddon: Clicked the install $addonName button")
}
fun verifyAddonInstallCompleted(addonName: String, activityTestRule: HomeActivityIntentTestRule) {
for (i in 1..RETRY_COUNT) {
Log.i(TAG, "verifyAddonInstallCompleted: Started try #$i")
try {
assertUIObjectExists(itemWithText("OK"), waitingTime = waitingTimeLong)
break
} catch (e: AssertionError) {
Log.i(TAG, "verifyAddonInstallCompleted: AssertionError caught, executing fallback methods")
if (i == RETRY_COUNT) {
throw e
} else {
Log.i(TAG, "verifyAddonInstallCompleted: $addonName failed to install on try #$i")
restartApp(activityTestRule)
homeScreen {
}.openThreeDotMenu {
@ -121,6 +131,7 @@ class SettingsSubMenuAddonsManagerRobot {
}
fun verifyAddonInstallCompletedPrompt(addonName: String) {
Log.i(TAG, "verifyAddonInstallCompletedPrompt: Trying to verify that completed add-on install prompt items are visible")
onView(
allOf(
withText("OK"),
@ -131,14 +142,18 @@ class SettingsSubMenuAddonsManagerRobot {
),
)
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyAddonInstallCompletedPrompt: Verified that completed add-on install prompt items are visible")
}
fun closeAddonInstallCompletePrompt() {
Log.i(TAG, "closeAddonInstallCompletePrompt: Trying to click the \"OK\" button from the completed add-on install prompt")
onView(withText("OK")).click()
Log.i(TAG, "closeAddonInstallCompletePrompt: Clicked the \"OK\" button from the completed add-on install prompt")
}
fun verifyAddonIsInstalled(addonName: String) {
scrollToElementByText(addonName)
Log.i(TAG, "verifyAddonIsInstalled: Trying to verify that the $addonName add-on was installed")
onView(
allOf(
withId(R.id.add_button),
@ -146,19 +161,24 @@ class SettingsSubMenuAddonsManagerRobot {
hasSibling(hasDescendant(withText(addonName))),
),
).check(matches(withEffectiveVisibility(Visibility.INVISIBLE)))
Log.i(TAG, "verifyAddonIsInstalled: Verified that the $addonName add-on was installed")
}
fun verifyEnabledTitleDisplayed() {
Log.i(TAG, "verifyEnabledTitleDisplayed: Trying to verify that the \"Enabled\" heading is displayed")
onView(withText("Enabled"))
.check(matches(isCompletelyDisplayed()))
Log.i(TAG, "verifyEnabledTitleDisplayed: Verified that the \"Enabled\" heading is displayed")
}
fun cancelInstallAddon() = cancelInstall()
fun acceptPermissionToInstallAddon() = allowPermissionToInstall()
fun verifyAddonsItems() {
Log.i(TAG, "verifyAddonsItems: Trying to verify that the \"Recommended\" heading is visible")
onView(allOf(withId(R.id.title), withText("Recommended")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyAddonsItems: Verified that the \"Recommended\" heading is visible")
Log.i(TAG, "verifyAddonsItems: Trying to verify that all uBlock Origin items are completely displayed")
onView(
allOf(
isAssignableFrom(RelativeLayout::class.java),
@ -176,11 +196,12 @@ class SettingsSubMenuAddonsManagerRobot {
hasDescendant(withId(R.id.add_button)),
),
).check(matches(isCompletelyDisplayed()))
Log.i(TAG, "verifyAddonsItems: Verified that all uBlock Origin items are completely displayed")
}
fun verifyAddonCanBeInstalled(addonName: String) {
scrollToElementByText(addonName)
mDevice.waitNotNull(Until.findObject(By.text(addonName)), waitingTime)
Log.i(TAG, "verifyAddonCanBeInstalled: Trying to verify that the install $addonName button is visible")
onView(
allOf(
withId(R.id.add_button),
@ -194,11 +215,14 @@ class SettingsSubMenuAddonsManagerRobot {
),
),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "verifyAddonCanBeInstalled: Verified that the install $addonName button is visible")
}
fun selectAllowInPrivateBrowsing() {
assertUIObjectExists(itemWithText("Allow in private browsing"), waitingTime = waitingTimeLong)
Log.i(TAG, "selectAllowInPrivateBrowsing: Trying to click the \"Allow in private browsing\" check box")
onView(withId(R.id.allow_in_private_browsing)).click()
Log.i(TAG, "selectAllowInPrivateBrowsing: Clicked the \"Allow in private browsing\" check box")
}
fun installAddon(addonName: String, activityTestRule: HomeActivityIntentTestRule) {
@ -214,8 +238,9 @@ class SettingsSubMenuAddonsManagerRobot {
class Transition {
fun goBack(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
fun goBackButton() = onView(allOf(withContentDescription("Navigate up")))
goBackButton().click()
Log.i(TAG, "goBack: Trying to click navigate up toolbar button")
onView(allOf(withContentDescription("Navigate up"))).click()
Log.i(TAG, "goBack: Clicked the navigate up toolbar button")
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
@ -226,19 +251,12 @@ class SettingsSubMenuAddonsManagerRobot {
interact: SettingsSubMenuAddonsManagerAddonDetailedMenuRobot.() -> Unit,
): SettingsSubMenuAddonsManagerAddonDetailedMenuRobot.Transition {
scrollToElementByText(addonName)
onView(
allOf(
withId(R.id.add_on_item),
hasDescendant(
allOf(
withId(R.id.add_on_name),
withText(addonName),
),
),
),
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
.perform(click())
Log.i(TAG, "openDetailedMenuForAddon: Trying to verify that the $addonName add-on is visible")
addonItem(addonName).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Log.i(TAG, "openDetailedMenuForAddon: Verified that the $addonName add-on is visible")
Log.i(TAG, "openDetailedMenuForAddon: Trying to click the $addonName add-on")
addonItem(addonName).perform(click())
Log.i(TAG, "openDetailedMenuForAddon: Clicked the $addonName add-on")
SettingsSubMenuAddonsManagerAddonDetailedMenuRobot().interact()
return SettingsSubMenuAddonsManagerAddonDetailedMenuRobot.Transition()
@ -255,17 +273,22 @@ class SettingsSubMenuAddonsManagerRobot {
)
private fun cancelInstall() {
onView(allOf(withId(R.id.deny_button), withText("Cancel")))
.check(matches(isCompletelyDisplayed()))
.perform(click())
Log.i(TAG, "cancelInstall: Trying to verify that the \"Cancel\" button is completely displayed")
onView(allOf(withId(R.id.deny_button), withText("Cancel"))).check(matches(isCompletelyDisplayed()))
Log.i(TAG, "cancelInstall: Verified that the \"Cancel\" button is completely displayed")
Log.i(TAG, "cancelInstall: Trying to click the \"Cancel\" button")
onView(allOf(withId(R.id.deny_button), withText("Cancel"))).perform(click())
Log.i(TAG, "cancelInstall: Clicked the \"Cancel\" button")
}
private fun allowPermissionToInstall() {
mDevice.waitNotNull(Until.findObject(By.text("Add")), waitingTime)
onView(allOf(withId(R.id.allow_button), withText("Add")))
.check(matches(isCompletelyDisplayed()))
.perform(click())
Log.i(TAG, "allowPermissionToInstall: Trying to verify that the \"Add\" button is completely displayed")
onView(allOf(withId(R.id.allow_button), withText("Add"))).check(matches(isCompletelyDisplayed()))
Log.i(TAG, "allowPermissionToInstall: Verified that the \"Add\" button is completely displayed")
Log.i(TAG, "allowPermissionToInstall: Trying to click the \"Add\" button")
onView(allOf(withId(R.id.allow_button), withText("Add"))).perform(click())
Log.i(TAG, "allowPermissionToInstall: Clicked the \"Add\" button")
}
}
@ -274,5 +297,18 @@ fun addonsMenu(interact: SettingsSubMenuAddonsManagerRobot.() -> Unit): Settings
return SettingsSubMenuAddonsManagerRobot.Transition()
}
private fun addonItem(addonName: String) =
onView(
allOf(
withId(R.id.add_on_item),
hasDescendant(
allOf(
withId(R.id.add_on_name),
withText(addonName),
),
),
),
)
private fun addonsList() =
UiScrollable(UiSelector().resourceId("$packageName:id/add_ons_list")).setAsVerticalList()

Loading…
Cancel
Save