mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-11 13:11:01 +00:00
Bug 1861647 - Fenix: Add new Addons high priority tests
This commit is contained in:
parent
d619946676
commit
16be6d9a05
@ -17,12 +17,10 @@ import org.mozilla.fenix.helpers.AppAndSystemHelper.registerAndCleanupIdlingReso
|
||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||
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.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
|
||||
|
||||
/**
|
||||
* Tests for verifying the functionality of installing or removing addons
|
||||
@ -101,8 +99,7 @@ class SettingsAddonsTest {
|
||||
val addonName = "uBlock Origin"
|
||||
|
||||
addonsMenu {
|
||||
installAddon(addonName)
|
||||
verifyAddonInstallCompleted(addonName, activityTestRule)
|
||||
installAddon(addonName, activityTestRule)
|
||||
closeAddonInstallCompletePrompt()
|
||||
}.openDetailedMenuForAddon(addonName) {
|
||||
}.removeAddon(activityTestRule) {
|
||||
@ -116,24 +113,34 @@ class SettingsAddonsTest {
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/561600
|
||||
// Installs uBlock add-on and checks that the app doesn't crash while loading pages with trackers
|
||||
// Installs 3 add-on and checks that the app doesn't crash while navigating the app
|
||||
@SmokeTest
|
||||
@Test
|
||||
fun noCrashWithAddonInstalledTest() {
|
||||
// setting ETP to Strict mode to test it works with add-ons
|
||||
activityTestRule.activity.settings().setStrictETP()
|
||||
|
||||
val addonName = "uBlock Origin"
|
||||
val uBlockAddon = "uBlock Origin"
|
||||
val tampermonkeyAddon = "Tampermonkey"
|
||||
val privacyBadgerAddon = "Privacy Badger"
|
||||
val trackingProtectionPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||
|
||||
addonsMenu {
|
||||
installAddon(addonName)
|
||||
verifyAddonInstallCompleted(addonName, activityTestRule)
|
||||
installAddon(uBlockAddon, activityTestRule)
|
||||
closeAddonInstallCompletePrompt()
|
||||
installAddon(tampermonkeyAddon, activityTestRule)
|
||||
closeAddonInstallCompletePrompt()
|
||||
installAddon(privacyBadgerAddon, activityTestRule)
|
||||
closeAddonInstallCompletePrompt()
|
||||
}.goBack {
|
||||
}.openNavigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(trackingProtectionPage.url) {
|
||||
verifyUrl(trackingProtectionPage.url.toString())
|
||||
}.goToHomescreen {
|
||||
}.openTopSiteTabWithTitle("Top Articles") {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
verifySettingsView()
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,21 +149,36 @@ class SettingsAddonsTest {
|
||||
@Test
|
||||
fun verifyUBlockWorksInPrivateModeTest() {
|
||||
val addonName = "uBlock Origin"
|
||||
val genericPage = getGenericAsset(mockWebServer, 1)
|
||||
|
||||
addonsMenu {
|
||||
installAddon(addonName)
|
||||
verifyAddonInstallCompleted(addonName, activityTestRule)
|
||||
installAddon(addonName, activityTestRule)
|
||||
selectAllowInPrivateBrowsing()
|
||||
closeAddonInstallCompletePrompt()
|
||||
}.goBack {
|
||||
}.togglePrivateBrowsingMode()
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(genericPage.url) {
|
||||
verifyPageContent(genericPage.content)
|
||||
}.openContextMenuOnSponsoredShortcut("Top Articles") {
|
||||
}.openTopSiteInPrivateTab {
|
||||
waitForPageToLoad()
|
||||
}.openThreeDotMenu {
|
||||
openAddonsSubList()
|
||||
verifyAddonAvailableInMainMenu(addonName)
|
||||
verifyTrackersBlockedByUblock()
|
||||
}
|
||||
}
|
||||
|
||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/875785
|
||||
@Test
|
||||
fun verifyUBlockWorksInNormalModeTest() {
|
||||
val addonName = "uBlock Origin"
|
||||
|
||||
addonsMenu {
|
||||
installAddon(addonName, activityTestRule)
|
||||
closeAddonInstallCompletePrompt()
|
||||
}.goBack {
|
||||
}.openTopSiteTabWithTitle("Top Articles") {
|
||||
waitForPageToLoad()
|
||||
}.openThreeDotMenu {
|
||||
openAddonsSubList()
|
||||
verifyTrackersBlockedByUblock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import android.util.Log
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.action.ViewActions.scrollTo
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.RootMatchers.isDialog
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
@ -84,36 +85,47 @@ class SettingsSubMenuAddonsManagerRobot {
|
||||
}
|
||||
|
||||
fun clickInstallAddon(addonName: String) {
|
||||
mDevice.waitNotNull(
|
||||
Until.findObject(By.textContains(addonName)),
|
||||
waitingTime,
|
||||
)
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("$packageName:id/add_ons_list"),
|
||||
).waitForExists(waitingTime)
|
||||
|
||||
installButtonForAddon(addonName)
|
||||
.perform(scrollTo())
|
||||
.check(matches(isCompletelyDisplayed()))
|
||||
.perform(click())
|
||||
Log.e("TestLog", "Clicked Install $addonName button")
|
||||
}
|
||||
|
||||
fun verifyAddonInstallCompleted(addonName: String, activityTestRule: HomeActivityIntentTestRule) {
|
||||
for (i in 1..RETRY_COUNT) {
|
||||
try {
|
||||
assertFalse(
|
||||
"$addonName failed to install",
|
||||
mDevice.findObject(UiSelector().text("Failed to install $addonName"))
|
||||
.waitForExists(waitingTimeShort),
|
||||
)
|
||||
|
||||
assertTrue(
|
||||
"$addonName failed to install",
|
||||
mDevice.findObject(UiSelector().text("Okay, Got it"))
|
||||
.waitForExists(waitingTimeLong),
|
||||
)
|
||||
Log.e("TestLog", "$addonName installed successfully.")
|
||||
break
|
||||
} catch (e: AssertionError) {
|
||||
if (i == RETRY_COUNT) {
|
||||
throw e
|
||||
} else {
|
||||
Log.e("TestLog", "Addon failed to install on try #$i")
|
||||
Log.e("TestLog", "$addonName failed to install on try #$i")
|
||||
restartApp(activityTestRule)
|
||||
installAddon(addonName)
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openAddonsManagerMenu {
|
||||
scrollToElementByText(addonName)
|
||||
clickInstallAddon(addonName)
|
||||
verifyAddonPermissionPrompt(addonName)
|
||||
acceptPermissionToInstallAddon()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,13 +172,14 @@ class SettingsSubMenuAddonsManagerRobot {
|
||||
onView(withId(R.id.allow_in_private_browsing)).click()
|
||||
}
|
||||
|
||||
fun installAddon(addonName: String) {
|
||||
fun installAddon(addonName: String, activityTestRule: HomeActivityIntentTestRule) {
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openAddonsManagerMenu {
|
||||
clickInstallAddon(addonName)
|
||||
verifyAddonPermissionPrompt(addonName)
|
||||
acceptPermissionToInstallAddon()
|
||||
verifyAddonInstallCompleted(addonName, activityTestRule)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.mozilla.fenix.helpers.MatcherHelper.assertItemWithResIdAndTextExists
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.checkedItemWithResIdAndText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText
|
||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||
@ -175,6 +176,11 @@ class ThreeDotMenuMainRobot {
|
||||
}
|
||||
}
|
||||
|
||||
fun verifyTrackersBlockedByUblock() {
|
||||
assertTrue(itemWithResId("$packageName:id/badge_text").waitForExists(waitingTime))
|
||||
assertTrue(itemWithResId("$packageName:id/badge_text").text.toInt() > 0)
|
||||
}
|
||||
|
||||
fun clickQuit() {
|
||||
expandMenu()
|
||||
onView(withText("Quit")).click()
|
||||
|
Loading…
Reference in New Issue
Block a user