mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/12311: BrowserToolbarController: Stop SessionFeature and release session from EngineView.
This commit is contained in:
parent
47e60525ff
commit
f3cfdc5058
@ -211,6 +211,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
||||
isPrivate = (activity as HomeActivity).browsingModeManager.mode.isPrivate
|
||||
),
|
||||
sessionManager = requireComponents.core.sessionManager,
|
||||
sessionFeature = sessionFeature,
|
||||
findInPageLauncher = { findInPageIntegration.withFeature { it.launch() } },
|
||||
engineView = engineView,
|
||||
swipeRefresh = swipeRefresh,
|
||||
|
@ -19,6 +19,8 @@ import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
import mozilla.components.concept.engine.prompt.ShareData
|
||||
import mozilla.components.feature.session.SessionFeature
|
||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||
import mozilla.components.support.ktx.kotlin.isUrl
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.NavGraphDirections
|
||||
@ -61,6 +63,7 @@ class DefaultBrowserToolbarController(
|
||||
private val activity: HomeActivity,
|
||||
private val navController: NavController,
|
||||
private val readerModeController: ReaderModeController,
|
||||
private val sessionFeature: ViewBoundFeatureWrapper<SessionFeature>,
|
||||
private val sessionManager: SessionManager,
|
||||
private val findInPageLauncher: () -> Unit,
|
||||
private val engineView: EngineView,
|
||||
@ -260,8 +263,10 @@ class DefaultBrowserToolbarController(
|
||||
}
|
||||
}
|
||||
ToolbarMenu.Item.OpenInFenix -> {
|
||||
// Release the session from this view so that it can immediately be rendered by a different view
|
||||
engineView.release()
|
||||
// Stop the SessionFeature from updating the EngineView and let it release the session
|
||||
// from the EngineView so that it can immediately be rendered by a different view once
|
||||
// we switch to the actual browser.
|
||||
sessionFeature.get()?.release()
|
||||
|
||||
// Strip the CustomTabConfig to turn this Session into a regular tab and then select it
|
||||
customTabSession!!.customTabConfig = null
|
||||
|
@ -33,9 +33,11 @@ import mozilla.components.browser.state.state.createTab
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
import mozilla.components.feature.search.SearchUseCases
|
||||
import mozilla.components.feature.session.SessionFeature
|
||||
import mozilla.components.feature.session.SessionUseCases
|
||||
import mozilla.components.feature.tab.collections.TabCollection
|
||||
import mozilla.components.feature.tabs.TabsUseCases
|
||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||
import mozilla.components.support.test.rule.MainCoroutineRule
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
@ -93,6 +95,8 @@ class DefaultBrowserToolbarControllerTest {
|
||||
@RelaxedMockK private lateinit var tabCollectionStorage: TabCollectionStorage
|
||||
@RelaxedMockK private lateinit var topSiteStorage: TopSiteStorage
|
||||
@RelaxedMockK private lateinit var readerModeController: ReaderModeController
|
||||
@RelaxedMockK private lateinit var sessionFeatureWrapper: ViewBoundFeatureWrapper<SessionFeature>
|
||||
@RelaxedMockK private lateinit var sessionFeature: SessionFeature
|
||||
private val store: BrowserStore = BrowserStore(initialState = BrowserState(
|
||||
listOf(
|
||||
createTab("https://www.mozilla.org", id = "reader-inactive-tab"),
|
||||
@ -124,6 +128,7 @@ class DefaultBrowserToolbarControllerTest {
|
||||
every { activity.components.core.sessionManager } returns sessionManager
|
||||
every { activity.components.core.store } returns store
|
||||
every { sessionManager.selectedSession } returns currentSession
|
||||
every { sessionFeatureWrapper.get() } returns sessionFeature
|
||||
|
||||
val onComplete = slot<() -> Unit>()
|
||||
every { browserAnimator.captureEngineViewAndDrawStatically(capture(onComplete)) } answers { onComplete.captured.invoke() }
|
||||
@ -469,7 +474,7 @@ class DefaultBrowserToolbarControllerTest {
|
||||
|
||||
controller.handleToolbarItemInteraction(item)
|
||||
|
||||
verify { engineView.release() }
|
||||
verify { sessionFeature.release() }
|
||||
verify { currentSession.customTabConfig = null }
|
||||
verify { sessionManager.select(currentSession) }
|
||||
verify { activity.startActivity(openInFenixIntent) }
|
||||
@ -571,6 +576,7 @@ class DefaultBrowserToolbarControllerTest {
|
||||
bookmarkTapped = bookmarkTapped,
|
||||
readerModeController = readerModeController,
|
||||
sessionManager = sessionManager,
|
||||
sessionFeature = sessionFeatureWrapper,
|
||||
onTabCounterClicked = onTabCounterClicked,
|
||||
onCloseTab = onCloseTab
|
||||
).apply {
|
||||
|
Loading…
Reference in New Issue
Block a user