2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/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>
This commit is contained in:
indu 2022-05-31 13:56:01 +05:30 committed by Mugurell
parent 0a948b4324
commit 80f38dba6f
2 changed files with 3 additions and 37 deletions

View File

@ -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()
}
}
}

View File

@ -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)