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.HomeActivityIntentTestRule
|
||||||
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
|
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper.getEnhancedTrackingProtectionAsset
|
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.verifySnackBarText
|
||||||
import org.mozilla.fenix.helpers.TestHelper.waitUntilSnackbarGone
|
import org.mozilla.fenix.helpers.TestHelper.waitUntilSnackbarGone
|
||||||
import org.mozilla.fenix.ui.robots.addonsMenu
|
import org.mozilla.fenix.ui.robots.addonsMenu
|
||||||
import org.mozilla.fenix.ui.robots.homeScreen
|
import org.mozilla.fenix.ui.robots.homeScreen
|
||||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for verifying the functionality of installing or removing addons
|
* Tests for verifying the functionality of installing or removing addons
|
||||||
@ -101,8 +99,7 @@ class SettingsAddonsTest {
|
|||||||
val addonName = "uBlock Origin"
|
val addonName = "uBlock Origin"
|
||||||
|
|
||||||
addonsMenu {
|
addonsMenu {
|
||||||
installAddon(addonName)
|
installAddon(addonName, activityTestRule)
|
||||||
verifyAddonInstallCompleted(addonName, activityTestRule)
|
|
||||||
closeAddonInstallCompletePrompt()
|
closeAddonInstallCompletePrompt()
|
||||||
}.openDetailedMenuForAddon(addonName) {
|
}.openDetailedMenuForAddon(addonName) {
|
||||||
}.removeAddon(activityTestRule) {
|
}.removeAddon(activityTestRule) {
|
||||||
@ -116,24 +113,34 @@ class SettingsAddonsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestRail link: https://testrail.stage.mozaws.net/index.php?/cases/view/561600
|
// 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
|
@SmokeTest
|
||||||
@Test
|
@Test
|
||||||
fun noCrashWithAddonInstalledTest() {
|
fun noCrashWithAddonInstalledTest() {
|
||||||
// setting ETP to Strict mode to test it works with add-ons
|
// setting ETP to Strict mode to test it works with add-ons
|
||||||
activityTestRule.activity.settings().setStrictETP()
|
activityTestRule.activity.settings().setStrictETP()
|
||||||
|
|
||||||
val addonName = "uBlock Origin"
|
val uBlockAddon = "uBlock Origin"
|
||||||
|
val tampermonkeyAddon = "Tampermonkey"
|
||||||
|
val privacyBadgerAddon = "Privacy Badger"
|
||||||
val trackingProtectionPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
val trackingProtectionPage = getEnhancedTrackingProtectionAsset(mockWebServer)
|
||||||
|
|
||||||
addonsMenu {
|
addonsMenu {
|
||||||
installAddon(addonName)
|
installAddon(uBlockAddon, activityTestRule)
|
||||||
verifyAddonInstallCompleted(addonName, activityTestRule)
|
closeAddonInstallCompletePrompt()
|
||||||
|
installAddon(tampermonkeyAddon, activityTestRule)
|
||||||
|
closeAddonInstallCompletePrompt()
|
||||||
|
installAddon(privacyBadgerAddon, activityTestRule)
|
||||||
closeAddonInstallCompletePrompt()
|
closeAddonInstallCompletePrompt()
|
||||||
}.goBack {
|
}.goBack {
|
||||||
}.openNavigationToolbar {
|
}.openNavigationToolbar {
|
||||||
}.enterURLAndEnterToBrowser(trackingProtectionPage.url) {
|
}.enterURLAndEnterToBrowser(trackingProtectionPage.url) {
|
||||||
verifyUrl(trackingProtectionPage.url.toString())
|
verifyUrl(trackingProtectionPage.url.toString())
|
||||||
|
}.goToHomescreen {
|
||||||
|
}.openTopSiteTabWithTitle("Top Articles") {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSettings {
|
||||||
|
verifySettingsView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,21 +149,36 @@ class SettingsAddonsTest {
|
|||||||
@Test
|
@Test
|
||||||
fun verifyUBlockWorksInPrivateModeTest() {
|
fun verifyUBlockWorksInPrivateModeTest() {
|
||||||
val addonName = "uBlock Origin"
|
val addonName = "uBlock Origin"
|
||||||
val genericPage = getGenericAsset(mockWebServer, 1)
|
|
||||||
|
|
||||||
addonsMenu {
|
addonsMenu {
|
||||||
installAddon(addonName)
|
installAddon(addonName, activityTestRule)
|
||||||
verifyAddonInstallCompleted(addonName, activityTestRule)
|
|
||||||
selectAllowInPrivateBrowsing()
|
selectAllowInPrivateBrowsing()
|
||||||
closeAddonInstallCompletePrompt()
|
closeAddonInstallCompletePrompt()
|
||||||
}.goBack {
|
}.goBack {
|
||||||
}.togglePrivateBrowsingMode()
|
}.openContextMenuOnSponsoredShortcut("Top Articles") {
|
||||||
navigationToolbar {
|
}.openTopSiteInPrivateTab {
|
||||||
}.enterURLAndEnterToBrowser(genericPage.url) {
|
waitForPageToLoad()
|
||||||
verifyPageContent(genericPage.content)
|
|
||||||
}.openThreeDotMenu {
|
}.openThreeDotMenu {
|
||||||
openAddonsSubList()
|
openAddonsSubList()
|
||||||
verifyAddonAvailableInMainMenu(addonName)
|
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 android.widget.RelativeLayout
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.action.ViewActions.click
|
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.assertion.ViewAssertions.matches
|
||||||
import androidx.test.espresso.matcher.RootMatchers.isDialog
|
import androidx.test.espresso.matcher.RootMatchers.isDialog
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||||
@ -84,36 +85,47 @@ class SettingsSubMenuAddonsManagerRobot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun clickInstallAddon(addonName: String) {
|
fun clickInstallAddon(addonName: String) {
|
||||||
mDevice.waitNotNull(
|
mDevice.findObject(
|
||||||
Until.findObject(By.textContains(addonName)),
|
UiSelector().resourceId("$packageName:id/add_ons_list"),
|
||||||
waitingTime,
|
).waitForExists(waitingTime)
|
||||||
)
|
|
||||||
|
|
||||||
installButtonForAddon(addonName)
|
installButtonForAddon(addonName)
|
||||||
|
.perform(scrollTo())
|
||||||
.check(matches(isCompletelyDisplayed()))
|
.check(matches(isCompletelyDisplayed()))
|
||||||
.perform(click())
|
.perform(click())
|
||||||
|
Log.e("TestLog", "Clicked Install $addonName button")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun verifyAddonInstallCompleted(addonName: String, activityTestRule: HomeActivityIntentTestRule) {
|
fun verifyAddonInstallCompleted(addonName: String, activityTestRule: HomeActivityIntentTestRule) {
|
||||||
for (i in 1..RETRY_COUNT) {
|
for (i in 1..RETRY_COUNT) {
|
||||||
try {
|
try {
|
||||||
assertFalse(
|
assertFalse(
|
||||||
|
"$addonName failed to install",
|
||||||
mDevice.findObject(UiSelector().text("Failed to install $addonName"))
|
mDevice.findObject(UiSelector().text("Failed to install $addonName"))
|
||||||
.waitForExists(waitingTimeShort),
|
.waitForExists(waitingTimeShort),
|
||||||
)
|
)
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
|
"$addonName failed to install",
|
||||||
mDevice.findObject(UiSelector().text("Okay, Got it"))
|
mDevice.findObject(UiSelector().text("Okay, Got it"))
|
||||||
.waitForExists(waitingTimeLong),
|
.waitForExists(waitingTimeLong),
|
||||||
)
|
)
|
||||||
|
Log.e("TestLog", "$addonName installed successfully.")
|
||||||
break
|
break
|
||||||
} catch (e: AssertionError) {
|
} catch (e: AssertionError) {
|
||||||
if (i == RETRY_COUNT) {
|
if (i == RETRY_COUNT) {
|
||||||
throw e
|
throw e
|
||||||
} else {
|
} else {
|
||||||
Log.e("TestLog", "Addon failed to install on try #$i")
|
Log.e("TestLog", "$addonName failed to install on try #$i")
|
||||||
restartApp(activityTestRule)
|
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()
|
onView(withId(R.id.allow_in_private_browsing)).click()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun installAddon(addonName: String) {
|
fun installAddon(addonName: String, activityTestRule: HomeActivityIntentTestRule) {
|
||||||
homeScreen {
|
homeScreen {
|
||||||
}.openThreeDotMenu {
|
}.openThreeDotMenu {
|
||||||
}.openAddonsManagerMenu {
|
}.openAddonsManagerMenu {
|
||||||
clickInstallAddon(addonName)
|
clickInstallAddon(addonName)
|
||||||
verifyAddonPermissionPrompt(addonName)
|
verifyAddonPermissionPrompt(addonName)
|
||||||
acceptPermissionToInstallAddon()
|
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.checkedItemWithResIdAndText
|
||||||
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText
|
||||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription
|
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.itemWithResIdAndText
|
||||||
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
|
import org.mozilla.fenix.helpers.MatcherHelper.itemWithText
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
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() {
|
fun clickQuit() {
|
||||||
expandMenu()
|
expandMenu()
|
||||||
onView(withText("Quit")).click()
|
onView(withText("Quit")).click()
|
||||||
|
Loading…
Reference in New Issue
Block a user