From 09481688f01c44122a72e5f197e59b2fb8eeb6b8 Mon Sep 17 00:00:00 2001 From: Oana Horvath Date: Thu, 17 Sep 2020 15:15:39 +0300 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/13829: Added idling resources to the addon details view" --- .../mozilla/fenix/ui/SettingsAddonsTest.kt | 16 ++++++++++--- ...MenuAddonsManagerAddonDetailedMenuRobot.kt | 23 +------------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAddonsTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAddonsTest.kt index 036273f241..12b74d0384 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAddonsTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAddonsTest.kt @@ -1,5 +1,6 @@ package org.mozilla.fenix.ui +import android.view.View import androidx.test.espresso.IdlingRegistry import org.mozilla.fenix.helpers.TestAssetHelper @@ -11,12 +12,12 @@ import okhttp3.mockwebserver.MockWebServer import org.junit.Rule import org.junit.Before import org.junit.After -import org.junit.Ignore import org.junit.Test import org.mozilla.fenix.R import org.mozilla.fenix.helpers.AndroidAssetDispatcher import org.mozilla.fenix.helpers.HomeActivityTestRule import org.mozilla.fenix.helpers.RecyclerViewIdlingResource +import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource import org.mozilla.fenix.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.navigationToolbar @@ -30,6 +31,7 @@ class SettingsAddonsTest { private lateinit var mockWebServer: MockWebServer private var addonsListIdlingResource: RecyclerViewIdlingResource? = null + private var addonContainerIdlingResource: ViewVisibilityIdlingResource? = null @get:Rule val activityTestRule = HomeActivityTestRule() @@ -49,6 +51,10 @@ class SettingsAddonsTest { if (addonsListIdlingResource != null) { IdlingRegistry.getInstance().unregister(addonsListIdlingResource!!) } + + if (addonContainerIdlingResource != null) { + IdlingRegistry.getInstance().unregister(addonContainerIdlingResource!!) + } } // Walks through settings add-ons menu to ensure all items are present @@ -89,7 +95,6 @@ class SettingsAddonsTest { } } - @Ignore("Failing intermittently on Firebase: https://github.com/mozilla-mobile/fenix/issues/13829") // Opens the addons settings menu, installs an addon, then uninstalls @Test fun verifyAddonsCanBeUninstalled() { @@ -107,8 +112,13 @@ class SettingsAddonsTest { clickInstallAddon(addonName) acceptInstallAddon() verifyDownloadAddonPrompt(addonName, activityTestRule) + IdlingRegistry.getInstance().unregister(addonsListIdlingResource!!) }.openDetailedMenuForAddon(addonName) { - verifyCurrentAddonMenu() + addonContainerIdlingResource = ViewVisibilityIdlingResource( + activityTestRule.activity.findViewById(R.id.addon_container), + View.VISIBLE + ) + IdlingRegistry.getInstance().register(addonContainerIdlingResource!!) }.removeAddon { } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerAddonDetailedMenuRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerAddonDetailedMenuRobot.kt index 499861c30e..b228c42b70 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerAddonDetailedMenuRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuAddonsManagerAddonDetailedMenuRobot.kt @@ -16,8 +16,6 @@ import org.mozilla.fenix.helpers.click class SettingsSubMenuAddonsManagerAddonDetailedMenuRobot { - fun verifyCurrentAddonMenu() = assertAddonMenuItems() - class Transition { fun goBack(interact: SettingsSubMenuAddonsManagerRobot.() -> Unit): SettingsSubMenuAddonsManagerRobot.Transition { fun goBackButton() = onView(allOf(withContentDescription("Navigate up"))) @@ -28,33 +26,14 @@ class SettingsSubMenuAddonsManagerAddonDetailedMenuRobot { } fun removeAddon(interact: SettingsSubMenuAddonsManagerRobot.() -> Unit): SettingsSubMenuAddonsManagerRobot.Transition { + removeAddonButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) removeAddonButton().click() SettingsSubMenuAddonsManagerRobot().interact() return SettingsSubMenuAddonsManagerRobot.Transition() } } - - private fun assertAddonMenuItems() { - enableSwitchButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - settingsButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - detailsButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - permissionsButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - removeAddonButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - } } -private fun enableSwitchButton() = - onView(withId(R.id.enable_switch)) - -private fun settingsButton() = - onView(withId(R.id.settings)) - -private fun detailsButton() = - onView(withId(R.id.details)) - -private fun permissionsButton() = - onView(withId(R.id.permissions)) - private fun removeAddonButton() = onView(withId(R.id.remove_add_on))