1
0
Fork 0

Re-enable ETP UI tests and update local asset (#8733)

master
Aaron Train 2020-03-02 14:40:52 -05:00 committed by GitHub
parent e3d34edfc7
commit 6ac13b3f7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 97 deletions

View File

@ -1,41 +1,18 @@
<!-- https://github.com/mozilla/dummytracker -->
<!-- https://github.com/englehardt/englehardt.github.io/tree/master/test/trackingprotection/test_pages -->
<html>
<!DOCTYPE HTML>
<!-- 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/. -->
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<meta charset="utf8">
<title>Trackers</title></head>
</head>
<body>
<p>Test for each list will say "Blocked" if Firefox is blocking resources from that list.</p>
<p>Fingerprinting (base-fingerprinting-track-digest256):</p>
<img
src="https://base-fingerprinting-track-digest256.dummytracker.org/test_not_blocked.png"
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png'">
<br/>
<p>Cryptomining (base-cryptomining-track-digest256):</p>
<img
src="https://base-cryptomining-track-digest256.dummytracker.org/test_not_blocked.png"
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png'">
<br/>
<p>Basic Tracking Protection List (base-track-digest256):</p>
<img
src="https://base-track-digest256.dummytracker.org/test_not_blocked.png"
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png'">
<p>STP Tracker blocking (social-tracking-protection-digest256)</p>
<img
src="https://social-tracking-protection-digest256.dummytracker.org/test_not_blocked.png"
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png'">
<p>social-track-digest256:</p>
<img
src="https://social-track-digest256.dummytracker.org/test_not_blocked.png"
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png'">
<br/>
<p>ads-track-digest256:</p>
<img
src="https://ads-track-digest256.dummytracker.org/test_not_blocked.png"
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png'">
<br/>
<p>analytics-track-digest256:</p>
<img
src="https://analytics-track-digest256.dummytracker.org/test_not_blocked.png"
onerror="this.onerror=null;this.src='https://not-a-tracker.dummytracker.org/test_blocked.png'">
<p>Trackers</p>
<!-- test-track-simple -->
<script src="http://trackertest.org/tracker.js"></script>
<script src="https://tracking.example.com/tracker.js"></script>
<script src="https://itisatracker.org/tracker.js"></script>
</body>
</html>

View File

@ -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 =

View File

@ -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))

View File

@ -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<RecyclerView.ViewHolder>(
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")

View File

@ -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<View> {
// 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<RecyclerView.ViewHolder>(
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)))
}

View File

@ -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("Whats 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() =