Bug 1933939 - Integrate changed API of Glean v63.0.0 r=android-reviewers,chutten,pollymce,afranchuk

This also standardizes on using the defined "test-ping" for metrics in tests.

Differential Revision: https://phabricator.services.mozilla.com/D230527
This commit is contained in:
Jan-Erik Rediger
2024-12-13 13:50:28 +00:00
parent d98ae58c1c
commit 83ad41fdd6
108 changed files with 557 additions and 277 deletions

View File

@@ -34,7 +34,6 @@ protocolhandler.mailto:
- set_local_default
- dismiss_local_default
send_in_pings:
- active
- metrics
handler_prompt_shown:
@@ -53,5 +52,4 @@ protocolhandler.mailto:
- os_default
- fx_default
send_in_pings:
- active
- metrics

View File

@@ -97,6 +97,8 @@ add_task(async function toolbarButtons() {
Services.telemetry.getSnapshotForKeyedScalars("main", true);
Services.fog.testResetFOG();
// We want to record events into this ping, so it has to be enabled.
GleanPings.prototypeNoCodeEvents.setEnabled(true);
let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
let tabClose = BrowserTestUtils.waitForTabClosing(newTab);

View File

@@ -7,6 +7,7 @@ package mozilla.components.lib.crash.service
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.work.testing.WorkManagerTestInitHelper
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
@@ -16,12 +17,15 @@ import mozilla.components.concept.base.crash.Breadcrumb
import mozilla.components.lib.crash.Crash
import mozilla.components.lib.crash.GleanMetrics.CrashMetrics
import mozilla.components.support.test.whenever
import mozilla.telemetry.glean.testing.GleanTestRule
import mozilla.telemetry.glean.Glean
import mozilla.telemetry.glean.config.Configuration
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
@@ -41,8 +45,25 @@ class GleanCrashReporterServiceTest {
private val context: Context
get() = ApplicationProvider.getApplicationContext()
@get:Rule
val gleanRule = GleanTestRule(context)
@Before
fun setUp() {
// We're using the WorkManager in a bunch of places, and Glean will crash
// in tests without this line. Let's simply put it here.
WorkManagerTestInitHelper.initializeTestWorkManager(context)
Glean.registerPings(GleanPings)
Glean.resetGlean(
context = context,
config = Configuration(),
clearStores = true,
)
}
@After
fun tearDown() {
// This closes the database to help prevent leaking it during tests.
// See Bug1719905 for more info.
WorkManagerTestInitHelper.closeWorkDatabase()
}
@get:Rule
val tempFolder = TemporaryFolder()

View File

@@ -19,3 +19,14 @@ sample:
- N/A
notification_emails:
- CHANGE-ME@example.com
test-string-list:
description: |
A test custom ping.
include_client_id: true
bugs:
- https://bugzilla.mozilla.org/123456789
data_reviews:
- N/A
notification_emails:
- CHANGE-ME@example.com

View File

@@ -13,6 +13,7 @@ import mozilla.telemetry.glean.config.Configuration
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.GleanMetrics.GleanBuildInfo
import org.mozilla.fenix.GleanMetrics.Pings
import org.mozilla.fenix.ext.getCustomGleanServerUrlIfAvailable
import org.mozilla.fenix.ext.setCustomEndpointIfAvailable
import org.mozilla.fenix.nimbus.FxNimbus
@@ -48,6 +49,11 @@ fun initializeGlean(applicationContext: Context, logger: Logger, isTelemetryUplo
pingSchedule = mapOf("baseline" to listOf("usage-reporting")),
)
// Since Glean v63.0.0, custom pings need to be registered prior to Glean init
// in order to ensure they are enabled and able to collect data.
// See https://bugzilla.mozilla.org/1934931 for more information.
Glean.registerPings(Pings)
// Set the metric configuration from Nimbus.
Glean.applyServerKnobsConfig(FxNimbus.features.glean.value().metricsEnabled.toString())

View File

@@ -79,7 +79,7 @@ class GleanMetricsService(
override fun start() {
logger.debug("Enabling Glean.")
// Initialization of Glean already happened in FenixApplication.
Glean.setUploadEnabled(true)
Glean.setCollectionEnabled(true)
if (initialized) return
initialized = true
@@ -101,7 +101,7 @@ class GleanMetricsService(
}
override fun stop() {
Glean.setUploadEnabled(false)
Glean.setCollectionEnabled(false)
unsetUsageProfileId()
}

View File

@@ -14,7 +14,6 @@ import mozilla.components.browser.errorpages.ErrorPages
import mozilla.components.browser.errorpages.ErrorType
import mozilla.components.concept.engine.request.RequestInterceptor
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Rule
@@ -25,13 +24,14 @@ import org.mozilla.fenix.AppRequestInterceptor.Companion.LOW_AND_MEDIUM_RISK_ERR
import org.mozilla.fenix.GleanMetrics.ErrorPage
import org.mozilla.fenix.ext.isOnline
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
class AppRequestInterceptorTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var interceptor: RequestInterceptor
private lateinit var navigationController: NavController

View File

@@ -20,7 +20,6 @@ import mozilla.components.concept.engine.webextension.WebExtension
import mozilla.components.feature.addons.migration.DefaultSupportedAddonsChecker
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.utils.BrowsersCache
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -36,6 +35,7 @@ import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
import org.mozilla.fenix.GleanMetrics.TopSites
import org.mozilla.fenix.components.metrics.MozillaProductDetector
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
import org.robolectric.Shadows.shadowOf
@@ -44,7 +44,7 @@ import org.robolectric.annotation.Config
@RunWith(FenixRobolectricTestRunner::class)
class FenixApplicationTest {
@get:Rule val gleanTestRule = GleanTestRule(ApplicationProvider.getApplicationContext())
@get:Rule val gleanTestRule = FenixGleanTestRule(ApplicationProvider.getApplicationContext())
private lateinit var application: FenixApplication
private lateinit var browsersCache: BrowsersCache

View File

@@ -16,7 +16,6 @@ import io.mockk.spyk
import io.mockk.verify
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.utils.toSafeIntent
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotEquals
@@ -34,6 +33,7 @@ import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getIntentSource
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.systemGesturesInsets
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.helpers.perf.TestStrictModeManager
import org.mozilla.fenix.utils.Settings
@@ -41,7 +41,7 @@ import org.mozilla.fenix.utils.Settings
@RunWith(FenixRobolectricTestRunner::class)
class HomeActivityTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var activity: HomeActivity

View File

@@ -21,7 +21,6 @@ import io.mockk.verify
import kotlinx.coroutines.test.runTest
import mozilla.components.feature.intent.processing.IntentProcessor
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@@ -37,6 +36,7 @@ import org.mozilla.fenix.components.IntentProcessors
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.helpers.perf.TestStrictModeManager
import org.mozilla.fenix.shortcut.NewTabShortcutIntentProcessor
@@ -52,7 +52,7 @@ class IntentReceiverActivityTest {
private lateinit var intentProcessors: IntentProcessors
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setup() {

View File

@@ -19,7 +19,6 @@ import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.service.nimbus.NimbusApi
import mozilla.components.support.base.observer.ObserverRegistry
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Rule
@@ -27,6 +26,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.SyncAuth
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
@@ -35,7 +35,7 @@ import org.mozilla.fenix.utils.Settings
class BackgroundServicesTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@MockK
private lateinit var context: Context

View File

@@ -8,7 +8,6 @@ import com.google.android.play.core.review.ReviewManager
import com.google.android.play.core.review.ReviewManagerFactory
import kotlinx.coroutines.test.runTest
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
@@ -19,6 +18,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.ReviewPrompt
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import java.text.SimpleDateFormat
import java.util.Date
@@ -37,7 +37,7 @@ class TestReviewSettings(
class ReviewPromptControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var reviewManager: ReviewManager

View File

@@ -13,7 +13,6 @@ import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.internal.CounterMetric
import mozilla.telemetry.glean.private.EventMetricType
import mozilla.telemetry.glean.private.NoExtras
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -32,12 +31,13 @@ import org.mozilla.fenix.components.menu.store.BrowserMenuState
import org.mozilla.fenix.components.menu.store.MenuAction
import org.mozilla.fenix.components.menu.store.MenuState
import org.mozilla.fenix.components.menu.store.MenuStore
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class MenuTelemetryMiddlewareTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Test
fun `WHEN adding a bookmark THEN record the bookmark browser menu telemetry`() {

View File

@@ -7,7 +7,6 @@ package org.mozilla.fenix.components.metrics
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
@@ -17,6 +16,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.MetaAttribution
import org.mozilla.fenix.GleanMetrics.PlayStoreAttribution
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.utils.Settings
import org.robolectric.RobolectricTestRunner
@@ -25,7 +25,7 @@ internal class InstallReferrerMetricsServiceTest {
val context: Context = ApplicationProvider.getApplicationContext()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Test
fun `WHEN retrieving minimum UTM params from setting THEN result should match`() {

View File

@@ -34,7 +34,6 @@ import mozilla.components.support.base.facts.Fact
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.webextensions.facts.WebExtensionFacts
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -55,6 +54,7 @@ import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp
import org.mozilla.fenix.GleanMetrics.SitePermissions
import org.mozilla.fenix.GleanMetrics.SyncedTabs
import org.mozilla.fenix.components.metrics.ReleaseMetricController.Companion
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.search.awesomebar.ShortcutsSuggestionProvider
import org.mozilla.fenix.utils.Settings
@@ -64,7 +64,7 @@ import mozilla.components.compose.browser.awesomebar.AwesomeBarFacts as ComposeA
class MetricControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@MockK(relaxUnitFun = true)
private lateinit var dataService1: MetricsService

View File

@@ -28,7 +28,6 @@ import mozilla.components.concept.engine.EngineSession
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.After
import org.junit.Assert.assertNotNull
import org.junit.Before
@@ -38,6 +37,7 @@ import org.junit.runner.RunWith
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.tabstrip.isTabStripEnabled
import org.mozilla.fenix.ext.isLargeWindow
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
@@ -47,7 +47,7 @@ class BrowserToolbarCFRPresenterTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setup() {

View File

@@ -51,7 +51,6 @@ import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@@ -80,6 +79,7 @@ import org.mozilla.fenix.components.appstate.AppAction.ShortcutAction
import org.mozilla.fenix.compose.snackbar.Snackbar
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.directionsEq
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.deletebrowsingdata.deleteAndQuit
import org.mozilla.fenix.utils.Settings
@@ -91,7 +91,7 @@ class DefaultBrowserToolbarMenuControllerTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@MockK private lateinit var snackbarParent: ViewGroup

View File

@@ -12,13 +12,13 @@ import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.put
import kotlinx.serialization.json.putJsonObject
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.experiments.nimbus.internal.validateEventQueries
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.GleanMetrics.NimbusSystem as GleanNimbus
@@ -26,7 +26,7 @@ import org.mozilla.fenix.GleanMetrics.NimbusSystem as GleanNimbus
class RecordedNimbusContextTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Test
fun `GIVEN a nimbusApi object WHEN recorded context with eventQueries is supplied THEN the event queries must be valid`() {

View File

@@ -0,0 +1,82 @@
/* 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.helpers
import android.content.Context
import androidx.annotation.VisibleForTesting
import androidx.work.testing.WorkManagerTestInitHelper
import mozilla.telemetry.glean.Glean
import mozilla.telemetry.glean.config.Configuration
import org.junit.rules.TestWatcher
import org.junit.runner.Description
import org.mozilla.fenix.GleanMetrics.Pings
/**
* This implements a JUnit rule for writing tests for Glean SDK metrics.
*
* The rule takes care of resetting the Glean SDK between tests and
* initializing all the required dependencies.
*
* Example usage:
*
* ```
* // Add the following lines to you test class.
* @get:Rule
* val gleanRule = GleanTestRule(ApplicationProvider.getApplicationContext())
* ```
*
* @param context the application context
* @param configToUse an optional [Configuration] to initialize the Glean SDK with
*/
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
class FenixGleanTestRule(
val context: Context,
val configToUse: Configuration = Configuration(),
) : TestWatcher() {
/**
* Invoked when a test is about to start.
*/
override fun starting(description: Description?) {
// We're using the WorkManager in a bunch of places, and Glean will crash
// in tests without this line. Let's simply put it here.
WorkManagerTestInitHelper.initializeTestWorkManager(context)
/**
* Always skip the first metrics ping, which would otherwise be overdue.
* Tests should explicitly destroy Glean and recreate it to test the metrics ping scheduler.
* This is the same as `delayMetricsPing` from `TestUtils.kt`,
* but now part of the publicly available test rule.
*/
// // Set the current system time to a known datetime.
// val fakeNow = Calendar.getInstance()
// fakeNow.clear()
// @Suppress("MagicNumber") // it's a fixed date only used in tests.
// fakeNow.set(2015, 6, 11, 2, 0, 0)
// SystemClock.setCurrentTimeMillis(fakeNow.timeInMillis)
//
// // Set the last sent date to yesterday.
// val buildInfo = BuildInfo(versionCode = "0.0.1", versionName = "0.0.1", buildDate = Calendar.getInstance())
// val mps = MetricsPingScheduler(context, buildInfo)
//
// mps.updateSentDate(getISOTimeString(fakeNow, truncateTo = TimeUnit.DAY))
Glean.registerPings(Pings)
Glean.resetGlean(
context = context,
config = configToUse,
clearStores = true,
)
}
override fun finished(description: Description?) {
// This closes the database to help prevent leaking it during tests.
// See Bug1719905 for more info.
WorkManagerTestInitHelper.closeWorkDatabase()
super.finished(description)
}
}

View File

@@ -34,7 +34,6 @@ import mozilla.components.service.nimbus.messaging.Message
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
@@ -62,6 +61,7 @@ import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.components.appstate.AppState
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.bookmarks.Bookmark
import org.mozilla.fenix.home.recenttabs.RecentTab
@@ -82,7 +82,7 @@ class DefaultSessionControlControllerTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val activity: HomeActivity = mockk(relaxed = true)
private val filesDir: File = mockk(relaxed = true)

View File

@@ -13,7 +13,6 @@ import io.mockk.verify
import mozilla.appservices.places.BookmarkRoot
import mozilla.components.browser.menu.view.MenuButton
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -29,6 +28,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.accounts.AccountState
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.whatsnew.WhatsNew
@@ -39,7 +39,7 @@ import org.mozilla.fenix.GleanMetrics.HomeMenu as HomeMenuMetrics
class HomeMenuViewTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var view: View
private lateinit var lifecycleOwner: LifecycleOwner

View File

@@ -17,7 +17,6 @@ import mozilla.components.browser.state.state.createTab
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.ui.tabcounter.TabCounter
import mozilla.components.ui.tabcounter.TabCounterMenu
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -33,6 +32,7 @@ import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager
import org.mozilla.fenix.browser.browsingmode.DefaultBrowsingModeManager
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
@@ -40,7 +40,7 @@ import org.mozilla.fenix.utils.Settings
class TabCounterViewTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var navController: NavController
private lateinit var browsingModeManager: BrowsingModeManager

View File

@@ -20,7 +20,6 @@ import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Before
@@ -31,6 +30,7 @@ import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.GleanMetrics.HomeBookmarks
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.HomeFragmentDirections
import org.mozilla.fenix.home.bookmarks.controller.DefaultBookmarksController
@@ -39,7 +39,7 @@ import org.mozilla.fenix.home.bookmarks.controller.DefaultBookmarksController
class DefaultBookmarksControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val coroutinesTestRule = MainCoroutineRule()

View File

@@ -12,7 +12,6 @@ import io.mockk.mockk
import io.mockk.verify
import mozilla.components.concept.engine.EngineSession
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -24,6 +23,7 @@ import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.onboarding.ReEngagementNotificationWorker
import org.mozilla.fenix.utils.Settings
@@ -32,7 +32,7 @@ import org.mozilla.fenix.utils.Settings
class ReEngagementIntentProcessorTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Test
fun `do not process blank intents`() {

View File

@@ -11,7 +11,6 @@ import io.mockk.Called
import io.mockk.mockk
import io.mockk.verify
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Rule
@@ -23,13 +22,14 @@ import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
class StartSearchIntentProcessorTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val navController: NavController = mockk(relaxed = true)
private val out: Intent = mockk(relaxed = true)

View File

@@ -16,7 +16,6 @@ import mozilla.components.service.pocket.PocketStory.PocketRecommendedStory
import mozilla.components.service.pocket.PocketStory.PocketSponsoredStory
import mozilla.components.service.pocket.ext.getCurrentFlightImpressions
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -35,6 +34,7 @@ import org.mozilla.fenix.components.appstate.AppState
import org.mozilla.fenix.components.appstate.recommendations.ContentRecommendationsState
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.pocket.controller.DefaultPocketStoriesController
import org.mozilla.fenix.utils.Settings
@@ -43,7 +43,7 @@ import org.mozilla.fenix.utils.Settings
class DefaultPocketStoriesControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val homeActivity: HomeActivity = mockk(relaxed = true)
private val settings: Settings = mockk(relaxed = true)

View File

@@ -38,7 +38,6 @@ import mozilla.components.service.fxa.sync.SyncReason
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.internal.ErrorType
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -49,12 +48,13 @@ import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.RecentSyncedTabs
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.helpers.FenixGleanTestRule
@RunWith(AndroidJUnit4::class)
class RecentSyncedTabFeatureTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val earliestTime = 100L
private val earlierTime = 250L

View File

@@ -20,7 +20,6 @@ import mozilla.components.concept.sync.DeviceType
import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Before
@@ -31,6 +30,7 @@ import org.mozilla.fenix.GleanMetrics.RecentSyncedTabs
import org.mozilla.fenix.R
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.home.HomeFragmentDirections
import org.mozilla.fenix.home.recentsyncedtabs.RecentSyncedTab
import org.mozilla.fenix.tabstray.Page
@@ -40,7 +40,7 @@ import org.mozilla.fenix.tabstray.TabsTrayAccessPoint
class DefaultRecentSyncedTabControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val tabsUseCases: TabsUseCases = mockk()
private val navController: NavController = mockk()

View File

@@ -20,7 +20,6 @@ import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Before
@@ -30,6 +29,7 @@ import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.RecentTabs
import org.mozilla.fenix.R
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@OptIn(ExperimentalCoroutinesApi::class)
@@ -40,7 +40,7 @@ class RecentTabControllerTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val navController: NavController = mockk(relaxed = true)
private val selectTabUseCase: TabsUseCases = mockk(relaxed = true)

View File

@@ -25,7 +25,6 @@ import mozilla.components.feature.tabs.TabsUseCases.SelectOrAddUseCase
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Before
@@ -36,6 +35,7 @@ import org.mozilla.fenix.GleanMetrics.RecentSearches
import org.mozilla.fenix.R
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.HomeFragmentDirections
import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryGroup
@@ -46,7 +46,7 @@ import org.mozilla.fenix.home.recentvisits.RecentlyVisitedItem.RecentHistoryHigh
class RecentVisitsControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val coroutinesTestRule = MainCoroutineRule()

View File

@@ -15,7 +15,6 @@ import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.state.SearchState
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -28,6 +27,7 @@ import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
@@ -35,7 +35,7 @@ import org.mozilla.fenix.utils.Settings
class DefaultToolbarControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val activity: HomeActivity = mockk(relaxed = true)
private val navController: NavController = mockk(relaxed = true)

View File

@@ -12,7 +12,6 @@ import io.mockk.verify
import mozilla.components.browser.icons.BrowserIcons
import mozilla.components.feature.top.sites.TopSite
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -26,6 +25,7 @@ import org.mozilla.fenix.GleanMetrics.TopSites
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.databinding.TopSiteItemBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.sessioncontrol.TopSiteInteractor
@@ -33,7 +33,7 @@ import org.mozilla.fenix.home.sessioncontrol.TopSiteInteractor
class TopSiteItemViewHolderTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var binding: TopSiteItemBinding
private lateinit var interactor: TopSiteInteractor

View File

@@ -9,7 +9,6 @@ import io.mockk.verify
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -19,6 +18,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@SuppressWarnings("TooManyFunctions", "LargeClass")
@@ -26,7 +26,7 @@ import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
class BookmarkFragmentInteractorTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var interactor: BookmarkFragmentInteractor

View File

@@ -6,12 +6,12 @@ package org.mozilla.fenix.library.history.state
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.library.history.History
import org.mozilla.fenix.library.history.HistoryFragmentAction
import org.mozilla.fenix.library.history.HistoryFragmentState
@@ -24,7 +24,7 @@ import org.mozilla.fenix.GleanMetrics.History as GleanHistory
@RunWith(RobolectricTestRunner::class)
class HistoryTelemetryMiddlewareTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val middleware = HistoryTelemetryMiddleware(isInPrivateMode = false)

View File

@@ -20,7 +20,6 @@ import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
@@ -35,6 +34,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.directionsEq
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.library.history.History
import org.mozilla.fenix.library.history.HistoryItemTimeGroup
@@ -47,7 +47,7 @@ import org.mozilla.fenix.GleanMetrics.History as GleanHistory
class HistoryMetadataGroupControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val coroutinesTestRule = MainCoroutineRule()

View File

@@ -24,7 +24,6 @@ import mozilla.components.concept.engine.prompt.ShareData
import mozilla.components.feature.recentlyclosed.RecentlyClosedTabsStorage
import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -38,6 +37,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.ext.directionsEq
import org.mozilla.fenix.ext.optionsEq
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
@@ -49,7 +49,7 @@ class DefaultRecentlyClosedControllerTest {
private val tabsUseCases: TabsUseCases = mockk(relaxed = true)
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setUp() {

View File

@@ -9,18 +9,18 @@ import io.mockk.mockk
import io.mockk.verifySequence
import mozilla.components.browser.state.action.AppLifecycleAction
import mozilla.components.browser.state.store.BrowserStore
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
class StoreLifecycleObserverTest {
@get:Rule
val gleanRule = GleanTestRule(ApplicationProvider.getApplicationContext())
val gleanRule = FenixGleanTestRule(ApplicationProvider.getApplicationContext())
@Test
fun `WHEN onPause is called THEN dispatch PauseAction`() {

View File

@@ -12,7 +12,6 @@ import mozilla.components.service.nimbus.messaging.Message
import mozilla.components.service.nimbus.messaging.MessageData
import mozilla.components.service.nimbus.messaging.NimbusMessagingControllerInterface
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -21,13 +20,14 @@ import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.components.appstate.AppAction.MessagingAction.MessageClicked
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
class DefaultMessageControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val homeActivity: HomeActivity = mockk(relaxed = true)
private val messagingController: NimbusMessagingControllerInterface = mockk(relaxed = true)

View File

@@ -8,7 +8,6 @@ import io.mockk.mockk
import io.mockk.verify
import mozilla.components.service.nimbus.messaging.Message
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -23,6 +22,7 @@ import org.mozilla.fenix.components.appstate.AppAction.MessagingAction.Microsurv
import org.mozilla.fenix.components.appstate.AppAction.MessagingAction.MicrosurveyAction.OnPrivacyNoticeTapped
import org.mozilla.fenix.components.appstate.AppAction.MessagingAction.MicrosurveyAction.SentConfirmationShown
import org.mozilla.fenix.components.appstate.AppAction.MessagingAction.MicrosurveyAction.Shown
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.SupportUtils
@@ -34,7 +34,7 @@ private val PRIVACY_POLICY_URL =
class MicrosurveyMessageControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val homeActivity: HomeActivity = mockk(relaxed = true)
private val message: Message = mockk(relaxed = true)

View File

@@ -17,7 +17,6 @@ import mozilla.components.support.ktx.kotlin.crossProduct
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Before
@@ -26,6 +25,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.PerfStartup
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.perf.StartupPathProvider.StartupPath
import org.mozilla.fenix.perf.StartupStateProvider.StartupState
@@ -45,7 +45,7 @@ class StartupTypeTelemetryTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private lateinit var telemetry: StartupTypeTelemetry
private lateinit var callbacks: StartupTypeTelemetry.StartupTypeLifecycleObserver

View File

@@ -12,13 +12,13 @@ import io.mockk.MockKAnnotations
import io.mockk.every
import io.mockk.impl.annotations.RelaxedMockK
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.GleanMetrics.StorageStats as Metrics
@@ -26,7 +26,7 @@ import org.mozilla.fenix.GleanMetrics.StorageStats as Metrics
class StorageStatsMetricsTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@RelaxedMockK private lateinit var mockContext: Context

View File

@@ -29,7 +29,6 @@ import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.middleware.CaptureActionsMiddleware
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -49,6 +48,7 @@ import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.Core
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.search.SearchDialogFragmentDirections.Companion.actionGlobalAddonsManagementFragment
import org.mozilla.fenix.search.SearchDialogFragmentDirections.Companion.actionGlobalSearchEngineFragment
@@ -77,7 +77,7 @@ class SearchDialogControllerTest {
private lateinit var browserStore: BrowserStore
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setUp() {

View File

@@ -25,7 +25,6 @@ import mozilla.components.concept.menu.Orientation
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
@@ -38,6 +37,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.search.SearchDialogFragmentStore
import org.mozilla.fenix.search.SearchEngineSource
@@ -62,7 +62,7 @@ class SearchSelectorToolbarActionTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setup() {

View File

@@ -15,7 +15,6 @@ import mozilla.components.browser.state.search.RegionState
import mozilla.components.concept.storage.Address
import mozilla.components.concept.storage.UpdatableAddressFields
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertNotNull
@@ -27,6 +26,7 @@ import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Addresses
import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.FragmentAddressEditorBinding
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.address.interactor.AddressEditorInteractor
import org.mozilla.fenix.settings.address.view.AddressEditorView
@@ -41,7 +41,7 @@ class AddressEditorViewTest {
private lateinit var address: Address
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setup() {

View File

@@ -19,7 +19,6 @@ import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.components.support.utils.CreditCardNetworkType
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Before
@@ -27,6 +26,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.CreditCards
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.creditcards.controller.DefaultCreditCardEditorController
@@ -34,7 +34,7 @@ import org.mozilla.fenix.settings.creditcards.controller.DefaultCreditCardEditor
class DefaultCreditCardEditorControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val storage: AutofillCreditCardsAddressesStorage = mockk(relaxed = true)
private val navController: NavController = mockk(relaxed = true)

View File

@@ -8,7 +8,6 @@ import io.mockk.mockk
import io.mockk.verify
import mozilla.components.concept.storage.CreditCard
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Before
@@ -16,6 +15,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.CreditCards
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.creditcards.controller.CreditCardsManagementController
import org.mozilla.fenix.settings.creditcards.interactor.DefaultCreditCardsManagementInteractor
@@ -24,7 +24,7 @@ import org.mozilla.fenix.settings.creditcards.interactor.DefaultCreditCardsManag
class DefaultCreditCardsManagementInteractorTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val controller: CreditCardsManagementController = mockk(relaxed = true)

View File

@@ -8,7 +8,6 @@ import androidx.navigation.NavController
import io.mockk.mockk
import io.mockk.verifyAll
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -17,6 +16,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.GleanMetrics.Logins
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.settings.logins.controller.LoginsListController
@@ -26,7 +26,7 @@ import org.mozilla.fenix.utils.Settings
@RunWith(FenixRobolectricTestRunner::class)
class LoginsListControllerTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
private val store: LoginsFragmentStore = mockk(relaxed = true)
private val settings: Settings = mockk(relaxed = true)

View File

@@ -28,7 +28,6 @@ import mozilla.components.feature.session.TrackingProtectionUseCases
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@@ -44,6 +43,7 @@ import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.components.PermissionStorage
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.directionsEq
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.settings.PhoneFeature
import org.mozilla.fenix.settings.quicksettings.ext.shouldBeEnabled
@@ -85,7 +85,7 @@ class DefaultQuickSettingsControllerTest {
private lateinit var controller: DefaultQuickSettingsController
@get:Rule
val gleanRule = GleanTestRule(testContext)
val gleanRule = FenixGleanTestRule(testContext)
@get:Rule
val coroutinesTestRule = MainCoroutineRule()

View File

@@ -34,7 +34,6 @@ import mozilla.components.lib.publicsuffixlist.PublicSuffixList
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -46,6 +45,7 @@ import org.mozilla.fenix.GleanMetrics.CookieBanners
import org.mozilla.fenix.GleanMetrics.Pings
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.trackingprotection.CookieBannerUIMode
import org.mozilla.fenix.trackingprotection.ProtectionsAction
@@ -93,7 +93,7 @@ internal class DefaultCookieBannerDetailsControllerTest {
private val scope = coroutinesTestRule.scope
@get:Rule
val gleanRule = GleanTestRule(testContext)
val gleanRule = FenixGleanTestRule(testContext)
@Before
fun setUp() {

View File

@@ -6,13 +6,13 @@ package org.mozilla.fenix.settings.trustpanel
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.settings.trustpanel.middleware.TrustPanelTelemetryMiddleware
import org.mozilla.fenix.settings.trustpanel.store.TrustPanelAction
import org.mozilla.fenix.settings.trustpanel.store.TrustPanelState
@@ -23,7 +23,7 @@ import org.robolectric.RobolectricTestRunner
class TrustPanelTelemetryMiddlewareTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Test
fun `GIVEN tracking protection is enabled WHEN toggle tracking protection action is dispatched THEN record tracking protection exception added telemetry`() {

View File

@@ -18,7 +18,6 @@ import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Before
@@ -32,6 +31,7 @@ import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.recordEventInNimbus
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.geckoview.GeckoSession
import java.io.IOException
@@ -41,7 +41,7 @@ class SaveToPDFMiddlewareTest {
private lateinit var appStore: AppStore
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val mainCoroutineTestRule = MainCoroutineRule()

View File

@@ -29,7 +29,6 @@ import mozilla.components.feature.share.RecentAppsStorage
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -44,6 +43,7 @@ import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.components.appstate.AppAction.ShareAction
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.share.listadapters.AppShareOption
@@ -72,7 +72,7 @@ class ShareControllerTest {
private val recentAppStorage = mockk<RecentAppsStorage>(relaxed = true)
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val coroutinesTestRule = MainCoroutineRule()

View File

@@ -16,7 +16,6 @@ import mozilla.components.concept.engine.shopping.ProductAnalysis
import mozilla.components.concept.engine.shopping.ProductRecommendation
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -24,6 +23,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Shopping
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.shopping.ProductAnalysisTestData
import org.mozilla.fenix.shopping.ProductRecommendationTestData
@@ -35,7 +35,7 @@ class DefaultReviewQualityCheckServiceTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Test
fun `GIVEN fetch is called WHEN onResult is invoked with the expected type THEN product analysis returns the same data`() =

View File

@@ -12,7 +12,6 @@ import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -24,6 +23,7 @@ import org.mozilla.fenix.GleanMetrics.Shopping
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppState
import org.mozilla.fenix.components.appstate.shopping.ShoppingState
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.shopping.ProductAnalysisTestData
import org.mozilla.fenix.shopping.fake.FakeReviewQualityCheckTelemetryService
@@ -38,7 +38,7 @@ import org.mozilla.fenix.shopping.store.ReviewQualityCheckStore
class ReviewQualityCheckTelemetryMiddlewareTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val coroutinesTestRule = MainCoroutineRule()

View File

@@ -44,7 +44,6 @@ import mozilla.components.support.test.middleware.CaptureActionsMiddleware
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.components.support.test.rule.runTestOnMain
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotEquals
@@ -72,6 +71,7 @@ import org.mozilla.fenix.components.TabCollectionStorage
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.ext.maxActiveTime
import org.mozilla.fenix.ext.potentialInactiveTabs
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.HomeFragment
import org.mozilla.fenix.utils.Settings
@@ -113,7 +113,7 @@ class DefaultTabsTrayControllerTest {
private val coroutinesTestRule: MainCoroutineRule = MainCoroutineRule()
private val testDispatcher = coroutinesTestRule.testDispatcher
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val chain: RuleChain = RuleChain.outerRule(gleanTestRule).around(coroutinesTestRule)

View File

@@ -21,7 +21,6 @@ import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.service.fxa.manager.FxaAccountManager
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
@@ -33,6 +32,7 @@ import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.TabsTray
import org.mozilla.fenix.components.accounts.FenixFxAEntryPoint
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import mozilla.components.browser.state.state.createTab as createStateTab
@@ -44,7 +44,7 @@ class NavigationInteractorTest {
private val accountManager: FxaAccountManager = mockk(relaxed = true)
val coroutinesTestRule: MainCoroutineRule = MainCoroutineRule()
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@get:Rule
val chain: RuleChain = RuleChain.outerRule(gleanTestRule).around(coroutinesTestRule)

View File

@@ -34,7 +34,6 @@ import mozilla.components.browser.state.state.ContentState
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
@@ -52,6 +51,7 @@ import org.mozilla.fenix.databinding.ComponentTabstrayFabBinding
import org.mozilla.fenix.databinding.FragmentTabTrayDialogBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.helpers.MockkRetryTestRule
import org.mozilla.fenix.home.HomeScreenViewModel
@@ -71,7 +71,7 @@ class TabsTrayFragmentTest {
val mockkRule = MockkRetryTestRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setup() {

View File

@@ -7,7 +7,6 @@ package org.mozilla.fenix.tabstray
import io.mockk.mockk
import mozilla.components.support.test.libstate.ext.waitUntilIdle
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -17,6 +16,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.TabsTray
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class) // for gleanTestRule
@@ -26,7 +26,7 @@ class TabsTrayTelemetryMiddlewareTest {
private lateinit var tabsTrayTelemetryMiddleware: TabsTrayTelemetryMiddleware
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
@Before
fun setup() {

View File

@@ -19,7 +19,6 @@ import mozilla.components.concept.base.images.ImageLoader
import mozilla.components.concept.engine.mediasession.MediaSession
import mozilla.components.lib.publicsuffixlist.PublicSuffixList
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
@@ -29,6 +28,7 @@ import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Tab
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.selection.SelectionHolder
import org.mozilla.fenix.tabstray.TabsTrayInteractor
@@ -37,7 +37,7 @@ import org.mozilla.fenix.tabstray.TabsTrayStore
@RunWith(FenixRobolectricTestRunner::class)
class AbstractBrowserTabViewHolderTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
val gleanTestRule = FenixGleanTestRule(testContext)
val store = TabsTrayStore()
val browserStore = BrowserStore()

View File

@@ -29,7 +29,6 @@ import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import mozilla.telemetry.glean.internal.TimerId
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -49,6 +48,7 @@ import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings
import org.robolectric.shadows.ShadowLooper
@@ -68,7 +68,7 @@ class TelemetryMiddlewareTest {
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanRule = GleanTestRule(ApplicationProvider.getApplicationContext())
val gleanRule = FenixGleanTestRule(ApplicationProvider.getApplicationContext())
private val clock = FakeClock()
private val metrics: MetricController = mockk()

View File

@@ -13,7 +13,6 @@ import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.verify
import mozilla.components.support.test.robolectric.testContext
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
@@ -27,6 +26,7 @@ import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.trackingprotection.TrackingProtectionCategory.CROSS_SITE_TRACKING_COOKIES
import org.mozilla.fenix.trackingprotection.TrackingProtectionCategory.SOCIAL_MEDIA_TRACKERS
@@ -48,7 +48,7 @@ class TrackingProtectionPanelViewTest {
)
@get:Rule
val gleanRule = GleanTestRule(testContext)
val gleanRule = FenixGleanTestRule(testContext)
@Before
fun setup() {

View File

@@ -177,7 +177,7 @@ class GleanMetricsService(context: Context) : MetricsService {
* @param enabled true if enabling upload, false if disabling it.
*/
fun setUploadEnabled(enabled: Boolean) {
Glean.setUploadEnabled(enabled)
Glean.setCollectionEnabled(enabled)
if (enabled) {
checkAndSetUsageProfileId()
} else {

View File

@@ -4,6 +4,7 @@
use std::sync::{Mutex, MutexGuard};
use crate::private::Ping;
use once_cell::sync::Lazy;
const GLOBAL_APPLICATION_ID: &str = "org.mozilla.firefox.test";
@@ -16,6 +17,18 @@ pub fn lock_test() -> (MutexGuard<'static, ()>, tempfile::TempDir) {
let lock = GLOBAL_LOCK.lock().unwrap();
_ = Ping::new(
"test-ping",
true,
false,
true,
true,
true,
vec![],
vec![],
true,
);
let dir = setup_glean(None);
(lock, dir)
}

View File

@@ -16,3 +16,8 @@ pub extern "C" fn fog_submit_ping_by_id(id: u32, reason: &nsACString) {
};
pings::submit_ping_by_id(id, reason.as_deref());
}
#[no_mangle]
pub extern "C" fn fog_set_ping_enabled(id: u32, value: bool) {
pings::set_ping_enabled(id, value);
}

View File

@@ -216,7 +216,7 @@ mod test {
let metric = &metrics::test_only_ipc::a_bool;
metric.set(true);
assert!(metric.test_get_value("store1").unwrap());
assert!(metric.test_get_value("test-ping").unwrap());
}
#[test]
@@ -244,7 +244,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
false == parent_metric.test_get_value("store1").unwrap(),
false == parent_metric.test_get_value("test-ping").unwrap(),
"Boolean metrics should only work in the parent process"
);
}
@@ -270,7 +270,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
!parent_metric.test_get_value("store1").unwrap(),
!parent_metric.test_get_value("test-ping").unwrap(),
"Boolean metrics can unsafely work in child processes"
);
}

View File

@@ -199,7 +199,7 @@ mod test {
let metric = &metrics::test_only_ipc::a_counter;
metric.add(1);
assert_eq!(1, metric.test_get_value("store1").unwrap());
assert_eq!(1, metric.test_get_value("test-ping").unwrap());
}
#[test]
@@ -233,7 +233,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
45 == parent_metric.test_get_value("store1").unwrap(),
45 == parent_metric.test_get_value("test-ping").unwrap(),
"Values from the 'processes' should be summed"
);
}

View File

@@ -219,7 +219,7 @@ mod test {
metric.accumulate_samples_signed(vec![1, 2, 3]);
assert!(metric.test_get_value("store1").is_some());
assert!(metric.test_get_value("test-ping").is_some());
}
#[test]
@@ -243,7 +243,7 @@ mod test {
assert!(ipc::replay_from_buf(&buf).is_ok());
let data = parent_metric
.test_get_value("store1")
.test_get_value("test-ping")
.expect("should have some data");
assert_eq!(2, data.values[&1], "Low bucket has 2 values");

View File

@@ -327,7 +327,7 @@ mod test {
let expected: glean::Datetime = DateTime::parse_from_rfc3339("2020-05-07T11:58:00+05:00")
.unwrap()
.into();
assert_eq!(expected, metric.test_get_value("store1").unwrap());
assert_eq!(expected, metric.test_get_value("test-ping").unwrap());
}
#[test]
@@ -341,7 +341,7 @@ mod test {
let expected: glean::Datetime = DateTime::parse_from_rfc3339("2020-05-07T11:58:00+05:00")
.unwrap()
.into();
assert_eq!(expected, metric.test_get_value("store1").unwrap());
assert_eq!(expected, metric.test_get_value("test-ping").unwrap());
}
#[test]
@@ -374,6 +374,6 @@ mod test {
let expected: glean::Datetime = DateTime::parse_from_rfc3339("2020-10-13T16:41:00+05:00")
.unwrap()
.into();
assert_eq!(expected, parent_metric.test_get_value("store1").unwrap());
assert_eq!(expected, parent_metric.test_get_value("test-ping").unwrap());
}
}

View File

@@ -128,7 +128,7 @@ mod test {
let metric = &metrics::test_only_ipc::an_external_denominator;
metric.add(1);
assert_eq!(1, metric.test_get_value("store1").unwrap());
assert_eq!(1, metric.test_get_value("test-ping").unwrap());
}
#[test]
@@ -164,7 +164,7 @@ mod test {
assert_eq!(
45,
parent_metric.test_get_value("store1").unwrap(),
parent_metric.test_get_value("test-ping").unwrap(),
"Values from the 'processes' should be summed"
);
}

View File

@@ -244,7 +244,7 @@ mod test {
CommonMetricData {
name: "event_metric".into(),
category: "telemetry".into(),
send_in_pings: vec!["store1".into()],
send_in_pings: vec!["test-ping".into()],
disabled: false,
..Default::default()
},
@@ -253,7 +253,7 @@ mod test {
// No extra keys
metric.record(None);
let recorded = metric.test_get_value("store1").unwrap();
let recorded = metric.test_get_value("test-ping").unwrap();
assert!(recorded.iter().any(|e| e.name == "event_metric"));
}
@@ -293,7 +293,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
let events = parent_metric.test_get_value("store1").unwrap();
let events = parent_metric.test_get_value("test-ping").unwrap();
assert_eq!(events.len(), 4);
// Events from the child process are last, they might get sorted later by Glean.
@@ -318,7 +318,7 @@ mod test {
};
event.record(extra);
let recorded = event.test_get_value("store1").unwrap();
let recorded = event.test_get_value("test-ping").unwrap();
assert_eq!(recorded.len(), 1);
assert!(recorded[0].extra.as_ref().unwrap().get("extra1").unwrap() == "a-valid-value");

View File

@@ -453,7 +453,7 @@ mod test {
cmd: CommonMetricData {
name: "global".into(),
category: "metric".into(),
send_in_pings: vec!["ping".into()],
send_in_pings: vec!["test-ping".into()],
disabled: false,
..Default::default()
},
@@ -469,14 +469,17 @@ mod test {
GLOBAL_METRIC.get("a_value").set(true);
assert_eq!(
true,
GLOBAL_METRIC.get("a_value").test_get_value("ping").unwrap()
GLOBAL_METRIC
.get("a_value")
.test_get_value("test-ping")
.unwrap()
);
}
#[test]
fn sets_labeled_bool_metrics() {
let _lock = lock_test();
let store_names: Vec<String> = vec!["store1".into()];
let store_names: Vec<String> = vec!["test-ping".into()];
let metric: LabeledMetric<LabeledBooleanMetric, DynamicLabel> = LabeledMetric::new(
0.into(),
@@ -494,14 +497,14 @@ mod test {
metric.get("upload").set(true);
assert!(metric.get("upload").test_get_value("store1").unwrap());
assert_eq!(None, metric.get("download").test_get_value("store1"));
assert!(metric.get("upload").test_get_value("test-ping").unwrap());
assert_eq!(None, metric.get("download").test_get_value("test-ping"));
}
#[test]
fn sets_labeled_string_metrics() {
let _lock = lock_test();
let store_names: Vec<String> = vec!["store1".into()];
let store_names: Vec<String> = vec!["test-ping".into()];
let metric: LabeledMetric<LabeledStringMetric, DynamicLabel> = LabeledMetric::new(
0.into(),
@@ -521,15 +524,15 @@ mod test {
assert_eq!(
"Glean",
metric.get("upload").test_get_value("store1").unwrap()
metric.get("upload").test_get_value("test-ping").unwrap()
);
assert_eq!(None, metric.get("download").test_get_value("store1"));
assert_eq!(None, metric.get("download").test_get_value("test-ping"));
}
#[test]
fn sets_labeled_counter_metrics() {
let _lock = lock_test();
let store_names: Vec<String> = vec!["store1".into()];
let store_names: Vec<String> = vec!["test-ping".into()];
let metric: LabeledMetric<LabeledCounterMetric, DynamicLabel> = LabeledMetric::new(
0.into(),
@@ -547,14 +550,17 @@ mod test {
metric.get("upload").add(10);
assert_eq!(10, metric.get("upload").test_get_value("store1").unwrap());
assert_eq!(None, metric.get("download").test_get_value("store1"));
assert_eq!(
10,
metric.get("upload").test_get_value("test-ping").unwrap()
);
assert_eq!(None, metric.get("download").test_get_value("test-ping"));
}
#[test]
fn records_errors() {
let _lock = lock_test();
let store_names: Vec<String> = vec!["store1".into()];
let store_names: Vec<String> = vec!["test-ping".into()];
let metric: LabeledMetric<LabeledBooleanMetric, DynamicLabel> = LabeledMetric::new(
0.into(),
@@ -581,7 +587,7 @@ mod test {
#[test]
fn predefined_labels() {
let _lock = lock_test();
let store_names: Vec<String> = vec!["store1".into()];
let store_names: Vec<String> = vec!["test-ping".into()];
#[allow(dead_code)]
enum MetricLabels {
@@ -606,15 +612,18 @@ mod test {
metric.get("label2").set(false);
metric.get("not_a_label").set(true);
assert_eq!(true, metric.get("label1").test_get_value("store1").unwrap());
assert_eq!(
true,
metric.get("label1").test_get_value("test-ping").unwrap()
);
assert_eq!(
false,
metric.get("label2").test_get_value("store1").unwrap()
metric.get("label2").test_get_value("test-ping").unwrap()
);
// The label not in the predefined set is recorded to the `other` bucket.
assert_eq!(
true,
metric.get("__other__").test_get_value("store1").unwrap()
metric.get("__other__").test_get_value("test-ping").unwrap()
);
assert_eq!(

View File

@@ -92,7 +92,7 @@ mod test {
let metric = &metrics::test_only_ipc::an_unordered_labeled_boolean;
metric.get("a_label").set(true);
assert!(metric.get("a_label").test_get_value("store1").unwrap());
assert!(metric.get("a_label").test_get_value("test-ping").unwrap());
}
#[test]
@@ -159,7 +159,10 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
!parent_metric.get(label).test_get_value("store1").unwrap(),
!parent_metric
.get(label)
.test_get_value("test-ping")
.unwrap(),
"Later value takes precedence."
);
}

View File

@@ -143,7 +143,10 @@ mod test {
let metric = &metrics::test_only_ipc::a_labeled_counter;
metric.get("a_label").add(1);
assert_eq!(1, metric.get("a_label").test_get_value("store1").unwrap());
assert_eq!(
1,
metric.get("a_label").test_get_value("test-ping").unwrap()
);
}
#[test]
@@ -205,7 +208,10 @@ mod test {
assert_eq!(
45,
parent_metric.get(label).test_get_value("store1").unwrap(),
parent_metric
.get(label)
.test_get_value("test-ping")
.unwrap(),
"Values from the 'processes' should be summed"
);
}

View File

@@ -255,7 +255,7 @@ mod test {
CommonMetricData {
name: "memory_distribution_metric".into(),
category: "telemetry".into(),
send_in_pings: vec!["store1".into()],
send_in_pings: vec!["test-ping".into()],
disabled: false,
..Default::default()
},
@@ -264,7 +264,7 @@ mod test {
metric.accumulate(42);
let metric_data = metric.test_get_value("store1").unwrap();
let metric_data = metric.test_get_value("test-ping").unwrap();
assert_eq!(1, metric_data.values[&42494]);
assert_eq!(43008, metric_data.sum);
}
@@ -284,7 +284,7 @@ mod test {
child_metric.accumulate(13 * 9);
}
let metric_data = parent_metric.test_get_value("store1").unwrap();
let metric_data = parent_metric.test_get_value("test-ping").unwrap();
assert_eq!(1, metric_data.values[&42494]);
assert_eq!(43008, metric_data.sum);

View File

@@ -126,7 +126,7 @@ mod test {
let metric = &metrics::test_only_ipc::rate_with_external_denominator;
metric.add_to_numerator(1);
assert_eq!(1, metric.test_get_value("store1").unwrap().numerator);
assert_eq!(1, metric.test_get_value("test-ping").unwrap().numerator);
}
#[test]
@@ -159,7 +159,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
45 == parent_metric.test_get_value("store1").unwrap().numerator,
45 == parent_metric.test_get_value("test-ping").unwrap().numerator,
"Values from the 'processes' should be summed"
);
}

View File

@@ -34,6 +34,7 @@ impl Ping {
enabled: bool,
schedules_pings: Vec<String>,
reason_codes: Vec<String>,
follows_collection_enabled: bool,
) -> Self {
if need_ipc() {
Ping::Child
@@ -48,10 +49,20 @@ impl Ping {
enabled,
schedules_pings,
reason_codes,
follows_collection_enabled,
))
}
}
pub fn set_enabled(&self, enabled: bool) {
match self {
Ping::Parent(p) => p.set_enabled(enabled),
Ping::Child => {
panic!("Cannot use ping set_enabled API from non-parent process!");
}
}
}
/// **Test-only API**
///
/// Attach a callback to be called right before a new ping is submitted.
@@ -109,8 +120,19 @@ mod test {
};
// Smoke test for what should be the generated code.
static PROTOTYPE_PING: Lazy<Ping> =
Lazy::new(|| Ping::new("prototype", false, true, true, true, true, vec![], vec![]));
static PROTOTYPE_PING: Lazy<Ping> = Lazy::new(|| {
Ping::new(
"prototype",
false,
true,
true,
true,
true,
vec![],
vec![],
true,
)
});
#[test]
fn smoke_test_custom_ping() {

View File

@@ -141,7 +141,7 @@ mod test {
let metric = &metrics::test_only_ipc::a_quantity;
metric.set(14);
assert_eq!(14, metric.test_get_value("store1").unwrap());
assert_eq!(14, metric.test_get_value("test-ping").unwrap());
}
#[test]

View File

@@ -166,7 +166,7 @@ mod test {
numerator: 1,
denominator: 100
},
metric.test_get_value("store1").unwrap()
metric.test_get_value("test-ping").unwrap()
);
}
@@ -207,7 +207,7 @@ mod test {
numerator: 45,
denominator: 33
},
parent_metric.test_get_value("store1").unwrap(),
parent_metric.test_get_value("test-ping").unwrap(),
"Values from the 'processes' should be summed"
);
}

View File

@@ -172,7 +172,7 @@ mod test {
assert_eq!(
"test_string_value",
metric.test_get_value("store1").unwrap()
metric.test_get_value("test-ping").unwrap()
);
}
@@ -200,7 +200,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
"test_parent_value" == parent_metric.test_get_value("store1").unwrap(),
"test_parent_value" == parent_metric.test_get_value("test-ping").unwrap(),
"String metrics should only work in the parent process"
);
}

View File

@@ -202,7 +202,7 @@ mod test {
assert_eq!(
vec!["test_string_value", "another test value"],
metric.test_get_value("store1").unwrap()
metric.test_get_value("test-ping").unwrap()
);
}
@@ -235,7 +235,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert_eq!(
vec!["test_string_value", "another test value"],
parent_metric.test_get_value("store1").unwrap()
parent_metric.test_get_value("test-ping").unwrap()
);
}
}

View File

@@ -166,7 +166,10 @@ mod test {
metric.set("test_text_value");
assert_eq!("test_text_value", metric.test_get_value("store1").unwrap());
assert_eq!(
"test_text_value",
metric.test_get_value("test-ping").unwrap()
);
}
#[test]
@@ -193,7 +196,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
"test_parent_value" == parent_metric.test_get_value("store1").unwrap(),
"test_parent_value" == parent_metric.test_get_value("test-ping").unwrap(),
"Text metrics should only work in the parent process"
);
}

View File

@@ -307,7 +307,7 @@ mod test {
CommonMetricData {
name: "timespan_metric".into(),
category: "telemetry".into(),
send_in_pings: vec!["store1".into()],
send_in_pings: vec!["test-ping".into()],
disabled: false,
..Default::default()
},
@@ -320,7 +320,7 @@ mod test {
// So let's cancel and make sure nothing blows up.
metric.cancel();
assert_eq!(None, metric.test_get_value("store1"));
assert_eq!(None, metric.test_get_value("test-ping"));
}
#[test]

View File

@@ -705,7 +705,7 @@ mod test {
metric.cancel(id);
// We can't inspect the values yet.
assert!(metric.test_get_value("store1").is_none());
assert!(metric.test_get_value("test-ping").is_none());
}
#[test]
@@ -737,7 +737,7 @@ mod test {
assert!(ipc::replay_from_buf(&buf).is_ok());
let data = parent_metric
.test_get_value("store1")
.test_get_value("test-ping")
.expect("should have some data");
// No guarantees from timers means no guarantees on buckets.

View File

@@ -161,7 +161,7 @@ mod test {
assert_eq!(
"https://example.com",
metric.test_get_value("store1").unwrap()
metric.test_get_value("test-ping").unwrap()
);
}
@@ -189,7 +189,7 @@ mod test {
assert!(ipc::replay_from_buf(&ipc::take_buf().unwrap()).is_ok());
assert!(
"https://example.com/parent" == parent_metric.test_get_value("store1").unwrap(),
"https://example.com/parent" == parent_metric.test_get_value("test-ping").unwrap(),
"Url metrics should only work in the parent process"
);
}

View File

@@ -175,7 +175,7 @@ mod test {
let expected = Uuid::new_v4();
metric.set(expected.clone());
assert_eq!(expected, metric.test_get_value("store1").unwrap());
assert_eq!(expected, metric.test_get_value("test-ping").unwrap());
}
#[test]
@@ -201,7 +201,7 @@ mod test {
assert_eq!(
expected,
parent_metric.test_get_value("store1").unwrap(),
parent_metric.test_get_value("test-ping").unwrap(),
"UUID metrics should only work in the parent process"
);
}

View File

@@ -144,6 +144,7 @@ pub extern "C" fn jog_test_register_ping(
enabled: bool,
schedules_pings: &ThinVec<nsCString>,
reason_codes: &ThinVec<nsCString>,
follows_collection_enabled: bool,
) -> u32 {
let ping_name = name.to_string();
let reason_codes = reason_codes
@@ -163,6 +164,7 @@ pub extern "C" fn jog_test_register_ping(
enabled,
schedules_pings,
reason_codes,
follows_collection_enabled,
)
.expect("Creation or registration of ping failed.") // permitted to panic in test-only method.
}
@@ -177,6 +179,7 @@ fn create_and_register_ping(
enabled: bool,
schedules_pings: Vec<String>,
reason_codes: Vec<String>,
follows_collection_enabled: bool,
) -> Result<u32, Box<dyn std::error::Error>> {
let ns_name = nsCString::from(&ping_name);
let ping_id = factory::create_and_register_ping(
@@ -188,6 +191,7 @@ fn create_and_register_ping(
enabled,
schedules_pings,
reason_codes,
follows_collection_enabled,
);
extern "C" {
fn JOG_RegisterPing(name: &nsACString, ping_id: u32);
@@ -237,6 +241,7 @@ struct PingDefinitionData {
enabled: bool,
schedules_pings: Option<Vec<String>>,
reason_codes: Option<Vec<String>>,
follows_collection_enabled: bool,
}
/// Read the file at the provided location, interpret it as a jogfile,
@@ -286,6 +291,7 @@ pub extern "C" fn jog_load_jogfile(jogfile_path: &nsAString) -> bool {
ping.enabled,
ping.schedules_pings.unwrap_or_else(Vec::new),
ping.reason_codes.unwrap_or_else(Vec::new),
ping.follows_collection_enabled,
);
}
true

View File

@@ -52,6 +52,8 @@ void Ping::Submit(const nsACString& aReason) const {
fog_submit_ping_by_id(mId, &aReason);
}
void Ping::SetEnabled(bool aValue) const { fog_set_ping_enabled(mId, aValue); }
void Ping::TestBeforeNextSubmit(PingTestCallback&& aCallback) const {
{
GetCallbackMapLock().apply(
@@ -70,6 +72,12 @@ GleanPing::Submit(const nsACString& aReason) {
return NS_OK;
}
NS_IMETHODIMP
GleanPing::SetEnabled(bool aValue) {
mPing.SetEnabled(aValue);
return NS_OK;
}
NS_IMETHODIMP
GleanPing::TestBeforeNextSubmit(nsIGleanPingTestCallback* aCallback) {
if (NS_WARN_IF(!aCallback)) {

View File

@@ -59,6 +59,16 @@ class Ping {
*/
void TestBeforeNextSubmit(PingTestCallback&& aCallback) const;
/**
* Enable or disable a ping.
*
* Disabling a ping causes all data for that ping to be removed from storage
* and all pending pings of that type to be deleted.
*
* @param aValue When true, enable metric collection.
*/
void SetEnabled(bool aValue) const;
private:
const uint32_t mId;
};

View File

@@ -55,7 +55,7 @@ known_metadata = [
"permit_non_commutative_operations_over_ipc",
]
# List of all ping-specific args that JOG undertsands.
# List of all ping-specific args that JOG understands.
known_ping_args = [
"name",
"include_client_id",
@@ -65,6 +65,7 @@ known_ping_args = [
"enabled",
"schedules_pings",
"reason_codes",
"follows_collection_enabled",
]

View File

@@ -198,9 +198,10 @@ pub fn create_and_register_ping(
enabled: bool,
schedules_pings: Vec<String>,
reason_codes: Vec<String>,
follows_collection_enabled: bool,
) -> Result<u32, Box<dyn std::error::Error>> {
let ping_id = NEXT_PING_ID.fetch_add(1, Ordering::SeqCst);
let ping = Ping::new(ping_name, include_client_id, send_if_empty, precise_timestamps, include_info_sections, enabled, schedules_pings, reason_codes);
let ping = Ping::new(ping_name, include_client_id, send_if_empty, precise_timestamps, include_info_sections, enabled, schedules_pings, reason_codes, follows_collection_enabled);
assert!(
__jog_metric_maps::PING_MAP.write()?.insert(ping_id.into(), ping).is_none(),
"We should never insert a runtime ping with an already-used id."

View File

@@ -24,6 +24,7 @@ pub static {{ obj.name|snake_case }}: Lazy<Ping> = Lazy::new(|| {
{{ obj.enabled|rust }},
{{ obj.schedules_pings|rust }},
{{ obj.reason_codes|rust }},
{{ obj.follows_collection_enabled|rust }},
)
});
@@ -92,3 +93,16 @@ pub(crate) fn submit_ping_by_id(id: u32, reason: Option<&str>) {
}
}
}
#[cfg(feature = "with_gecko")]
pub(crate) fn set_ping_enabled(id: u32, enabled: bool) {
match id {
{% for obj in all_objs['pings'].values() %}
{{ obj.name|ping_id }} => {{ obj.name | snake_case }}.set_enabled(enabled),
{% endfor %}
_ => {
// TODO: instrument this error.
log::error!("Cannot set_enabled on unknown ping {} by id.", id);
}
}
}

View File

@@ -358,6 +358,9 @@ fn fog_test_reset_internal(
// I'd prefer to reuse the uploader, but it gets moved into Glean so we build anew.
conf.uploader = Some(Box::new(ViaductUploader) as Box<dyn glean::net::PingUploader>);
// Register all custom pings before we initialize.
pings::register_pings(None);
glean::test_reset_glean(conf, client_info, true);
Ok(())
}

View File

@@ -90,10 +90,10 @@ impl UploadPrefObserver {
// ensure Glean is told to wipe the stores.
// This may send a "deletion-request" ping for a client_id that's never sent
// any other pings.
glean::set_upload_enabled(false);
glean::set_collection_enabled(false);
}
RECORDING_ENABLED.store(recording_enabled, Ordering::SeqCst);
glean::set_upload_enabled(upload_enabled || recording_enabled);
glean::set_collection_enabled(upload_enabled || recording_enabled);
NS_OK
}
}

View File

@@ -125,13 +125,14 @@ using std::tuple;
TEST_F(FOGFixture, TestCppEventWorks) {
test_only_ipc::no_extra_event.Record();
ASSERT_TRUE(test_only_ipc::no_extra_event.TestGetValue("store1"_ns)
ASSERT_TRUE(test_only_ipc::no_extra_event.TestGetValue("test-ping"_ns)
.unwrap()
.isSome());
AnEventExtra extra = {.extra1 = Some("can set extras"_ns)};
test_only_ipc::an_event.Record(Some(extra));
auto optEvents = test_only_ipc::an_event.TestGetValue("store1"_ns).unwrap();
auto optEvents =
test_only_ipc::an_event.TestGetValue("test-ping"_ns).unwrap();
ASSERT_TRUE(optEvents.isSome());
auto events = optEvents.extract();
@@ -149,7 +150,7 @@ TEST_F(FOGFixture, TestCppEventsWithDifferentExtraTypes) {
.extra3LongerName = Some(false)};
test_only_ipc::event_with_extra.Record(Some(extra));
auto optEvents =
test_only_ipc::event_with_extra.TestGetValue("store1"_ns).unwrap();
test_only_ipc::event_with_extra.TestGetValue("test-ping"_ns).unwrap();
ASSERT_TRUE(optEvents.isSome());
auto events = optEvents.extract();
@@ -197,7 +198,7 @@ TEST_F(FOGFixture, TestCppCustomDistWorks) {
test_only_ipc::a_custom_dist.AccumulateSamples({7, 268435458});
DistributionData data =
test_only_ipc::a_custom_dist.TestGetValue("store1"_ns).unwrap().ref();
test_only_ipc::a_custom_dist.TestGetValue("test-ping"_ns).unwrap().ref();
ASSERT_EQ(data.sum, 7UL + 268435458);
ASSERT_EQ(data.count, 2UL);
for (const auto& entry : data.values) {
@@ -471,7 +472,7 @@ TEST_F(FOGFixture, TestCppUrlWorks) {
mozilla::glean::test_only_ipc::a_url.Set(kValue);
ASSERT_STREQ(kValue.get(),
mozilla::glean::test_only_ipc::a_url.TestGetValue("store1"_ns)
mozilla::glean::test_only_ipc::a_url.TestGetValue("test-ping"_ns)
.unwrap()
.value()
.get());

View File

@@ -353,7 +353,8 @@
"background",
"dirty_startup",
"foreground"
]
],
true
],
[
"not-deletion-request",
@@ -363,7 +364,8 @@
true,
true,
[],
[]
[],
true
],
[
"not-events",
@@ -377,7 +379,8 @@
"background",
"max_capacity",
"startup"
]
],
true
],
[
"not-metrics",
@@ -393,7 +396,8 @@
"today",
"tomorrow",
"upgrade"
]
],
true
],
[
"not-ohttp",
@@ -403,7 +407,8 @@
false,
true,
[],
[]
[],
true
],
[
"ridealong-test",
@@ -413,7 +418,8 @@
true,
true,
[],
[]
[],
true
]
]
}

View File

@@ -24,6 +24,7 @@ pub static not_baseline: Lazy<Ping> = Lazy::new(|| {
true,
vec![],
vec!["background".into(), "dirty_startup".into(), "foreground".into()],
true,
)
});
@@ -43,6 +44,7 @@ pub static not_deletion_request: Lazy<Ping> = Lazy::new(|| {
true,
vec![],
vec![],
true,
)
});
@@ -60,6 +62,7 @@ pub static not_events: Lazy<Ping> = Lazy::new(|| {
true,
vec![],
vec!["background".into(), "max_capacity".into(), "startup".into()],
true,
)
});
@@ -81,6 +84,7 @@ pub static not_metrics: Lazy<Ping> = Lazy::new(|| {
true,
vec![],
vec!["overdue".into(), "reschedule".into(), "today".into(), "tomorrow".into(), "upgrade".into()],
true,
)
});
@@ -96,6 +100,7 @@ pub static not_ohttp: Lazy<Ping> = Lazy::new(|| {
true,
vec![],
vec![],
true,
)
});
@@ -111,6 +116,7 @@ pub static ridealong_test: Lazy<Ping> = Lazy::new(|| {
true,
vec![],
vec![],
true,
)
});
@@ -174,3 +180,19 @@ pub(crate) fn submit_ping_by_id(id: u32, reason: Option<&str>) {
}
}
}
#[cfg(feature = "with_gecko")]
pub(crate) fn set_ping_enabled(id: u32, enabled: bool) {
match id {
1 => not_baseline.set_enabled(enabled),
2 => not_deletion_request.set_enabled(enabled),
3 => not_events.set_enabled(enabled),
4 => not_metrics.set_enabled(enabled),
5 => not_ohttp.set_enabled(enabled),
6 => ridealong_test.set_enabled(enabled),
_ => {
// TODO: instrument this error.
log::error!("Cannot set_enabled on unknown ping {} by id.", id);
}
}
}

View File

@@ -770,7 +770,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_MIRROR_FOR_COUNTER
@@ -791,7 +791,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: h#TELEMETRY_TEST_COUNT
@@ -812,7 +812,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
labels:
@@ -837,7 +837,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_MIRROR_FOR_UNORDERED_BOOL
@@ -857,7 +857,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_BOOLEAN_KIND
@@ -878,7 +878,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_MIRROR_FOR_UNORDERED_LABELED_BOOL
@@ -899,7 +899,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_MIRROR_FOR_DATE
@@ -919,7 +919,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_MULTIPLE_STORES_STRING
@@ -938,7 +938,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
a_memory_dist:
@@ -958,7 +958,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_LINEAR
@@ -978,7 +978,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_EXPONENTIAL
@@ -997,7 +997,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
range_min: 1
@@ -1021,7 +1021,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_KEYED_BOOLEAN_KIND
@@ -1051,7 +1051,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TelemetryTest_MirrorWithExtra_Object1
@@ -1084,7 +1084,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
no_extra_event:
@@ -1103,7 +1103,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
telemetry_mirror: TelemetryTest_NotExpiredOptout_Object1
a_uuid:
type: uuid
@@ -1121,7 +1121,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_STRING_KIND
@@ -1141,7 +1141,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_ANOTHER_MIRROR_FOR_LABELED_COUNTER
@@ -1162,7 +1162,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_MIRROR_FOR_LABELED_COUNTER
@@ -1182,7 +1182,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
irate:
@@ -1200,7 +1200,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
telemetry_mirror: TELEMETRY_TEST_MIRROR_FOR_RATE
rate_with_external_denominator:
type: rate
@@ -1218,7 +1218,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
an_external_denominator:
type: counter
description: |
@@ -1234,7 +1234,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
a_url:
@@ -1252,7 +1252,7 @@ test_only.ipc:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
no_lint:
- COMMON_PREFIX
telemetry_mirror: TELEMETRY_TEST_MIRROR_FOR_URL
@@ -1274,7 +1274,7 @@ test_only.jog:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping
an_event:
type: event
@@ -1299,4 +1299,4 @@ test_only.jog:
- glean-team@mozilla.com
expires: never
send_in_pings:
- store1
- test-ping

View File

@@ -188,7 +188,7 @@ add_task(
// custom_distribution
const customSampleSum = CUSTOM_SAMPLES.reduce((acc, a) => acc + a, 0);
const customData = Glean.testOnlyIpc.aCustomDist.testGetValue("store1");
const customData = Glean.testOnlyIpc.aCustomDist.testGetValue("test-ping");
Assert.equal(customSampleSum, customData.sum, "Sum's correct");
for (let [bucket, count] of Object.entries(customData.values)) {
Assert.ok(

View File

@@ -211,7 +211,7 @@ add_task(async function test_fog_memory_distribution_works() {
add_task(async function test_fog_custom_distribution_works() {
Glean.testOnlyIpc.aCustomDist.accumulateSamples([7, 268435458]);
let data = Glean.testOnlyIpc.aCustomDist.testGetValue("store1");
let data = Glean.testOnlyIpc.aCustomDist.testGetValue("test-ping");
Assert.equal(2, data.count, "Count of entries is correct");
Assert.equal(7 + 268435458, data.sum, "Sum's correct");
for (let [bucket, count] of Object.entries(data.values)) {
@@ -451,7 +451,7 @@ add_task(async function test_fog_url_works() {
const value = "https://www.example.com/fog";
Glean.testOnlyIpc.aUrl.set(value);
Assert.equal(value, Glean.testOnlyIpc.aUrl.testGetValue("store1"));
Assert.equal(value, Glean.testOnlyIpc.aUrl.testGetValue("test-ping"));
});
add_task(async function test_fog_text_works() {

View File

@@ -123,7 +123,7 @@ add_task(
Assert.ok(count == 1 && MEMORY_BUCKETS.includes(bucket));
}
const customData = Glean.testOnlyIpc.aCustomDist.testGetValue("store1");
const customData = Glean.testOnlyIpc.aCustomDist.testGetValue("test-ping");
Assert.equal(3 + 4, customData.sum, "Sum's correct");
for (let [bucket, count] of Object.entries(customData.values)) {
Assert.ok(

Some files were not shown because too many files have changed in this diff Show More