Commit 4da4c058 authored by Mugurell's avatar Mugurell Committed by plingurar@mozilla.com
Browse files

Bug 2020810 - part 3 - Add a new toolbar_tabstray_swipe telemetry probe r=android-reviewers,skhan

This will allow understanding the usefulness of the new feature of
opening the tabs tray from vertical swipes over the toolbar.

The new probe has a name similar to the existing toolbar_tab_swipe
one for when the user does a horizontal swipe over the toolbar to
switching between adjacent tabs.

Differential Revision: https://phabricator.services.mozilla.com/D286900
parent d30ebe0d
Loading
Loading
Loading
Loading
+16 −0
Changes for mobile/android/fenix/app/metrics.yaml: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -478,6 +478,22 @@ events:
    metadata:
      tags:
        - Toolbar
  toolbar_tabstray_swipe:
    type: event
    description: |
      A user swiped the toolbar up or down to open the tabs tray.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2020810
    data_reviews:
      - https://phabricator.services.mozilla.com/D286900
    data_sensitivity:
      - interaction
    notification_emails:
      - android-probes@mozilla.com
    expires: never
    metadata:
      tags:
        - Toolbar
  toolbar_tab_swipe_cfr_shown:
    type: event
    description: |
+2 −0
Changes for mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/gestures/ToolbarVerticalGesturesHandler.kt: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -83,6 +83,8 @@ class ToolbarVerticalGesturesHandler(
        }

        if (isSwipeValid()) {
            Events.toolbarTabstraySwipe.record(NoExtras())

            navController.nav(
                navController.currentDestination?.id,
                NavGraphDirections.actionGlobalTabManagementFragment(
+12 −0
Changes for mobile/android/fenix/app/src/test/java/org/mozilla/fenix/components/toolbar/gestures/ToolbarVerticalGesturesHandlerTest.kt: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,9 +15,13 @@ import io.mockk.mockk
import io.mockk.spyk
import io.mockk.verify
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.BrowserFragmentDirections
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
@@ -28,6 +32,7 @@ import org.mozilla.fenix.components.appstate.AppState
import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.components.toolbar.ToolbarPosition.BOTTOM
import org.mozilla.fenix.components.toolbar.ToolbarPosition.TOP
import org.mozilla.fenix.helpers.FenixGleanTestRule
import org.mozilla.fenix.tabstray.redux.state.Page
import org.mozilla.fenix.tabstray.ui.AccessPoint
import org.robolectric.ParameterizedRobolectricTestRunner
@@ -40,6 +45,9 @@ private const val TOOLBAR_HEIGHT = 100

@RunWith(ParameterizedRobolectricTestRunner::class)
class ToolbarVerticalGesturesHandlerTest(private val scenario: Scenario) {
    @get:Rule
    val gleanTestRule = FenixGleanTestRule(testContext)

    private val toolbarLayout = spyk(View(testContext))
    private var navbarLayout: View? = null
    private val appStore = AppStore(AppState(mode = scenario.browsingMode))
@@ -91,6 +99,8 @@ class ToolbarVerticalGesturesHandlerTest(private val scenario: Scenario) {
        }

        if (expectedTabsTrayNavigations > 0) {
            assertNotNull(Events.toolbarTabstraySwipe.testGetValue())

            verify(exactly = expectedTabsTrayNavigations) {
                navController.navigate(
                    BrowserFragmentDirections.actionGlobalTabManagementFragment(
@@ -102,6 +112,8 @@ class ToolbarVerticalGesturesHandlerTest(private val scenario: Scenario) {
                )
            }
        } else {
            assertNull(Events.toolbarTabstraySwipe.testGetValue())

            verify(exactly = 0) { navController.navigate(any<NavDirections>(), anyNullable<NavOptions?>()) }
        }
    }