Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Re-enable ETP UI tests and update local asset
Browse files Browse the repository at this point in the history
fix: more reliable scroll on descendant in recycler view

fix: ktlint
  • Loading branch information
AaronMT committed Feb 26, 2020
1 parent 2096176 commit a7d3aac
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 66 deletions.
49 changes: 13 additions & 36 deletions app/src/androidTest/assets/pages/etp.html
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand All @@ -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 =
Expand All @@ -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 =
Expand All @@ -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 =
Expand All @@ -151,11 +146,11 @@ class EnhancedTrackingProtectionTest {
navigationToolbar {
}.openThreeDotMenu {
}.openSettings {
verifyEnhancedTrackingProtectionButton()
verifyEnhancedTrackingProtectionValue("On")
}
}

@Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907")
@Test
fun testStrictVisitDisableExceptionToggle() {
val trackingProtectionTest =
Expand Down Expand Up @@ -188,7 +183,6 @@ class EnhancedTrackingProtectionTest {
}
}

@Ignore("Disabled for investigation into failure - https://github.com/mozilla-mobile/fenix/issues/7907")
@Test
fun testStrictVisitSheetDetails() {
val trackingProtectionTest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
}
Expand All @@ -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)))
}

Expand Down

0 comments on commit a7d3aac

Please sign in to comment.