Commit edcee712 authored by mcarare's avatar mcarare Committed by Mihai Adrian Carare
Browse files

For #17400: Select tab opened from collection.

parent e110bb32
...@@ -240,6 +240,7 @@ class HomeFragment : Fragment() { ...@@ -240,6 +240,7 @@ class HomeFragment : Fragment() {
addTabUseCase = components.useCases.tabsUseCases.addTab, addTabUseCase = components.useCases.tabsUseCases.addTab,
restoreUseCase = components.useCases.tabsUseCases.restore, restoreUseCase = components.useCases.tabsUseCases.restore,
reloadUrlUseCase = components.useCases.sessionUseCases.reload, reloadUrlUseCase = components.useCases.sessionUseCases.reload,
selectTabUseCase = components.useCases.tabsUseCases.selectTab,
fragmentStore = homeFragmentStore, fragmentStore = homeFragmentStore,
navController = findNavController(), navController = findNavController(),
viewLifecycleScope = viewLifecycleOwner.lifecycleScope, viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
......
...@@ -179,6 +179,7 @@ class DefaultSessionControlController( ...@@ -179,6 +179,7 @@ class DefaultSessionControlController(
private val addTabUseCase: TabsUseCases.AddNewTabUseCase, private val addTabUseCase: TabsUseCases.AddNewTabUseCase,
private val restoreUseCase: TabsUseCases.RestoreUseCase, private val restoreUseCase: TabsUseCases.RestoreUseCase,
private val reloadUrlUseCase: SessionUseCases.ReloadUrlUseCase, private val reloadUrlUseCase: SessionUseCases.ReloadUrlUseCase,
private val selectTabUseCase: TabsUseCases.SelectTabUseCase,
private val fragmentStore: HomeFragmentStore, private val fragmentStore: HomeFragmentStore,
private val navController: NavController, private val navController: NavController,
private val viewLifecycleScope: CoroutineScope, private val viewLifecycleScope: CoroutineScope,
...@@ -216,6 +217,7 @@ class DefaultSessionControlController( ...@@ -216,6 +217,7 @@ class DefaultSessionControlController(
tab, tab,
onTabRestored = { onTabRestored = {
activity.openToBrowser(BrowserDirection.FromHome) activity.openToBrowser(BrowserDirection.FromHome)
sessionManager.selectedSession?.let { selectTabUseCase.invoke(it) }
reloadUrlUseCase.invoke(sessionManager.selectedSession) reloadUrlUseCase.invoke(sessionManager.selectedSession)
}, },
onFailure = { onFailure = {
......
...@@ -12,6 +12,7 @@ import io.mockk.verify ...@@ -12,6 +12,7 @@ import io.mockk.verify
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineScope import kotlinx.coroutines.test.TestCoroutineScope
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.state.search.SearchEngine import mozilla.components.browser.state.search.SearchEngine
import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.BrowserState
...@@ -61,6 +62,7 @@ class DefaultSessionControlControllerTest { ...@@ -61,6 +62,7 @@ class DefaultSessionControlControllerTest {
private val tabCollectionStorage: TabCollectionStorage = mockk(relaxed = true) private val tabCollectionStorage: TabCollectionStorage = mockk(relaxed = true)
private val tabsUseCases: TabsUseCases = mockk(relaxed = true) private val tabsUseCases: TabsUseCases = mockk(relaxed = true)
private val reloadUrlUseCase: SessionUseCases = mockk(relaxed = true) private val reloadUrlUseCase: SessionUseCases = mockk(relaxed = true)
private val selectTabUseCase: TabsUseCases = mockk(relaxed = true)
private val hideOnboarding: () -> Unit = mockk(relaxed = true) private val hideOnboarding: () -> Unit = mockk(relaxed = true)
private val registerCollectionStorageObserver: () -> Unit = mockk(relaxed = true) private val registerCollectionStorageObserver: () -> Unit = mockk(relaxed = true)
private val showTabTray: () -> Unit = mockk(relaxed = true) private val showTabTray: () -> Unit = mockk(relaxed = true)
...@@ -122,6 +124,7 @@ class DefaultSessionControlControllerTest { ...@@ -122,6 +124,7 @@ class DefaultSessionControlControllerTest {
tabCollectionStorage = tabCollectionStorage, tabCollectionStorage = tabCollectionStorage,
addTabUseCase = tabsUseCases.addTab, addTabUseCase = tabsUseCases.addTab,
reloadUrlUseCase = reloadUrlUseCase.reload, reloadUrlUseCase = reloadUrlUseCase.reload,
selectTabUseCase = selectTabUseCase.selectTab,
restoreUseCase = restoreUseCase, restoreUseCase = restoreUseCase,
fragmentStore = fragmentStore, fragmentStore = fragmentStore,
navController = navController, navController = navController,
...@@ -194,10 +197,14 @@ class DefaultSessionControlControllerTest { ...@@ -194,10 +197,14 @@ class DefaultSessionControlControllerTest {
every { restore(activity, engine, restoreSessionId = false) } returns restoredTab every { restore(activity, engine, restoreSessionId = false) } returns restoredTab
} }
val session = mockk<Session>()
every { sessionManager.selectedSession } returns session
controller.handleCollectionOpenTabClicked(tab) controller.handleCollectionOpenTabClicked(tab)
verify { metrics.track(Event.CollectionTabRestored) } verify { metrics.track(Event.CollectionTabRestored) }
verify { activity.openToBrowser(BrowserDirection.FromHome) } verify { activity.openToBrowser(BrowserDirection.FromHome) }
verify { selectTabUseCase.selectTab.invoke(session) }
verify { reloadUrlUseCase.reload } verify { reloadUrlUseCase.reload }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment