For #18027 - Also fix the bottom toolbar in place when a11y is enabled

We previously only set the top toolbar as fixed if an a11y service was running.
This commit is contained in:
Mugurell 2021-02-19 17:45:56 +02:00
parent 8c51e06965
commit 0a0f75d2ab
4 changed files with 60 additions and 9 deletions

View File

@ -822,12 +822,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
internal fun initializeEngineView(toolbarHeight: Int) {
val context = requireContext()
// If there is an a11y service enabled and the user hasn't explicitly set bottom toolbar
val isTopToolbarForced =
!context.settings().shouldUseBottomToolbar &&
context.settings().shouldUseFixedTopToolbar
if (!isTopToolbarForced && context.settings().isDynamicToolbarEnabled) {
if (!context.settings().shouldUseFixedTopToolbar && context.settings().isDynamicToolbarEnabled) {
getEngineView().setDynamicToolbarMaxHeight(toolbarHeight)
val toolbarPosition = if (context.settings().shouldUseBottomToolbar) {

View File

@ -245,7 +245,7 @@ class BrowserToolbarView(
fun setToolbarBehavior(shouldDisableScroll: Boolean = false) {
when (settings.toolbarPosition) {
ToolbarPosition.BOTTOM -> {
if (settings.isDynamicToolbarEnabled && !isPwaTabOrTwaTab) {
if (settings.isDynamicToolbarEnabled && !isPwaTabOrTwaTab && !settings.shouldUseFixedTopToolbar) {
setDynamicToolbarBehavior(MozacToolbarPosition.BOTTOM)
} else {
expandToolbarAndMakeItFixed()

View File

@ -60,6 +60,16 @@ class BaseBrowserFragmentTest {
verify { engineView.setDynamicToolbarMaxHeight(0) }
}
@Test
fun `initializeEngineView should setDynamicToolbarMaxHeight to 0 if bottom toolbar is forced for a11y`() {
every { testContext.settings().shouldUseBottomToolbar } returns true
every { testContext.settings().shouldUseFixedTopToolbar } returns true
fragment.initializeEngineView(13)
verify { engineView.setDynamicToolbarMaxHeight(0) }
}
@Test
fun `initializeEngineView should setDynamicToolbarMaxHeight to toolbar height if dynamic toolbar is enabled`() {
every { testContext.settings().shouldUseFixedTopToolbar } returns false
@ -116,6 +126,16 @@ class BaseBrowserFragmentTest {
verify { (swipeRefreshLayout.layoutParams as CoordinatorLayout.LayoutParams).bottomMargin = 13 }
}
@Test
fun `initializeEngineView should set toolbar height as EngineView parent's bottom margin if bottom toolbar is forced for a11y`() {
every { testContext.settings().shouldUseBottomToolbar } returns true
every { testContext.settings().shouldUseFixedTopToolbar } returns true
fragment.initializeEngineView(13)
verify { (swipeRefreshLayout.layoutParams as CoordinatorLayout.LayoutParams).bottomMargin = 13 }
}
@Test
fun `WHEN status is equals to FAILED or COMPLETED and it is the same tab then shouldShowCompletedDownloadDialog will be true`() {
every { fragment.getCurrentTab() } returns createTab(id = "1", url = "")

View File

@ -50,11 +50,12 @@ class BrowserToolbarViewTest {
}
@Test
fun `setToolbarBehavior(false) should setDynamicToolbarBehavior if bottom toolbar is dynamic and the tab is not for a PWA or TWA`() {
fun `setToolbarBehavior(false) should setDynamicToolbarBehavior if no a11y, bottom toolbar is dynamic and the tab is not for a PWA or TWA`() {
val toolbarViewSpy = spyk(toolbarView)
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns true
every { toolbarViewSpy.isPwaTabOrTwaTab } returns false
every { testContext.settings().shouldUseFixedTopToolbar } returns false
toolbarViewSpy.setToolbarBehavior(false)
@ -66,6 +67,8 @@ class BrowserToolbarViewTest {
val toolbarViewSpy = spyk(toolbarView)
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns false
every { toolbarViewSpy.isPwaTabOrTwaTab } returns false
every { testContext.settings().shouldUseFixedTopToolbar } returns false
toolbarViewSpy.setToolbarBehavior(false)
@ -78,6 +81,7 @@ class BrowserToolbarViewTest {
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns true
every { toolbarViewSpy.isPwaTabOrTwaTab } returns true
every { testContext.settings().shouldUseFixedTopToolbar } returns false
toolbarViewSpy.setToolbarBehavior(false)
@ -85,11 +89,27 @@ class BrowserToolbarViewTest {
}
@Test
fun `setToolbarBehavior(true) should setDynamicToolbarBehavior if bottom toolbar is dynamic and the tab is not for a PWA or TWA`() {
fun `setToolbarBehavior(false) should expandToolbarAndMakeItFixed if bottom toolbar is dynamic tab is not for a PWA or TWA but a11y is enabled`() {
val toolbarViewSpy = spyk(toolbarView)
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns true
every { toolbarViewSpy.isPwaTabOrTwaTab } returns false
every { testContext.settings().shouldUseFixedTopToolbar } returns true
toolbarViewSpy.setToolbarBehavior(false)
verify { toolbarViewSpy.expandToolbarAndMakeItFixed() }
}
@Test
fun `setToolbarBehavior(true) should expandToolbarAndMakeItFixed bottom toolbar is dynamic, the tab is not for a PWA or TWA and a11y is disabled`() {
// All intrinsic checks are met but the method was called with `shouldDisableScroll` = true
val toolbarViewSpy = spyk(toolbarView)
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns true
every { toolbarViewSpy.isPwaTabOrTwaTab } returns false
every { testContext.settings().shouldUseFixedTopToolbar } returns false
toolbarViewSpy.setToolbarBehavior(false)
@ -101,6 +121,8 @@ class BrowserToolbarViewTest {
val toolbarViewSpy = spyk(toolbarView)
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns false
every { toolbarViewSpy.isPwaTabOrTwaTab } returns false
every { testContext.settings().shouldUseFixedTopToolbar } returns false
toolbarViewSpy.setToolbarBehavior(false)
@ -113,6 +135,20 @@ class BrowserToolbarViewTest {
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns true
every { toolbarViewSpy.isPwaTabOrTwaTab } returns true
every { testContext.settings().shouldUseFixedTopToolbar } returns false
toolbarViewSpy.setToolbarBehavior(false)
verify { toolbarViewSpy.expandToolbarAndMakeItFixed() }
}
@Test
fun `setToolbarBehavior(true) should expandToolbarAndMakeItFixed if bottom toolbar is dynamic, the tab is for a PWA or TWA and a11 is enabled`() {
val toolbarViewSpy = spyk(toolbarView)
every { testContext.settings().toolbarPosition } returns ToolbarPosition.BOTTOM
every { testContext.settings().isDynamicToolbarEnabled } returns true
every { toolbarViewSpy.isPwaTabOrTwaTab } returns false
every { testContext.settings().shouldUseFixedTopToolbar } returns true
toolbarViewSpy.setToolbarBehavior(false)