1
0
Fork 0

No issue: Fixes GleanMetricsService nits & broken UI test (#5539)

* No issue: Fixes GleanMetricsService nits

* No issue: fixes broken UI test
master
Sawyer Blatz 2019-09-24 16:12:09 -07:00 committed by GitHub
parent b113c2ac24
commit 856399e9e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View File

@ -298,7 +298,7 @@ private fun assertPrivateSessionHeader() =
const val PRIVATE_SESSION_MESSAGE = "Firefox Preview clears your search and browsing history " + const val PRIVATE_SESSION_MESSAGE = "Firefox Preview clears your search and browsing history " +
"when you quit the app or close all private tabs. While this doesnt make you anonymous to websites or " + "when you quit the app or close all private tabs. While this doesnt make you anonymous to websites or " +
"your internet service provider, it makes it easier to keep what you do online private from anyone else " + "your internet service provider, it makes it easier to keep what you do online private from anyone else " +
"who uses this device.\n\nCommon myths about private browsing" "who uses this device."
private fun assertPrivateSessionMessage(visible: Boolean) = private fun assertPrivateSessionMessage(visible: Boolean) =
onView(CoreMatchers.allOf(ViewMatchers.withText(PRIVATE_SESSION_MESSAGE))) onView(CoreMatchers.allOf(ViewMatchers.withText(PRIVATE_SESSION_MESSAGE)))

View File

@ -112,7 +112,7 @@ open class FenixApplication : Application() {
components.core.sessionManager.register(NotificationSessionObserver(this)) components.core.sessionManager.register(NotificationSessionObserver(this))
if ((System.currentTimeMillis() - this.settings.lastPlacesStorageMaintenance) > ONE_DAY_MILLIS) { if ((System.currentTimeMillis() - this.settings().lastPlacesStorageMaintenance) > ONE_DAY_MILLIS) {
runStorageMaintenance() runStorageMaintenance()
} }
} }
@ -123,7 +123,7 @@ open class FenixApplication : Application() {
// run maintenance on one - arbitrarily using bookmarks. // run maintenance on one - arbitrarily using bookmarks.
components.core.bookmarksStorage.runMaintenance() components.core.bookmarksStorage.runMaintenance()
} }
this.settings.lastPlacesStorageMaintenance = System.currentTimeMillis() this.settings().lastPlacesStorageMaintenance = System.currentTimeMillis()
} }
private fun registerRxExceptionHandling() { private fun registerRxExceptionHandling() {

View File

@ -430,10 +430,6 @@ class GleanMetricsService(private val context: Context) : MetricsService {
} }
} }
/**
* Sets some basic Glean metrics required by Fenix.
* This is a separate function to simplify testing.
*/
internal fun setStartupMetrics() { internal fun setStartupMetrics() {
Metrics.apply { Metrics.apply {
defaultBrowser.set(Browsers.all(context).isDefaultBrowser) defaultBrowser.set(Browsers.all(context).isDefaultBrowser)

View File

@ -10,6 +10,7 @@ import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
@ -27,10 +28,15 @@ class GleanMetricsServiceTest {
@get:Rule @get:Rule
val gleanRule = GleanTestRule(testContext) val gleanRule = GleanTestRule(testContext)
private lateinit var gleanService: GleanMetricsService
@Before
fun setup() {
gleanService = GleanMetricsService(testContext)
}
@Test @Test
fun `setStartupMetrics sets some base metrics`() { fun `setStartupMetrics sets some base metrics`() {
val gleanService = GleanMetricsService(testContext)
// Set the metrics. // Set the metrics.
gleanService.setStartupMetrics() gleanService.setStartupMetrics()
@ -48,8 +54,6 @@ class GleanMetricsServiceTest {
@Test @Test
fun `the app_opened event is correctly recorded`() { fun `the app_opened event is correctly recorded`() {
val gleanService = GleanMetricsService(testContext)
// Build the event wrapper used by Fenix. // Build the event wrapper used by Fenix.
val event = Event.OpenedApp(Event.OpenedApp.Source.APP_ICON) val event = Event.OpenedApp(Event.OpenedApp.Source.APP_ICON)