[fenix] For https://github.com/mozilla-mobile/fenix/issues/24452 - Remove MetricController checks from BackgroundServicesTest

pull/600/head
Alexandru2909 3 years ago committed by mergify[bot]
parent f2a0ca62b9
commit 624dc9baa3

@ -4,7 +4,6 @@
package org.mozilla.fenix.components package org.mozilla.fenix.components
import io.mockk.Called
import io.mockk.MockKAnnotations import io.mockk.MockKAnnotations
import io.mockk.Runs import io.mockk.Runs
import io.mockk.confirmVerified import io.mockk.confirmVerified
@ -25,7 +24,6 @@ import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.GleanMetrics.SyncAuth
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
@ -36,9 +34,6 @@ class BackgroundServicesTest {
@get:Rule @get:Rule
val gleanTestRule = GleanTestRule(testContext) val gleanTestRule = GleanTestRule(testContext)
@MockK
private lateinit var metrics: MetricController
@MockK @MockK
private lateinit var settings: Settings private lateinit var settings: Settings
@ -48,7 +43,6 @@ class BackgroundServicesTest {
@Before @Before
fun setup() { fun setup() {
MockKAnnotations.init(this) MockKAnnotations.init(this)
every { metrics.track(any()) } just Runs
every { settings.signedInFxaAccount = any() } just Runs every { settings.signedInFxaAccount = any() } just Runs
observer = TelemetryAccountObserver(settings) observer = TelemetryAccountObserver(settings)
@ -64,7 +58,7 @@ class BackgroundServicesTest {
assertEquals(1, SyncAuth.signIn.testGetValue().size) assertEquals(1, SyncAuth.signIn.testGetValue().size)
assertEquals(null, SyncAuth.signIn.testGetValue().single().extra) assertEquals(null, SyncAuth.signIn.testGetValue().single().extra)
verify { settings.signedInFxaAccount = true } verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings) confirmVerified(settings)
} }
@Test @Test
@ -76,7 +70,7 @@ class BackgroundServicesTest {
assertEquals(1, SyncAuth.signUp.testGetValue().size) assertEquals(1, SyncAuth.signUp.testGetValue().size)
assertEquals(null, SyncAuth.signUp.testGetValue().single().extra) assertEquals(null, SyncAuth.signUp.testGetValue().single().extra)
verify { settings.signedInFxaAccount = true } verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings) confirmVerified(settings)
} }
@Test @Test
@ -88,27 +82,7 @@ class BackgroundServicesTest {
assertEquals(1, SyncAuth.paired.testGetValue().size) assertEquals(1, SyncAuth.paired.testGetValue().size)
assertEquals(null, SyncAuth.paired.testGetValue().single().extra) assertEquals(null, SyncAuth.paired.testGetValue().single().extra)
verify { settings.signedInFxaAccount = true } verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings) confirmVerified(settings)
}
@Test
fun `telemetry account observer tracks shared copy event`() {
val account = mockk<OAuthAccount>()
registry.notifyObservers { onAuthenticated(account, AuthType.MigratedCopy) }
verify { metrics wasNot Called }
verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings)
}
@Test
fun `telemetry account observer tracks shared reuse event`() {
val account = mockk<OAuthAccount>()
registry.notifyObservers { onAuthenticated(account, AuthType.MigratedReuse) }
verify { metrics wasNot Called }
verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings)
} }
@Test @Test
@ -120,7 +94,7 @@ class BackgroundServicesTest {
assertEquals(1, SyncAuth.recovered.testGetValue().size) assertEquals(1, SyncAuth.recovered.testGetValue().size)
assertEquals(null, SyncAuth.recovered.testGetValue().single().extra) assertEquals(null, SyncAuth.recovered.testGetValue().single().extra)
verify { settings.signedInFxaAccount = true } verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings) confirmVerified(settings)
} }
@Test @Test
@ -132,7 +106,7 @@ class BackgroundServicesTest {
assertEquals(1, SyncAuth.otherExternal.testGetValue().size) assertEquals(1, SyncAuth.otherExternal.testGetValue().size)
assertEquals(null, SyncAuth.otherExternal.testGetValue().single().extra) assertEquals(null, SyncAuth.otherExternal.testGetValue().single().extra)
verify { settings.signedInFxaAccount = true } verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings) confirmVerified(settings)
} }
@Test @Test
@ -144,17 +118,7 @@ class BackgroundServicesTest {
assertEquals(1, SyncAuth.otherExternal.testGetValue().size) assertEquals(1, SyncAuth.otherExternal.testGetValue().size)
assertEquals(null, SyncAuth.otherExternal.testGetValue().single().extra) assertEquals(null, SyncAuth.otherExternal.testGetValue().single().extra)
verify { settings.signedInFxaAccount = true } verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings) confirmVerified(settings)
}
@Test
fun `telemetry account observer does not track existing account`() {
val account = mockk<OAuthAccount>()
registry.notifyObservers { onAuthenticated(account, AuthType.Existing) }
verify { metrics wasNot Called }
verify { settings.signedInFxaAccount = true }
confirmVerified(metrics, settings)
} }
@Test @Test
@ -164,6 +128,6 @@ class BackgroundServicesTest {
assertEquals(1, SyncAuth.signOut.testGetValue().size) assertEquals(1, SyncAuth.signOut.testGetValue().size)
assertEquals(null, SyncAuth.signOut.testGetValue().single().extra) assertEquals(null, SyncAuth.signOut.testGetValue().single().extra)
verify { settings.signedInFxaAccount = false } verify { settings.signedInFxaAccount = false }
confirmVerified(metrics, settings) confirmVerified(settings)
} }
} }

Loading…
Cancel
Save