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() {
addTabUseCase = components.useCases.tabsUseCases.addTab,
restoreUseCase = components.useCases.tabsUseCases.restore,
reloadUrlUseCase = components.useCases.sessionUseCases.reload,
selectTabUseCase = components.useCases.tabsUseCases.selectTab,
fragmentStore = homeFragmentStore,
navController = findNavController(),
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
......
......@@ -179,6 +179,7 @@ class DefaultSessionControlController(
private val addTabUseCase: TabsUseCases.AddNewTabUseCase,
private val restoreUseCase: TabsUseCases.RestoreUseCase,
private val reloadUrlUseCase: SessionUseCases.ReloadUrlUseCase,
private val selectTabUseCase: TabsUseCases.SelectTabUseCase,
private val fragmentStore: HomeFragmentStore,
private val navController: NavController,
private val viewLifecycleScope: CoroutineScope,
......@@ -216,6 +217,7 @@ class DefaultSessionControlController(
tab,
onTabRestored = {
activity.openToBrowser(BrowserDirection.FromHome)
sessionManager.selectedSession?.let { selectTabUseCase.invoke(it) }
reloadUrlUseCase.invoke(sessionManager.selectedSession)
},
onFailure = {
......
......@@ -12,6 +12,7 @@ import io.mockk.verify
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineScope
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.state.search.SearchEngine
import mozilla.components.browser.state.state.BrowserState
......@@ -61,6 +62,7 @@ class DefaultSessionControlControllerTest {
private val tabCollectionStorage: TabCollectionStorage = mockk(relaxed = true)
private val tabsUseCases: TabsUseCases = 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 registerCollectionStorageObserver: () -> Unit = mockk(relaxed = true)
private val showTabTray: () -> Unit = mockk(relaxed = true)
......@@ -122,6 +124,7 @@ class DefaultSessionControlControllerTest {
tabCollectionStorage = tabCollectionStorage,
addTabUseCase = tabsUseCases.addTab,
reloadUrlUseCase = reloadUrlUseCase.reload,
selectTabUseCase = selectTabUseCase.selectTab,
restoreUseCase = restoreUseCase,
fragmentStore = fragmentStore,
navController = navController,
......@@ -194,10 +197,14 @@ class DefaultSessionControlControllerTest {
every { restore(activity, engine, restoreSessionId = false) } returns restoredTab
}
val session = mockk<Session>()
every { sessionManager.selectedSession } returns session
controller.handleCollectionOpenTabClicked(tab)
verify { metrics.track(Event.CollectionTabRestored) }
verify { activity.openToBrowser(BrowserDirection.FromHome) }
verify { selectTabUseCase.selectTab.invoke(session) }
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