mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/24210: Remove wrapper from "default browser" events.
This commit is contained in:
parent
692f15b64c
commit
cf9b6193ce
@ -68,6 +68,7 @@ import mozilla.components.support.locale.LocaleAwareAppCompatActivity
|
|||||||
import mozilla.components.support.utils.SafeIntent
|
import mozilla.components.support.utils.SafeIntent
|
||||||
import mozilla.components.support.utils.toSafeIntent
|
import mozilla.components.support.utils.toSafeIntent
|
||||||
import mozilla.components.support.webextensions.WebExtensionPopupFeature
|
import mozilla.components.support.webextensions.WebExtensionPopupFeature
|
||||||
|
import mozilla.telemetry.glean.private.NoExtras
|
||||||
import org.mozilla.fenix.GleanMetrics.Events
|
import org.mozilla.fenix.GleanMetrics.Events
|
||||||
import org.mozilla.fenix.GleanMetrics.Metrics
|
import org.mozilla.fenix.GleanMetrics.Metrics
|
||||||
import org.mozilla.fenix.addons.AddonDetailsFragmentDirections
|
import org.mozilla.fenix.addons.AddonDetailsFragmentDirections
|
||||||
@ -172,7 +173,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|||||||
StartSearchIntentProcessor(components.analytics.metrics),
|
StartSearchIntentProcessor(components.analytics.metrics),
|
||||||
OpenBrowserIntentProcessor(this, ::getIntentSessionId),
|
OpenBrowserIntentProcessor(this, ::getIntentSessionId),
|
||||||
OpenSpecificTabIntentProcessor(this),
|
OpenSpecificTabIntentProcessor(this),
|
||||||
DefaultBrowserIntentProcessor(this, components.analytics.metrics)
|
DefaultBrowserIntentProcessor(this)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +347,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settings().checkIfFenixIsDefaultBrowserOnAppResume()) {
|
if (settings().checkIfFenixIsDefaultBrowserOnAppResume()) {
|
||||||
metrics.track(Event.ChangedToDefaultBrowser)
|
Events.defaultBrowserChanged.record(NoExtras())
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultBrowserNotificationWorker.setDefaultBrowserNotificationIfNeeded(applicationContext)
|
DefaultBrowserNotificationWorker.setDefaultBrowserNotificationIfNeeded(applicationContext)
|
||||||
|
@ -122,8 +122,6 @@ sealed class Event {
|
|||||||
object AddonsOpenInSettings : Event()
|
object AddonsOpenInSettings : Event()
|
||||||
object VoiceSearchTapped : Event()
|
object VoiceSearchTapped : Event()
|
||||||
object SearchWidgetInstalled : Event()
|
object SearchWidgetInstalled : Event()
|
||||||
object ChangedToDefaultBrowser : Event()
|
|
||||||
object DefaultBrowserNotifTapped : Event()
|
|
||||||
|
|
||||||
object ProgressiveWebAppOpenFromHomescreenTap : Event()
|
object ProgressiveWebAppOpenFromHomescreenTap : Event()
|
||||||
object ProgressiveWebAppInstallAsShortcut : Event()
|
object ProgressiveWebAppInstallAsShortcut : Event()
|
||||||
|
@ -122,12 +122,7 @@ private val Event.wrapper: EventWrapper<*>?
|
|||||||
is Event.ToolbarMenuShown -> EventWrapper<NoExtraKeys>(
|
is Event.ToolbarMenuShown -> EventWrapper<NoExtraKeys>(
|
||||||
{ Events.toolbarMenuVisible.record(it) }
|
{ Events.toolbarMenuVisible.record(it) }
|
||||||
)
|
)
|
||||||
is Event.ChangedToDefaultBrowser -> EventWrapper<NoExtraKeys>(
|
|
||||||
{ Events.defaultBrowserChanged.record(it) }
|
|
||||||
)
|
|
||||||
is Event.DefaultBrowserNotifTapped -> EventWrapper<NoExtraKeys>(
|
|
||||||
{ Events.defaultBrowserNotifTapped.record(it) }
|
|
||||||
)
|
|
||||||
is Event.CustomTabsMenuOpened -> EventWrapper<NoExtraKeys>(
|
is Event.CustomTabsMenuOpened -> EventWrapper<NoExtraKeys>(
|
||||||
{ CustomTab.menu.record(it) }
|
{ CustomTab.menu.record(it) }
|
||||||
)
|
)
|
||||||
@ -140,10 +135,6 @@ private val Event.wrapper: EventWrapper<*>?
|
|||||||
is Event.NormalAndPrivateUriOpened -> EventWrapper<NoExtraKeys>(
|
is Event.NormalAndPrivateUriOpened -> EventWrapper<NoExtraKeys>(
|
||||||
{ Events.normalAndPrivateUriCount.add(1) }
|
{ Events.normalAndPrivateUriCount.add(1) }
|
||||||
)
|
)
|
||||||
is Event.PreferenceToggled -> EventWrapper(
|
|
||||||
{ Events.preferenceToggled.record(it) },
|
|
||||||
{ Events.preferenceToggledKeys.valueOf(it) }
|
|
||||||
)
|
|
||||||
is Event.HistoryOpened -> EventWrapper<NoExtraKeys>(
|
is Event.HistoryOpened -> EventWrapper<NoExtraKeys>(
|
||||||
{ History.opened.record(it) }
|
{ History.opened.record(it) }
|
||||||
)
|
)
|
||||||
@ -235,11 +226,6 @@ private val Event.wrapper: EventWrapper<*>?
|
|||||||
is Event.NotificationMediaPause -> EventWrapper<NoExtraKeys>(
|
is Event.NotificationMediaPause -> EventWrapper<NoExtraKeys>(
|
||||||
{ MediaNotification.pause.record(it) }
|
{ MediaNotification.pause.record(it) }
|
||||||
)
|
)
|
||||||
|
|
||||||
is Event.OpenedLink -> EventWrapper(
|
|
||||||
{ Events.openedLink.record(it) },
|
|
||||||
{ Events.openedLinkKeys.valueOf(it) }
|
|
||||||
)
|
|
||||||
is Event.OpenLogins -> EventWrapper<NoExtraKeys>(
|
is Event.OpenLogins -> EventWrapper<NoExtraKeys>(
|
||||||
{ Logins.openLogins.record(it) }
|
{ Logins.openLogins.record(it) }
|
||||||
)
|
)
|
||||||
@ -459,11 +445,6 @@ private val Event.wrapper: EventWrapper<*>?
|
|||||||
is Event.HomeScreenCustomizedHomeClicked -> EventWrapper<NoExtraKeys>(
|
is Event.HomeScreenCustomizedHomeClicked -> EventWrapper<NoExtraKeys>(
|
||||||
{ HomeScreen.customizeHomeClicked.record(it) }
|
{ HomeScreen.customizeHomeClicked.record(it) }
|
||||||
)
|
)
|
||||||
is Event.TabViewSettingChanged -> EventWrapper(
|
|
||||||
{ Events.tabViewChanged.record(it) },
|
|
||||||
{ Events.tabViewChangedKeys.valueOf(it) }
|
|
||||||
)
|
|
||||||
|
|
||||||
is Event.BrowserToolbarHomeButtonClicked -> EventWrapper<NoExtraKeys>(
|
is Event.BrowserToolbarHomeButtonClicked -> EventWrapper<NoExtraKeys>(
|
||||||
{ Events.browserToolbarHomeTapped.record(it) }
|
{ Events.browserToolbarHomeTapped.record(it) }
|
||||||
)
|
)
|
||||||
|
@ -6,9 +6,9 @@ package org.mozilla.fenix.home.intent
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
|
import mozilla.telemetry.glean.private.NoExtras
|
||||||
|
import org.mozilla.fenix.GleanMetrics.Events
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
|
||||||
import org.mozilla.fenix.components.metrics.MetricController
|
|
||||||
import org.mozilla.fenix.ext.openSetDefaultBrowserOption
|
import org.mozilla.fenix.ext.openSetDefaultBrowserOption
|
||||||
import org.mozilla.fenix.ext.settings
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.onboarding.DefaultBrowserNotificationWorker.Companion.isDefaultBrowserNotificationIntent
|
import org.mozilla.fenix.onboarding.DefaultBrowserNotificationWorker.Companion.isDefaultBrowserNotificationIntent
|
||||||
@ -21,13 +21,12 @@ import org.mozilla.fenix.onboarding.DefaultBrowserNotificationWorker.Companion.i
|
|||||||
*/
|
*/
|
||||||
class DefaultBrowserIntentProcessor(
|
class DefaultBrowserIntentProcessor(
|
||||||
private val activity: HomeActivity,
|
private val activity: HomeActivity,
|
||||||
private val metrics: MetricController
|
|
||||||
) : HomeIntentProcessor {
|
) : HomeIntentProcessor {
|
||||||
|
|
||||||
override fun process(intent: Intent, navController: NavController, out: Intent): Boolean {
|
override fun process(intent: Intent, navController: NavController, out: Intent): Boolean {
|
||||||
return if (isDefaultBrowserNotificationIntent(intent)) {
|
return if (isDefaultBrowserNotificationIntent(intent)) {
|
||||||
activity.openSetDefaultBrowserOption()
|
activity.openSetDefaultBrowserOption()
|
||||||
metrics.track(Event.DefaultBrowserNotifTapped)
|
Events.defaultBrowserNotifTapped.record(NoExtras())
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -16,7 +16,6 @@ import org.junit.runner.RunWith
|
|||||||
import org.mozilla.fenix.GleanMetrics.Addons
|
import org.mozilla.fenix.GleanMetrics.Addons
|
||||||
import org.mozilla.fenix.GleanMetrics.Awesomebar
|
import org.mozilla.fenix.GleanMetrics.Awesomebar
|
||||||
import org.mozilla.fenix.GleanMetrics.CreditCards
|
import org.mozilla.fenix.GleanMetrics.CreditCards
|
||||||
import org.mozilla.fenix.GleanMetrics.Events
|
|
||||||
import org.mozilla.fenix.GleanMetrics.History
|
import org.mozilla.fenix.GleanMetrics.History
|
||||||
import org.mozilla.fenix.GleanMetrics.RecentBookmarks
|
import org.mozilla.fenix.GleanMetrics.RecentBookmarks
|
||||||
import org.mozilla.fenix.GleanMetrics.RecentlyVisitedHomepage
|
import org.mozilla.fenix.GleanMetrics.RecentlyVisitedHomepage
|
||||||
@ -147,17 +146,6 @@ class GleanMetricsServiceTest {
|
|||||||
assertEquals("123", events[0].extra!!["addon_id"])
|
assertEquals("123", events[0].extra!!["addon_id"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `default browser events are correctly recorded`() {
|
|
||||||
assertFalse(Events.defaultBrowserChanged.testHasValue())
|
|
||||||
gleanService.track(Event.ChangedToDefaultBrowser)
|
|
||||||
assertTrue(Events.defaultBrowserChanged.testHasValue())
|
|
||||||
|
|
||||||
assertFalse(Events.defaultBrowserNotifTapped.testHasValue())
|
|
||||||
gleanService.track(Event.DefaultBrowserNotifTapped)
|
|
||||||
assertTrue(Events.defaultBrowserNotifTapped.testHasValue())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `Home screen recent bookmarks events are correctly recorded`() {
|
fun `Home screen recent bookmarks events are correctly recorded`() {
|
||||||
assertFalse(RecentBookmarks.shown.testHasValue())
|
assertFalse(RecentBookmarks.shown.testHasValue())
|
||||||
|
@ -10,10 +10,14 @@ import io.mockk.Called
|
|||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
|
import mozilla.components.service.glean.testing.GleanTestRule
|
||||||
import mozilla.components.support.test.robolectric.testContext
|
import mozilla.components.support.test.robolectric.testContext
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
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.Events
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.components.metrics.MetricController
|
import org.mozilla.fenix.components.metrics.MetricController
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
@ -21,11 +25,14 @@ import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
|||||||
@RunWith(FenixRobolectricTestRunner::class)
|
@RunWith(FenixRobolectricTestRunner::class)
|
||||||
class DefaultBrowserIntentProcessorTest {
|
class DefaultBrowserIntentProcessorTest {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val gleanTestRule = GleanTestRule(testContext)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `do not process blank intents`() {
|
fun `do not process blank intents`() {
|
||||||
val navController: NavController = mockk()
|
val navController: NavController = mockk()
|
||||||
val out: Intent = mockk()
|
val out: Intent = mockk()
|
||||||
val result = DefaultBrowserIntentProcessor(mockk(), mockk())
|
val result = DefaultBrowserIntentProcessor(mockk())
|
||||||
.process(Intent(), navController, out)
|
.process(Intent(), navController, out)
|
||||||
|
|
||||||
assertFalse(result)
|
assertFalse(result)
|
||||||
@ -47,11 +54,14 @@ class DefaultBrowserIntentProcessorTest {
|
|||||||
every { activity.applicationContext } returns testContext
|
every { activity.applicationContext } returns testContext
|
||||||
every { metrics.track(any()) } returns Unit
|
every { metrics.track(any()) } returns Unit
|
||||||
|
|
||||||
val result = DefaultBrowserIntentProcessor(activity, metrics)
|
assertFalse(Events.defaultBrowserNotifTapped.testHasValue())
|
||||||
|
|
||||||
|
val result = DefaultBrowserIntentProcessor(activity)
|
||||||
.process(intent, navController, out)
|
.process(intent, navController, out)
|
||||||
|
|
||||||
assert(result)
|
assert(result)
|
||||||
verify { metrics.track(any()) }
|
|
||||||
|
assertTrue(Events.defaultBrowserNotifTapped.testHasValue())
|
||||||
verify { navController wasNot Called }
|
verify { navController wasNot Called }
|
||||||
verify { out wasNot Called }
|
verify { out wasNot Called }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user