2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

Bug 1807280 - fix SettingsAddonsTest#verifyAddonsCanBeUninstalled

This commit is contained in:
oana.horvath 2023-05-17 15:42:48 +03:00 committed by mergify[bot]
parent 2c6c6ef8ad
commit ef2619142a
3 changed files with 34 additions and 13 deletions

View File

@ -137,6 +137,15 @@ object TestHelper {
).waitUntilGone(waitingTime)
}
fun verifySnackBarText(expectedText: String) {
assertTrue(
mDevice.findObject(
UiSelector()
.textContains(expectedText),
).waitForExists(waitingTime),
)
}
fun verifyUrl(urlSubstring: String, resourceName: String, resId: Int) {
waitUntilObjectIsFound(resourceName)
mDevice.findObject(UiSelector().text(urlSubstring)).waitForExists(waitingTime)
@ -333,7 +342,7 @@ object TestHelper {
)
}
fun getStringResource(id: Int) = appContext.resources.getString(id, appName)
fun getStringResource(id: Int, argument: String = appName) = appContext.resources.getString(id, argument)
fun setCustomSearchEngine(searchEngine: SearchEngine) {
with(appContext.components.useCases.searchUseCases) {

View File

@ -4,7 +4,6 @@
package org.mozilla.fenix.ui
import android.view.View
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
@ -19,7 +18,8 @@ import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper.getEnhancedTrackingProtectionAsset
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
import org.mozilla.fenix.helpers.TestHelper.registerAndCleanupIdlingResources
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.helpers.TestHelper.verifySnackBarText
import org.mozilla.fenix.helpers.TestHelper.waitUntilSnackbarGone
import org.mozilla.fenix.ui.robots.addonsMenu
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
@ -102,13 +102,12 @@ class SettingsAddonsTest {
verifyAddonInstallCompleted(addonName, activityTestRule)
closeAddonInstallCompletePrompt()
}.openDetailedMenuForAddon(addonName) {
registerAndCleanupIdlingResources(
ViewVisibilityIdlingResource(
activityTestRule.activity.findViewById(R.id.addon_container),
View.VISIBLE,
),
) {}
}.removeAddon {
}.removeAddon(activityTestRule) {
verifySnackBarText("Successfully uninstalled $addonName")
waitUntilSnackbarGone()
}.goBack {
}.openThreeDotMenu {
}.openAddonsManagerMenu {
verifyAddonCanBeInstalled(addonName)
}
}

View File

@ -1,17 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@file:Suppress("DEPRECATION")
package org.mozilla.fenix.ui.robots
import android.view.View
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.rule.ActivityTestRule
import org.hamcrest.CoreMatchers.allOf
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestHelper.registerAndCleanupIdlingResources
import org.mozilla.fenix.helpers.ViewVisibilityIdlingResource
import org.mozilla.fenix.helpers.click
/**
@ -29,9 +35,16 @@ class SettingsSubMenuAddonsManagerAddonDetailedMenuRobot {
return SettingsSubMenuAddonsManagerRobot.Transition()
}
fun removeAddon(interact: SettingsSubMenuAddonsManagerRobot.() -> Unit): SettingsSubMenuAddonsManagerRobot.Transition {
removeAddonButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
removeAddonButton().click()
fun removeAddon(activityTestRule: ActivityTestRule<HomeActivity>, interact: SettingsSubMenuAddonsManagerRobot.() -> Unit): SettingsSubMenuAddonsManagerRobot.Transition {
registerAndCleanupIdlingResources(
ViewVisibilityIdlingResource(
activityTestRule.activity.findViewById(R.id.addon_container),
View.VISIBLE,
),
) {
removeAddonButton().check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
removeAddonButton().click()
}
SettingsSubMenuAddonsManagerRobot().interact()
return SettingsSubMenuAddonsManagerRobot.Transition()