From 4a00131fa15bdf8d1144e25642a318377b2fa797 Mon Sep 17 00:00:00 2001 From: Oana Horvath Date: Mon, 31 Aug 2020 16:31:29 +0300 Subject: [PATCH] Closes #13218: adds IdlingResources for the Addons list --- .../org/mozilla/fenix/ui/SettingsAddonsTest.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 7dd20c9442..4c6f93a8a7 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 androidx.test.espresso.IdlingRegistry import org.mozilla.fenix.helpers.TestAssetHelper /* This Source Code Form is subject to the terms of the Mozilla Public @@ -11,8 +12,10 @@ import org.junit.Rule import org.junit.Before import org.junit.After 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.ui.robots.homeScreen import org.mozilla.fenix.ui.robots.navigationToolbar @@ -25,6 +28,7 @@ class SettingsAddonsTest { /* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping. private lateinit var mockWebServer: MockWebServer + private var addonsListIdlingResource: RecyclerViewIdlingResource? = null @get:Rule val activityTestRule = HomeActivityTestRule() @@ -40,6 +44,10 @@ class SettingsAddonsTest { @After fun tearDown() { mockWebServer.shutdown() + + if (addonsListIdlingResource != null) { + IdlingRegistry.getInstance().unregister(addonsListIdlingResource!!) + } } // Walks through settings add-ons menu to ensure all items are present @@ -51,6 +59,9 @@ class SettingsAddonsTest { verifyAdvancedHeading() verifyAddons() }.openAddonsManagerMenu { + addonsListIdlingResource = + RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.add_ons_list), 1) + IdlingRegistry.getInstance().register(addonsListIdlingResource!!) verifyAddonsItems() } } @@ -65,6 +76,9 @@ class SettingsAddonsTest { }.openNewTabAndEnterToBrowser(defaultWebPage.url) { }.openThreeDotMenu { }.openAddonsManagerMenu { + addonsListIdlingResource = + RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.add_ons_list), 1) + IdlingRegistry.getInstance().register(addonsListIdlingResource!!) clickInstallAddon(addonName) verifyAddonPrompt(addonName) cancelInstallAddon() @@ -85,6 +99,9 @@ class SettingsAddonsTest { verifyAdvancedHeading() verifyAddons() }.openAddonsManagerMenu { + addonsListIdlingResource = + RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.add_ons_list), 1) + IdlingRegistry.getInstance().register(addonsListIdlingResource!!) clickInstallAddon(addonName) acceptInstallAddon() verifyDownloadAddonPrompt(addonName, activityTestRule)