For #25455 : Let A-C handle toolbar expanding when URL changes

This fix allows the toolbar to be visible after the user clicks on a link and scrolls

Co-Authored-By: Mugurell <Mugurell@users.noreply.github.com>
pull/543/head
indu 2 years ago committed by Mugurell
parent ca800f122e
commit ac31a1ace4

@ -768,7 +768,7 @@ abstract class BaseBrowserFragment :
view = view
)
expandToolbarOnNavigation(store)
closeFindInPageBarOnNavigation(store)
store.flowScoped(viewLifecycleOwner) { flow ->
flow.mapNotNull { state -> state.findTabOrCustomTabOrSelectedTab(customTabSessionId) }
@ -870,11 +870,9 @@ abstract class BaseBrowserFragment :
context.settings().incrementSecureWarningCount()
}
@VisibleForTesting
internal fun expandToolbarOnNavigation(store: BrowserStore) {
private fun closeFindInPageBarOnNavigation(store: BrowserStore) {
consumeFlow(store) { flow ->
flow.mapNotNull {
state ->
flow.mapNotNull { state ->
state.findCustomTabOrSelectedTab(customTabSessionId)
}
.ifAnyChanged {
@ -883,7 +881,6 @@ abstract class BaseBrowserFragment :
}
.collect {
findInPageIntegration.onBackPressed()
browserToolbarView.expand()
}
}
}

@ -14,11 +14,9 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.spyk
import io.mockk.verify
import mozilla.components.browser.state.action.ContentAction
import mozilla.components.browser.state.action.RestoreCompleteAction
import mozilla.components.browser.state.action.TabListAction
import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.state.LoadRequestState
import mozilla.components.browser.state.state.SessionState
import mozilla.components.browser.state.state.TabSessionState
import mozilla.components.browser.state.state.createTab
@ -152,35 +150,6 @@ class BrowserFragmentTest {
}
}
@Test
fun `WHEN url changes THEN toolbar is expanded`() {
addAndSelectTab(testTab)
browserFragment.expandToolbarOnNavigation(store)
val toolbar: BrowserToolbarView = mockk(relaxed = true)
every { browserFragment.browserToolbarView } returns toolbar
store.dispatch(ContentAction.UpdateUrlAction(testTab.id, "https://firefox.com")).joinBlocking()
verify(exactly = 1) { toolbar.expand() }
}
@Test
fun `WHEN load request is triggered THEN toolbar is expanded`() {
addAndSelectTab(testTab)
browserFragment.expandToolbarOnNavigation(store)
val toolbar: BrowserToolbarView = mockk(relaxed = true)
every { browserFragment.browserToolbarView } returns toolbar
store.dispatch(
ContentAction.UpdateLoadRequestAction(
testTab.id,
LoadRequestState("https://firefox.com", false, true)
)
).joinBlocking()
verify(exactly = 1) { toolbar.expand() }
}
@Test
fun `GIVEN tabs are restored WHEN there are no tabs THEN navigate to home`() {
browserFragment.observeRestoreComplete(store, navController)

Loading…
Cancel
Save