2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

For #15366: Add recently closed tabs metrics from history fragment.

This commit is contained in:
mcarare 2020-11-25 14:18:18 +02:00 committed by Mihai Adrian Carare
parent 2f360eb474
commit d233229ce4
3 changed files with 12 additions and 4 deletions

View File

@ -15,6 +15,8 @@ import mozilla.components.concept.engine.prompt.ShareData
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
@Suppress("TooManyFunctions") @Suppress("TooManyFunctions")
interface HistoryController { interface HistoryController {
@ -43,7 +45,8 @@ class DefaultHistoryController(
private val displayDeleteAll: () -> Unit, private val displayDeleteAll: () -> Unit,
private val invalidateOptionsMenu: () -> Unit, private val invalidateOptionsMenu: () -> Unit,
private val deleteHistoryItems: (Set<HistoryItem>) -> Unit, private val deleteHistoryItems: (Set<HistoryItem>) -> Unit,
private val syncHistory: suspend () -> Unit private val syncHistory: suspend () -> Unit,
private val metrics: MetricController
) : HistoryController { ) : HistoryController {
override fun handleOpen(item: HistoryItem, mode: BrowsingMode?) { override fun handleOpen(item: HistoryItem, mode: BrowsingMode?) {
openToBrowser(item, mode) openToBrowser(item, mode)
@ -111,5 +114,6 @@ class DefaultHistoryController(
HistoryFragmentDirections.actionGlobalRecentlyClosed(), HistoryFragmentDirections.actionGlobalRecentlyClosed(),
NavOptions.Builder().setPopUpTo(R.id.recentlyClosedFragment, true).build() NavOptions.Builder().setPopUpTo(R.id.recentlyClosedFragment, true).build()
) )
metrics.track(Event.RecentlyClosedTabsOpened)
} }
} }

View File

@ -92,7 +92,8 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
::displayDeleteAllDialog, ::displayDeleteAllDialog,
::invalidateOptionsMenu, ::invalidateOptionsMenu,
::deleteHistoryItems, ::deleteHistoryItems,
::syncHistory ::syncHistory,
requireComponents.analytics.metrics
) )
historyInteractor = HistoryInteractor( historyInteractor = HistoryInteractor(
historyController historyController

View File

@ -25,6 +25,7 @@ import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.ext.directionsEq import org.mozilla.fenix.ext.directionsEq
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@ -45,6 +46,7 @@ class HistoryControllerTest {
private val invalidateOptionsMenu: () -> Unit = mockk(relaxed = true) private val invalidateOptionsMenu: () -> Unit = mockk(relaxed = true)
private val deleteHistoryItems: (Set<HistoryItem>) -> Unit = mockk(relaxed = true) private val deleteHistoryItems: (Set<HistoryItem>) -> Unit = mockk(relaxed = true)
private val syncHistory: suspend () -> Unit = mockk(relaxed = true) private val syncHistory: suspend () -> Unit = mockk(relaxed = true)
private val metrics: MetricController = mockk(relaxed = true)
private val controller = DefaultHistoryController( private val controller = DefaultHistoryController(
store, store,
navController, navController,
@ -56,7 +58,8 @@ class HistoryControllerTest {
displayDeleteAll, displayDeleteAll,
invalidateOptionsMenu, invalidateOptionsMenu,
deleteHistoryItems, deleteHistoryItems,
syncHistory syncHistory,
metrics
) )
@Before @Before