For #26224 - Disable the TCP CFR in failing UI tests

This commit is contained in:
Mugurell 2022-08-25 12:50:53 +03:00 committed by mergify[bot]
parent 00d2a9d402
commit b16e69105c
21 changed files with 65 additions and 3 deletions

View File

@ -18,6 +18,7 @@ class FeatureSettingsHelper {
private var isRecentTabsFeatureEnabled: Boolean = settings.showRecentTabsFeature
private var isRecentlyVisitedFeatureEnabled: Boolean = settings.historyMetadataUIFeature
private var isUserKnowsAboutPwasTrue: Boolean = settings.userKnowsAboutPwas
private var isTCPCFREnabled: Boolean = settings.shouldShowTotalCookieProtectionCFR
fun setPocketEnabled(enabled: Boolean) {
settings.showPocketRecommendationsFeature = enabled
@ -47,6 +48,13 @@ class FeatureSettingsHelper {
settings.deleteSitePermissions = delete
}
/**
* Enable or disable showing the TCP CFR when accessing a webpage for the first time.
*/
fun setTCPCFREnabled(shouldShowCFR: Boolean) {
settings.shouldShowTotalCookieProtectionCFR = shouldShowCFR
}
// Important:
// Use this after each test if you have modified these feature settings
// to make sure the app goes back to the default state
@ -56,5 +64,6 @@ class FeatureSettingsHelper {
settings.showRecentTabsFeature = isRecentTabsFeatureEnabled
settings.historyMetadataUIFeature = isRecentlyVisitedFeatureEnabled
settings.userKnowsAboutPwas = isUserKnowsAboutPwasTrue
settings.shouldShowTotalCookieProtectionCFR = isTCPCFREnabled
}
}

View File

@ -39,6 +39,7 @@ class BrowsingErrorPagesTest {
fun setUp() {
// disabling the jump-back-in pop-up that interferes with the tests.
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After

View File

@ -15,6 +15,7 @@ import org.junit.Test
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.RetryTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
@ -47,6 +48,8 @@ class ContextMenusTest {
@JvmField
val retryTestRule = RetryTestRule(3)
private val featureSettingsHelper = FeatureSettingsHelper()
@Before
fun setUp() {
activityIntentTestRule.activity.applicationContext.settings().shouldShowJumpBackInCFR = false
@ -55,11 +58,14 @@ class ContextMenusTest {
dispatcher = AndroidAssetDispatcher()
start()
}
featureSettingsHelper.setTCPCFREnabled(false)
}
@After
fun tearDown() {
mockWebServer.shutdown()
featureSettingsHelper.resetAllFeatureFlags()
}
@SmokeTest

View File

@ -14,6 +14,7 @@ import org.junit.Test
import org.mozilla.fenix.IntentReceiverActivity
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.createCustomTabIntent
@ -43,6 +44,8 @@ class CustomTabsTest {
IntentReceiverActivity::class.java, true, false
)
private val featureSettingsHelper = FeatureSettingsHelper()
@Before
fun setUp() {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
@ -50,11 +53,14 @@ class CustomTabsTest {
dispatcher = AndroidAssetDispatcher()
start()
}
featureSettingsHelper.setTCPCFREnabled(false)
}
@After
fun tearDown() {
mockWebServer.shutdown()
featureSettingsHelper.resetAllFeatureFlags()
}
@SmokeTest

View File

@ -52,6 +52,8 @@ class DownloadFileTypesTest(fileName: String) {
fun setUp() {
// disabling the jump-back-in pop-up that interferes with the tests.
featureSettingsHelper.setJumpBackCFREnabled(false)
// disable the TCP CFR that appears when loading webpages and interferes with the tests.
featureSettingsHelper.setTCPCFREnabled(false)
// disabling the PWA CFR on 3rd visit
featureSettingsHelper.disablePwaCFR(true)
}

View File

@ -66,6 +66,8 @@ class DownloadTest {
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
// disabling the jump-back-in pop-up that interferes with the tests.
featureSettingsHelper.setJumpBackCFREnabled(false)
// disable the TCP CFR that appears when loading webpages and interferes with the tests.
featureSettingsHelper.setTCPCFREnabled(false)
// disabling the PWA CFR on 3rd visit
featureSettingsHelper.disablePwaCFR(true)
// clear all existing notifications

View File

@ -21,6 +21,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper
@ -40,6 +41,7 @@ class HistoryTest {
private lateinit var mDevice: UiDevice
private var historyListIdlingResource: RecyclerViewIdlingResource? = null
private var recentlyClosedTabsListIdlingResource: RecyclerViewIdlingResource? = null
private val featureSettingsHelper = FeatureSettingsHelper()
@get:Rule
val activityTestRule = HomeActivityTestRule()
@ -54,11 +56,14 @@ class HistoryTest {
dispatcher = AndroidAssetDispatcher()
start()
}
featureSettingsHelper.setTCPCFREnabled(false)
}
@After
fun tearDown() {
mockWebServer.shutdown()
featureSettingsHelper.resetAllFeatureFlags()
// Clearing all history data after each test to avoid overlapping data
val applicationContext: Context = activityTestRule.activity.applicationContext
val historyStorage = PlacesHistoryStorage(applicationContext)

View File

@ -11,8 +11,8 @@ import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.ui.robots.navigationToolbar
@ -34,6 +34,7 @@ class NavigationToolbarTest {
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
@get:Rule
val activityTestRule = HomeActivityTestRule()
private val featureSettingsHelper = FeatureSettingsHelper()
@Before
fun setUp() {
@ -42,13 +43,14 @@ class NavigationToolbarTest {
dispatcher = AndroidAssetDispatcher()
start()
}
val settings = activityTestRule.activity.settings()
settings.shouldShowJumpBackInCFR = false
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After
fun tearDown() {
mockWebServer.shutdown()
featureSettingsHelper.resetAllFeatureFlags()
}
@Test

View File

@ -7,11 +7,13 @@ package org.mozilla.fenix.ui
import androidx.core.net.toUri
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestHelper.setNetworkEnabled
@ -30,10 +32,18 @@ class NoNetworkAccessStartupTests {
@get:Rule
val activityTestRule = HomeActivityTestRule(launchActivity = false)
private val featureSettingsHelper = FeatureSettingsHelper()
@Before
fun setUp() {
featureSettingsHelper.setTCPCFREnabled(false)
}
@After
fun tearDown() {
// Restoring network connection
setNetworkEnabled(true)
featureSettingsHelper.resetAllFeatureFlags()
}
@Test

View File

@ -31,6 +31,7 @@ class PwaTest {
@Before
fun setUp() {
featureSettingsHelper.disablePwaCFR(true)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After

View File

@ -64,6 +64,7 @@ class SearchTest {
start()
}
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
featureSettingsHelper.setPocketEnabled(false)
}

View File

@ -15,6 +15,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.FeatureSettingsHelper
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper.getEnhancedTrackingProtectionAsset
@ -32,6 +33,7 @@ class SettingsAddonsTest {
private lateinit var mockWebServer: MockWebServer
private var addonsListIdlingResource: RecyclerViewIdlingResource? = null
private var addonContainerIdlingResource: ViewVisibilityIdlingResource? = null
private val featureSettingsHelper = FeatureSettingsHelper()
@get:Rule
val activityTestRule = HomeActivityIntentTestRule()
@ -42,6 +44,8 @@ class SettingsAddonsTest {
dispatcher = AndroidAssetDispatcher()
start()
}
featureSettingsHelper.setTCPCFREnabled(false)
}
@After
@ -55,6 +59,8 @@ class SettingsAddonsTest {
if (addonContainerIdlingResource != null) {
IdlingRegistry.getInstance().unregister(addonContainerIdlingResource!!)
}
featureSettingsHelper.resetAllFeatureFlags()
}
// Walks through settings add-ons menu to ensure all items are present

View File

@ -44,6 +44,7 @@ class SettingsAdvancedTest {
start()
}
featureSettingsHelper.setPocketEnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After

View File

@ -55,6 +55,7 @@ class SettingsBasicsTest {
}
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After

View File

@ -43,6 +43,7 @@ class SettingsHomepageTest {
start()
}
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After

View File

@ -58,6 +58,7 @@ class SettingsPrivacyTest {
}
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
featureSettingsHelper.disablePwaCFR(true)
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
@ -70,6 +71,7 @@ class SettingsPrivacyTest {
@After
fun tearDown() {
mockWebServer.shutdown()
featureSettingsHelper.resetAllFeatureFlags()
}
@Test

View File

@ -58,6 +58,7 @@ class SitePermissionsTest {
fun setUp() {
// disabling the new homepage pop-up that interferes with the tests.
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
featureSettingsHelper.deleteSitePermissions(true)
featureSettingsHelper.disablePwaCFR(true)
}

View File

@ -96,6 +96,7 @@ class SmokeTest {
// disabling the new homepage pop-up that interferes with the tests.
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mockWebServer = MockWebServer().apply {
@ -708,6 +709,7 @@ class SmokeTest {
// Test running on beta/release builds in CI:
// caution when making changes to it, so they don't block the builds
fun noHistoryInPrivateBrowsingTest() {
FeatureSettingsHelper().setTCPCFREnabled(false)
val website = TestAssetHelper.getGenericAsset(mockWebServer, 1)
homeScreen {

View File

@ -48,6 +48,7 @@ class StrictEnhancedTrackingProtectionTest {
}
featureSettingsHelper.setStrictETPEnabled()
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After

View File

@ -57,6 +57,7 @@ class TabbedBrowsingTest {
fun setUp() {
// disabling the new homepage pop-up that interferes with the tests.
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
mockWebServer = MockWebServer().apply {

View File

@ -53,6 +53,7 @@ class TopSitesTest {
}
featureSettingsHelper.setJumpBackCFREnabled(false)
featureSettingsHelper.setTCPCFREnabled(false)
}
@After