|
|
|
@ -10,6 +10,7 @@ import io.mockk.impl.annotations.MockK
|
|
|
|
|
import io.mockk.mockk
|
|
|
|
|
import io.mockk.verify
|
|
|
|
|
import io.mockk.verifyAll
|
|
|
|
|
import mozilla.components.browser.toolbar.facts.ToolbarFacts
|
|
|
|
|
import mozilla.components.feature.awesomebar.facts.AwesomeBarFacts
|
|
|
|
|
import mozilla.components.feature.customtabs.CustomTabsFacts
|
|
|
|
|
import mozilla.components.feature.media.facts.MediaFacts
|
|
|
|
@ -30,6 +31,7 @@ import org.junit.Before
|
|
|
|
|
import org.junit.Rule
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
|
import org.mozilla.fenix.GleanMetrics.CustomTab
|
|
|
|
|
import org.mozilla.fenix.GleanMetrics.LoginDialog
|
|
|
|
|
import org.mozilla.fenix.GleanMetrics.MediaNotification
|
|
|
|
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
|
|
|
@ -411,8 +413,6 @@ class MetricControllerTest {
|
|
|
|
|
|
|
|
|
|
val simpleMappings = listOf(
|
|
|
|
|
// CreditCardAutofillDialogFacts.Items is already tested.
|
|
|
|
|
Triple(Component.FEATURE_CUSTOMTABS, CustomTabsFacts.Items.CLOSE, Event.CustomTabsClosed),
|
|
|
|
|
Triple(Component.FEATURE_CUSTOMTABS, CustomTabsFacts.Items.ACTION_BUTTON, Event.CustomTabsActionTapped),
|
|
|
|
|
Triple(Component.FEATURE_PWA, ProgressiveWebAppFacts.Items.HOMESCREEN_ICON_TAP, Event.ProgressiveWebAppOpenFromHomescreenTap),
|
|
|
|
|
Triple(Component.FEATURE_PWA, ProgressiveWebAppFacts.Items.INSTALL_SHORTCUT, Event.ProgressiveWebAppInstallAsShortcut),
|
|
|
|
|
Triple(Component.FEATURE_SYNCEDTABS, SyncedTabsFacts.Items.SYNCED_TABS_SUGGESTION_CLICKED, Event.SyncedTabSuggestionClicked),
|
|
|
|
@ -474,6 +474,41 @@ class MetricControllerTest {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `WHEN processing a CustomTab fact THEN the right metric is recorded`() {
|
|
|
|
|
val controller = ReleaseMetricController(emptyList(), { true }, { true }, mockk())
|
|
|
|
|
val action = mockk<Action>(relaxed = true)
|
|
|
|
|
var fact: Fact
|
|
|
|
|
|
|
|
|
|
with(controller) {
|
|
|
|
|
fact = Fact(
|
|
|
|
|
Component.BROWSER_TOOLBAR,
|
|
|
|
|
action,
|
|
|
|
|
ToolbarFacts.Items.MENU,
|
|
|
|
|
metadata = mapOf("customTab" to true)
|
|
|
|
|
)
|
|
|
|
|
fact.process()
|
|
|
|
|
|
|
|
|
|
assertEquals(true, CustomTab.menu.testHasValue())
|
|
|
|
|
assertEquals(1, CustomTab.menu.testGetValue().size)
|
|
|
|
|
assertEquals(null, CustomTab.menu.testGetValue().single().extra)
|
|
|
|
|
|
|
|
|
|
fact = Fact(Component.FEATURE_CUSTOMTABS, action, CustomTabsFacts.Items.ACTION_BUTTON)
|
|
|
|
|
fact.process()
|
|
|
|
|
|
|
|
|
|
assertEquals(true, CustomTab.actionButton.testHasValue())
|
|
|
|
|
assertEquals(1, CustomTab.actionButton.testGetValue().size)
|
|
|
|
|
assertEquals(null, CustomTab.actionButton.testGetValue().single().extra)
|
|
|
|
|
|
|
|
|
|
fact = Fact(Component.FEATURE_CUSTOMTABS, action, CustomTabsFacts.Items.CLOSE)
|
|
|
|
|
fact.process()
|
|
|
|
|
|
|
|
|
|
assertEquals(true, CustomTab.closed.testHasValue())
|
|
|
|
|
assertEquals(1, CustomTab.closed.testGetValue().size)
|
|
|
|
|
assertEquals(null, CustomTab.closed.testGetValue().single().extra)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `search term group events should be sent to enabled service`() {
|
|
|
|
|
val controller = ReleaseMetricController(
|
|
|
|
|