You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
7.0 KiB
Kotlin
212 lines
7.0 KiB
Kotlin
5 years ago
|
/* 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/. */
|
||
|
|
||
|
package org.mozilla.fenix.ui
|
||
|
|
||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||
|
import okhttp3.mockwebserver.MockWebServer
|
||
|
import org.junit.After
|
||
|
import org.junit.Before
|
||
|
import org.junit.Rule
|
||
|
import org.junit.Test
|
||
4 years ago
|
import org.mozilla.fenix.ext.settings
|
||
5 years ago
|
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||
|
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||
|
import org.mozilla.fenix.helpers.TestAssetHelper
|
||
|
import org.mozilla.fenix.helpers.TestHelper
|
||
|
import org.mozilla.fenix.ui.robots.enhancedTrackingProtection
|
||
|
import org.mozilla.fenix.ui.robots.homeScreen
|
||
|
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||
|
import org.mozilla.fenix.ui.robots.settingsSubMenuEnhancedTrackingProtection
|
||
|
|
||
|
/**
|
||
|
* Tests for verifying basic UI functionality of Enhanced Tracking Protection
|
||
|
*
|
||
|
* Including
|
||
|
* - Verifying default states
|
||
|
* - Verifying Enhanced Tracking Protection notification bubble
|
||
|
* - Verifying Enhanced Tracking Protection notification shield
|
||
|
* - Verifying Enhanced Tracking Protection content sheet
|
||
|
* - Verifying Enhanced Tracking Protection content sheet details
|
||
|
* - Verifying Enhanced Tracking Protection toggle
|
||
|
* - Verifying Enhanced Tracking Protection site exceptions
|
||
|
*/
|
||
|
|
||
4 years ago
|
class StrictEnhancedTrackingProtectionTest {
|
||
5 years ago
|
private lateinit var mockWebServer: MockWebServer
|
||
|
|
||
|
@get:Rule
|
||
|
val activityTestRule = HomeActivityTestRule()
|
||
|
|
||
|
@Before
|
||
|
fun setUp() {
|
||
|
mockWebServer = MockWebServer().apply {
|
||
|
setDispatcher(AndroidAssetDispatcher())
|
||
|
start()
|
||
|
}
|
||
|
|
||
4 years ago
|
InstrumentationRegistry.getInstrumentation().context.settings().setStrictETP()
|
||
|
|
||
5 years ago
|
// Reset on-boarding notification for each test
|
||
|
TestHelper.setPreference(
|
||
|
InstrumentationRegistry.getInstrumentation().context,
|
||
|
"pref_key_tracking_protection_onboarding", 0
|
||
|
)
|
||
|
}
|
||
|
|
||
|
@After
|
||
|
fun tearDown() {
|
||
|
mockWebServer.shutdown()
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun testSettingsDefaults() {
|
||
|
homeScreen {
|
||
|
}.openThreeDotMenu {
|
||
|
}.openSettings {
|
||
|
verifyEnhancedTrackingProtectionButton()
|
||
|
verifyEnhancedTrackingProtectionValue("On")
|
||
|
}.openEnhancedTrackingProtectionSubMenu {
|
||
|
verifyEnhancedTrackingProtectionHeader()
|
||
|
verifyEnhancedTrackingProtectionOptions()
|
||
|
verifyEnhancedTrackingProtectionDefaults()
|
||
|
}.openExceptions {
|
||
|
verifyDefault()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun testStrictVisitContentNotification() {
|
||
|
val trackingProtectionTest =
|
||
|
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||
|
|
||
|
navigationToolbar {
|
||
|
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionNotice()
|
||
|
}.closeNotificationPopup {}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun testStrictVisitContentShield() {
|
||
|
val trackingProtectionTest =
|
||
|
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||
|
|
||
|
navigationToolbar {
|
||
|
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionNotice()
|
||
|
}.closeNotificationPopup {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionShield()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun testStrictVisitProtectionSheet() {
|
||
|
val trackingProtectionTest =
|
||
|
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||
|
|
||
|
navigationToolbar {
|
||
|
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionNotice()
|
||
|
}.closeNotificationPopup {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionShield()
|
||
|
}.openEnhancedTrackingProtectionSheet {
|
||
|
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun testStrictVisitDisable() {
|
||
|
val trackingProtectionTest =
|
||
|
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||
|
|
||
|
navigationToolbar {
|
||
|
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionNotice()
|
||
|
}.closeNotificationPopup {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionShield()
|
||
|
}.openEnhancedTrackingProtectionSheet {
|
||
|
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||
|
}.disableEnhancedTrackingProtectionFromSheet {
|
||
|
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||
|
}.closeEnhancedTrackingProtectionSheet {}
|
||
|
|
||
|
// Verify that Enhanced Tracking Protection remains globally enabled
|
||
|
navigationToolbar {
|
||
|
}.openThreeDotMenu {
|
||
4 years ago
|
verifyThreeDotMenuExists()
|
||
|
verifySettingsButton()
|
||
5 years ago
|
}.openSettings {
|
||
4 years ago
|
verifyEnhancedTrackingProtectionButton()
|
||
5 years ago
|
verifyEnhancedTrackingProtectionValue("On")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun testStrictVisitDisableExceptionToggle() {
|
||
|
val trackingProtectionTest =
|
||
|
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||
|
|
||
|
navigationToolbar {
|
||
|
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionNotice()
|
||
|
}.closeNotificationPopup {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionShield()
|
||
|
}.openEnhancedTrackingProtectionSheet {
|
||
|
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||
|
}.disableEnhancedTrackingProtectionFromSheet {
|
||
|
verifyEnhancedTrackingProtectionSheetStatus("OFF", false)
|
||
|
}.openProtectionSettings {
|
||
|
verifyEnhancedTrackingProtectionHeader()
|
||
|
verifyEnhancedTrackingProtectionOptions()
|
||
|
verifyEnhancedTrackingProtectionDefaults()
|
||
|
}
|
||
|
|
||
|
settingsSubMenuEnhancedTrackingProtection {
|
||
|
}.openExceptions {
|
||
|
verifyListedURL(trackingProtectionTest.url.toString())
|
||
|
}.disableExceptions {
|
||
|
verifyDefault()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun testStrictVisitSheetDetails() {
|
||
|
val trackingProtectionTest =
|
||
|
TestAssetHelper.getEnhancedTrackingProtectionAsset(mockWebServer)
|
||
|
|
||
|
navigationToolbar {
|
||
|
}.enterURLAndEnterToBrowser(trackingProtectionTest.url) {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionNotice()
|
||
|
}.closeNotificationPopup {}
|
||
|
|
||
|
enhancedTrackingProtection {
|
||
|
verifyEnhancedTrackingProtectionShield()
|
||
|
}.openEnhancedTrackingProtectionSheet {
|
||
|
verifyEnhancedTrackingProtectionSheetStatus("ON", true)
|
||
|
}.openDetails {
|
||
|
verifyEnhancedTrackingProtectionDetailsStatus("Blocked")
|
||
|
}
|
||
|
}
|
||
|
}
|