From 2e60b8d80a541f4e1ed3b66ee79b8df8d79b40f0 Mon Sep 17 00:00:00 2001 From: Arturo Mejia Date: Mon, 16 Aug 2021 15:34:39 -0400 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/19886 fix ui tests --- .../java/org/mozilla/fenix/ui/SmokeTest.kt | 38 ++----------------- .../StrictEnhancedTrackingProtectionTest.kt | 20 +--------- .../mozilla/fenix/ui/robots/BrowserRobot.kt | 26 +------------ .../robots/EnhancedTrackingProtectionRobot.kt | 17 ++------- ...sSubMenuEnhancedTrackingProtectionRobot.kt | 2 - 5 files changed, 8 insertions(+), 95 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt index 0fc174f773..d9d5634584 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -40,7 +40,6 @@ import org.mozilla.fenix.ui.robots.clickTabCrashedRestoreButton import org.mozilla.fenix.ui.robots.clickUrlbar import org.mozilla.fenix.ui.robots.collectionRobot import org.mozilla.fenix.ui.robots.customTabScreen -import org.mozilla.fenix.ui.robots.dismissTrackingOnboarding import org.mozilla.fenix.ui.robots.downloadRobot import org.mozilla.fenix.ui.robots.enhancedTrackingProtection import org.mozilla.fenix.ui.robots.homeScreen @@ -392,34 +391,7 @@ class SmokeTest { } @Test - // Turns ETP toggle off from Settings and verifies the ETP shield is not displayed in the nav bar - fun verifyETPShieldNotDisplayedIfOFFGlobally() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - - homeScreen { - }.openThreeDotMenu { - }.openSettings { - }.openEnhancedTrackingProtectionSubMenu { - switchEnhancedTrackingProtectionToggle() - verifyEnhancedTrackingProtectionOptionsGrayedOut() - }.goBackToHomeScreen { - navigationToolbar { - }.enterURLAndEnterToBrowser(defaultWebPage.url) { - verifyEnhancedTrackingProtectionPanelNotVisible() - }.openThreeDotMenu { - }.openSettings { - }.openEnhancedTrackingProtectionSubMenu { - switchEnhancedTrackingProtectionToggle() - }.goBack { - }.goBackToBrowser { - clickEnhancedTrackingProtectionPanel() - verifyEnhancedTrackingProtectionSwitch() - clickEnhancedTrackingProtectionSwitchOffOn() - } - } - } - - @Test + @Ignore("https://github.com/mozilla-mobile/fenix/issues/20868") fun customTrackingProtectionSettingsTest() { val genericWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) val trackingPage = TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer) @@ -437,12 +409,11 @@ class SmokeTest { // browsing a basic page to allow GV to load on a fresh run }.enterURLAndEnterToBrowser(genericWebPage.url) { }.openNavigationToolbar { - }.openTrackingProtectionTestPage(trackingPage.url, true) { - dismissTrackingOnboarding() - } + }.openTrackingProtectionTestPage(trackingPage.url, true) {} enhancedTrackingProtection { }.openEnhancedTrackingProtectionSheet { + }.openDetails { verifyTrackingCookiesBlocked() verifyCryptominersBlocked() verifyFingerprintersBlocked() @@ -664,9 +635,6 @@ class SmokeTest { }.goBack { }.openNavigationToolbar { }.openTrackingProtectionTestPage(trackingProtectionPage.url, true) {} - enhancedTrackingProtection { - verifyEnhancedTrackingProtectionShield() - }.closeNotificationPopup {} } @Test diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt index fb3f07373c..c39e0b8b73 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/StrictEnhancedTrackingProtectionTest.kt @@ -76,19 +76,6 @@ class StrictEnhancedTrackingProtectionTest { } } - @Test - fun testStrictVisitContentShield() { - val trackingProtectionTest = - TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer) - - navigationToolbar { - }.openTrackingProtectionTestPage(trackingProtectionTest.url, true) {} - - enhancedTrackingProtection { - verifyEnhancedTrackingProtectionShield() - } - } - @Test fun testStrictVisitProtectionSheet() { val trackingProtectionTest = @@ -97,9 +84,7 @@ class StrictEnhancedTrackingProtectionTest { navigationToolbar { }.openTrackingProtectionTestPage(trackingProtectionTest.url, true) {} - enhancedTrackingProtection { - verifyEnhancedTrackingProtectionShield() - }.openEnhancedTrackingProtectionSheet { + enhancedTrackingProtection {}.openEnhancedTrackingProtectionSheet { verifyEnhancedTrackingProtectionSheetStatus("ON", true) } } @@ -113,7 +98,6 @@ class StrictEnhancedTrackingProtectionTest { }.openTrackingProtectionTestPage(trackingProtectionTest.url, true) {} enhancedTrackingProtection { - verifyEnhancedTrackingProtectionShield() }.openEnhancedTrackingProtectionSheet { verifyEnhancedTrackingProtectionSheetStatus("ON", true) }.disableEnhancedTrackingProtectionFromSheet { @@ -139,7 +123,6 @@ class StrictEnhancedTrackingProtectionTest { }.openTrackingProtectionTestPage(trackingProtectionTest.url, true) {} enhancedTrackingProtection { - verifyEnhancedTrackingProtectionShield() }.openEnhancedTrackingProtectionSheet { verifyEnhancedTrackingProtectionSheetStatus("ON", true) }.disableEnhancedTrackingProtectionFromSheet { @@ -167,7 +150,6 @@ class StrictEnhancedTrackingProtectionTest { }.openTrackingProtectionTestPage(trackingProtectionTest.url, true) {} enhancedTrackingProtection { - verifyEnhancedTrackingProtectionShield() }.openEnhancedTrackingProtectionSheet { verifyEnhancedTrackingProtectionSheetStatus("ON", true) }.openDetails { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index 608ecaa05e..558d7ff47d 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -26,7 +26,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withContentDescription import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withId -import androidx.test.espresso.matcher.ViewMatchers.withResourceName import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By @@ -164,15 +163,9 @@ class BrowserRobot { fun verifyEnhancedTrackingProtectionSwitch() = assertEnhancedTrackingProtectionSwitch() - fun clickEnhancedTrackingProtectionSwitchOffOn() = - onView(withResourceName("switch_widget")).click() - - fun verifyProtectionSettingsButton() = assertProtectionSettingsButton() - fun verifyEnhancedTrackingOptions() { - clickEnhancedTrackingProtectionPanel() + onView(withId(R.id.mozac_browser_toolbar_security_indicator)).click() verifyEnhancedTrackingProtectionSwitch() - verifyProtectionSettingsButton() } fun verifyMenuButton() = assertMenuButton() @@ -214,11 +207,6 @@ class BrowserRobot { .perform(ViewActions.pressBack()) } - fun clickEnhancedTrackingProtectionPanel() = enhancedTrackingProtectionIndicator().click() - - fun verifyEnhancedTrackingProtectionPanelNotVisible() = - assertEnhancedTrackingProtectionIndicatorNotVisible() - fun clickContextOpenLinkInNewTab() { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) mDevice.waitNotNull( @@ -566,11 +554,6 @@ fun browserScreen(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { return BrowserRobot.Transition() } -fun dismissTrackingOnboarding() { - mDevice.wait(Until.findObject(By.res("close_onboarding")), waitingTime) - dismissOnboardingButton().click() -} - fun navURLBar() = onView(withId(R.id.toolbar)) private fun assertNavURLBar() = navURLBar() @@ -579,13 +562,6 @@ private fun assertNavURLBar() = navURLBar() private fun assertNavURLBarHidden() = navURLBar() .check(matches(not(isDisplayed()))) -fun enhancedTrackingProtectionIndicator() = - onView(withId(R.id.mozac_browser_toolbar_tracking_protection_indicator)) - -private fun assertEnhancedTrackingProtectionIndicatorNotVisible() { - enhancedTrackingProtectionIndicator().check(matches(not(isDisplayed()))) -} - private fun assertEnhancedTrackingProtectionSwitch() { withText(R.id.trackingProtectionSwitch) .matches(withEffectiveVisibility(Visibility.VISIBLE)) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/EnhancedTrackingProtectionRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/EnhancedTrackingProtectionRobot.kt index 23ec6040e9..de1ace4dbd 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/EnhancedTrackingProtectionRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/EnhancedTrackingProtectionRobot.kt @@ -33,8 +33,6 @@ class EnhancedTrackingProtectionRobot { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())!! - fun verifyEnhancedTrackingProtectionShield() = assertEnhancedTrackingProtectionShield() - fun verifyEnhancedTrackingProtectionSheetStatus(status: String, state: Boolean) = assertEnhancedTrackingProtectionSheetStatus(status, state) @@ -52,18 +50,10 @@ class EnhancedTrackingProtectionRobot { class Transition { fun openEnhancedTrackingProtectionSheet(interact: EnhancedTrackingProtectionRobot.() -> Unit): Transition { openEnhancedTrackingProtectionSheet().click() - EnhancedTrackingProtectionRobot().interact() return Transition() } - fun closeNotificationPopup(interact: BrowserRobot.() -> Unit): Transition { - closeButton().click() - - BrowserRobot().interact() - return Transition() - } - fun closeEnhancedTrackingProtectionSheet(interact: BrowserRobot.() -> Unit): Transition { // Back out of the Enhanced Tracking Protection sheet mDevice.pressBack() @@ -80,6 +70,7 @@ class EnhancedTrackingProtectionRobot { } fun openProtectionSettings(interact: SettingsSubMenuEnhancedTrackingProtectionRobot.() -> Unit): Transition { + onView(withId(R.id.trackingProtectionDetails)).click() openEnhancedTrackingProtectionSettings().click() SettingsSubMenuEnhancedTrackingProtectionRobot().interact() @@ -121,10 +112,8 @@ private fun assertEnhancedTrackingProtectionDetailsStatus(status: String) { mDevice.waitNotNull(Until.findObjects(By.textContains(status))) } -private fun closeButton() = onView(ViewMatchers.withId(R.id.close_onboarding)) - private fun openEnhancedTrackingProtectionSheet() = - onView(ViewMatchers.withId(R.id.mozac_browser_toolbar_tracking_protection_indicator)) + onView(withId(R.id.mozac_browser_toolbar_security_indicator)) private fun disableEnhancedTrackingProtection() = onView(ViewMatchers.withResourceName("switch_widget")) @@ -133,7 +122,7 @@ private fun openEnhancedTrackingProtectionSettings() = onView(ViewMatchers.withId(R.id.protection_settings)) private fun openEnhancedTrackingProtectionDetails() = - onView(ViewMatchers.withId(R.id.tracking_content)) + onView(ViewMatchers.withId(R.id.trackingProtectionDetails)) private fun assertTrackingCookiesBlocked() { mDevice.findObject(UiSelector().resourceId("$packageName:id/cross_site_tracking")) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuEnhancedTrackingProtectionRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuEnhancedTrackingProtectionRobot.kt index c60f8e965f..3915461b31 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuEnhancedTrackingProtectionRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsSubMenuEnhancedTrackingProtectionRobot.kt @@ -50,8 +50,6 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot { fun verifyEnhancedTrackingProtectionOptions() = assertEnhancedTrackingProtectionOptions() - fun verifyEnhancedTrackingProtectionOptionsGrayedOut() = assertEnhancedTrackingProtectionOptionsGrayedOut() - fun verifyTrackingProtectionSwitchEnabled() = assertTrackingProtectionSwitchEnabled() fun switchEnhancedTrackingProtectionToggle() = onView(withResourceName("switch_widget")).click()