From 7f137486e68da940cbd57c87cd412b2f11e5142d Mon Sep 17 00:00:00 2001 From: "oana.horvath" Date: Wed, 21 Jun 2023 18:02:26 +0300 Subject: [PATCH] Bug 1808879 - Fix UI test for the addons install prompt --- .../ui/robots/SettingsSubMenuAddonsManagerRobot.kt | 38 +++++++++------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt index c82834595f18..0c0cf2ebc3bd 100644 --- a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt +++ b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerRobot.kt @@ -11,12 +11,14 @@ import android.widget.RelativeLayout import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.matcher.RootMatchers.isDialog import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.hasDescendant import androidx.test.espresso.matcher.ViewMatchers.hasSibling import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withId @@ -49,7 +51,20 @@ import org.mozilla.fenix.helpers.ext.waitNotNull */ class SettingsSubMenuAddonsManagerRobot { - fun verifyAddonPermissionPrompt(addonName: String) = assertAddonPermissionPrompt(addonName) + fun verifyAddonPermissionPrompt(addonName: String) { + mDevice.waitNotNull(Until.findObject(By.text("Add $addonName?")), waitingTime) + + onView( + allOf( + withText("Add $addonName?"), + hasSibling(withText(containsString("It requires your permission to:"))), + hasSibling(withText("Add")), + hasSibling(withText("Cancel")), + ), + ) + .inRoot(isDialog()) + .check(matches(isDisplayed())) + } fun clickInstallAddon(addonName: String) { mDevice.waitNotNull( @@ -185,27 +200,6 @@ class SettingsSubMenuAddonsManagerRobot { .check(matches(not(isCompletelyDisplayed()))) } - private fun assertAddonPermissionPrompt(addonName: String) { - mDevice.waitNotNull(Until.findObject(By.text("Add $addonName?")), waitingTime) - - onView(allOf(withId(R.id.title), withText("Add $addonName?"))) - .check(matches(isCompletelyDisplayed())) - - onView( - allOf( - withId(R.id.permissions), - withText(containsString("It requires your permission to:")), - ), - ) - .check(matches(isCompletelyDisplayed())) - - onView(allOf(withId(R.id.allow_button), withText("Add"))) - .check(matches(isCompletelyDisplayed())) - - onView(allOf(withId(R.id.deny_button), withText("Cancel"))) - .check(matches(isCompletelyDisplayed())) - } - private fun assertAddonIsInstalled(addonName: String) { onView( allOf( -- 2.11.4.GIT