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