diff --git a/app/src/androidTest/assets/pages/etp.html b/app/src/androidTest/assets/pages/etp.html index 453f4d8ba..eed0969ce 100644 --- a/app/src/androidTest/assets/pages/etp.html +++ b/app/src/androidTest/assets/pages/etp.html @@ -1,41 +1,18 @@ - - - + + + + + Trackers -

Test for each list will say "Blocked" if Firefox is blocking resources from that list.

-

Fingerprinting (base-fingerprinting-track-digest256):

- -
-

Cryptomining (base-cryptomining-track-digest256):

- -
-

Basic Tracking Protection List (base-track-digest256):

- -

STP Tracker blocking (social-tracking-protection-digest256)

- -

social-track-digest256:

- -
-

ads-track-digest256:

- -
-

analytics-track-digest256:

- +

Trackers

+ + + + + diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/EnhancedTrackingProtectionTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/EnhancedTrackingProtectionTest.kt index 175f7c6c4..7953301f1 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/EnhancedTrackingProtectionTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/EnhancedTrackingProtectionTest.kt @@ -8,7 +8,6 @@ import androidx.test.platform.app.InstrumentationRegistry import okhttp3.mockwebserver.MockWebServer import org.junit.After import org.junit.Before -import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.mozilla.fenix.helpers.AndroidAssetDispatcher @@ -74,7 +73,6 @@ class EnhancedTrackingProtectionTest { } } - @Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907") @Test fun testStrictVisitContentNotification() { val trackingProtectionTest = @@ -88,7 +86,6 @@ class EnhancedTrackingProtectionTest { }.closeNotificationPopup {} } - @Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907") @Test fun testStrictVisitContentShield() { val trackingProtectionTest = @@ -106,7 +103,6 @@ class EnhancedTrackingProtectionTest { } } - @Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907") @Test fun testStrictVisitProtectionSheet() { val trackingProtectionTest = @@ -126,7 +122,6 @@ class EnhancedTrackingProtectionTest { } } - @Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907") @Test fun testStrictVisitDisable() { val trackingProtectionTest = @@ -150,12 +145,14 @@ class EnhancedTrackingProtectionTest { // Verify that Enhanced Tracking Protection remains globally enabled navigationToolbar { }.openThreeDotMenu { + verifyThreeDotMenuExists() + verifySettingsButton() }.openSettings { + verifyEnhancedTrackingProtectionButton() verifyEnhancedTrackingProtectionValue("On") } } - @Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907") @Test fun testStrictVisitDisableExceptionToggle() { val trackingProtectionTest = @@ -188,7 +185,6 @@ class EnhancedTrackingProtectionTest { } } - @Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907") @Test fun testStrictVisitSheetDetails() { val trackingProtectionTest = diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt index a0eb1a932..51f3a80a9 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt @@ -65,7 +65,7 @@ class NavigationToolbarRobot { } fun openThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition { - mDevice.waitNotNull(Until.findObject(By.descContains("Menu")), waitingTime) + mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_menu")), waitingTime) threeDotButton().click() ThreeDotMenuMainRobot().interact() @@ -146,7 +146,7 @@ private fun assertNoHistoryBookmarks() { private fun dismissOnboardingButton() = onView(withId(R.id.close_onboarding)) private fun urlBar() = onView(withId(R.id.toolbar)) private fun awesomeBar() = onView(withId(R.id.mozac_browser_toolbar_edit_url_view)) -private fun threeDotButton() = onView(withContentDescription("Menu")) +private fun threeDotButton() = onView(withId(R.id.mozac_browser_toolbar_menu)) private fun newTab() = onView(withContentDescription("Add tab")) private fun fillLinkButton() = onView(withId(R.id.fill_link_from_clipboard)) private fun clearAddressBar() = onView(withId(R.id.mozac_browser_toolbar_clear_view)) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt index e687e9a21..05ce3e73f 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SettingsRobot.kt @@ -195,6 +195,7 @@ private fun assertPrivacyHeading() { } private fun assertEnhancedTrackingProtectionButton() { + mDevice.wait(Until.findObject(By.text("Privacy and Security")), waitingTime) onView(ViewMatchers.withId(R.id.recycler_view)).perform( RecyclerViewActions.scrollTo( ViewMatchers.hasDescendant(ViewMatchers.withText("Enhanced Tracking Protection")) @@ -202,8 +203,10 @@ private fun assertEnhancedTrackingProtectionButton() { ).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) } -private fun assertEnhancedTrackingProtectionValue(state: String) = +private fun assertEnhancedTrackingProtectionValue(state: String) { + mDevice.wait(Until.findObject(By.text("Enhanced Tracking Protection")), waitingTime) onView(ViewMatchers.withText(state)).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) +} private fun assertLoginsButton() { TestHelper.scrollToElementByText("Logins and passwords") 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 75d8c198a..47339578d 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 @@ -6,18 +6,16 @@ package org.mozilla.fenix.ui.robots -import android.view.View +import androidx.preference.R +import androidx.recyclerview.widget.RecyclerView import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.UiController -import androidx.test.espresso.ViewAction import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.withResourceName import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.UiDevice import org.hamcrest.CoreMatchers -import org.hamcrest.Matcher -import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.isChecked @@ -46,24 +44,15 @@ class SettingsSubMenuEnhancedTrackingProtectionRobot { fun openExceptions( interact: SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.() -> Unit ): SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.Transition { - TestHelper.scrollToElementByText("Exceptions") - openExceptions().perform( - object : ViewAction { - override fun getConstraints(): Matcher { - // do not check constraints, check if enabled - return ViewMatchers.isEnabled() - } - override fun getDescription(): String { - return "Exceptions" - } - - override fun perform(uiController: UiController?, view: View) { - view.performClick() - } - } + onView(ViewMatchers.withId(R.id.recycler_view)).perform( + RecyclerViewActions.scrollTo( + ViewMatchers.hasDescendant(ViewMatchers.withText("Exceptions")) + ) ) + openExceptions().click() + SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot().interact() return SettingsSubMenuEnhancedTrackingProtectionExceptionsRobot.Transition() } @@ -84,9 +73,16 @@ private fun assertEnhancedTrackingProtectionOptions() { onView(ViewMatchers.withText("Strict (Default)")) .check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) - val summaryText = + val strictText = "Stronger tracking protection and faster performance, but some sites may not work properly." - onView(ViewMatchers.withText(summaryText)) + onView(ViewMatchers.withText(strictText)) + .check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + + onView(ViewMatchers.withText("Custom")) + .check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + val customText = + "Choose which trackers and scripts to block" + onView(ViewMatchers.withText(customText)) .check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt index ff4ec3725..179b635e8 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt @@ -7,20 +7,21 @@ package org.mozilla.fenix.ui.robots import androidx.recyclerview.widget.RecyclerView -import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions import androidx.test.espresso.assertion.ViewAssertions import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.hasDescendant import androidx.test.espresso.matcher.ViewMatchers.hasFocus +import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDisplayed 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.espresso.matcher.ViewMatchers.Visibility import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice @@ -86,7 +87,10 @@ class ThreeDotMenuMainRobot { private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) fun openSettings(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition { - settingsButton().click() + onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) + .check(matches(isCompletelyDisplayed())) + .perform(ViewActions.click()) SettingsRobot().interact() return SettingsRobot.Transition() @@ -236,55 +240,50 @@ private fun threeDotMenuRecyclerViewExists() { onView(withId(R.id.mozac_browser_menu_recyclerView)).check(matches(isDisplayed())) } -private fun settingsButton() = onView( - allOf( - withText(R.string.settings), - withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE) - ) -) - +private fun settingsButton() = onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings))) private fun assertSettingsButton() = settingsButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) + .check(matches(isCompletelyDisplayed())) private fun libraryButton() = onView(allOf(withText(R.string.browser_menu_your_library))) private fun assertLibraryButton() = libraryButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun historyButton() = onView(allOf(withText(R.string.library_history))) private fun assertHistoryButton() = historyButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun bookmarksButton() = onView(allOf(withText(R.string.library_bookmarks))) private fun assertBookmarksButton() = bookmarksButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun helpButton() = onView(allOf(withText(R.string.browser_menu_help))) private fun assertHelpButton() = helpButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun forwardButton() = onView(ViewMatchers.withContentDescription("Forward")) private fun assertForwardButton() = forwardButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun addBookmarkButton() = onView(ViewMatchers.withContentDescription("Bookmark")) private fun assertAddBookmarkButton() = addBookmarkButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun editBookmarkButton() = onView(ViewMatchers.withContentDescription("Edit bookmark")) private fun assertEditBookmarkButton() = editBookmarkButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun refreshButton() = onView(ViewMatchers.withContentDescription("Refresh")) private fun assertRefreshButton() = refreshButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun closeAllTabsButton() = onView(allOf(withText("Close all tabs"))) private fun assertCloseAllTabsButton() = closeAllTabsButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun shareTabButton() = onView(allOf(withText("Share tabs"))) private fun assertShareTabButton() = shareTabButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun shareButton() = onView(ViewMatchers.withContentDescription("Share")) private fun assertShareButton() = shareButton() @@ -299,15 +298,15 @@ private fun browserViewSaveCollectionButton() = onView( private fun saveCollectionButton() = onView(allOf(withText("Save to collection"))) private fun assertSaveCollectionButton() = saveCollectionButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun addNewCollectionButton() = onView(allOf(withText("Add new collection"))) private fun assertaddNewCollectionButton() = addNewCollectionButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun collectionNameTextField() = onView(allOf(withResourceName("name_collection_edittext"))) private fun assertCollectionNameTextField() = collectionNameTextField() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun findInPageButton() = onView(allOf(withText("Find in page"))) private fun assertFindInPageButton() = findInPageButton() @@ -320,7 +319,7 @@ private fun SendToDeviceTitle() = onView(allOf(withText("SEND TO DEVICE"), withResourceName("accountHeaderText"))) private fun assertSendToDeviceTitle() = SendToDeviceTitle() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun ShareALinkTitle() = onView(allOf(withText("ALL ACTIONS"), withResourceName("apps_link_header"))) @@ -330,17 +329,17 @@ private fun assertShareALinkTitle() = ShareALinkTitle() private fun whatsNewButton() = onView( allOf( withText("What’s New"), - withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE) + withEffectiveVisibility(Visibility.VISIBLE) ) ) private fun assertWhatsNewButton() = whatsNewButton() - .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun readerViewToggle() = onView(allOf(withText(R.string.browser_menu_read))) private fun assertReaderViewToggle(visible: Boolean) = readerViewToggle() .check( - if (visible) matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)) else ViewAssertions.doesNotExist() + if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else ViewAssertions.doesNotExist() ) private fun readerViewAppearanceToggle() = @@ -348,7 +347,7 @@ private fun readerViewAppearanceToggle() = private fun assertReaderViewAppearanceButton(visible: Boolean) = readerViewAppearanceToggle() .check( - if (visible) matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)) else ViewAssertions.doesNotExist() + if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else ViewAssertions.doesNotExist() ) private fun addToFirefoxHomeButton() =