Bug 1868261 - Add hiding on scroll behaviour to navbar
parent
552a96e5ae
commit
d42aca60dc
@ -0,0 +1,34 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.components.toolbar.navbar
|
||||
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.concept.toolbar.ScrollableToolbar
|
||||
import mozilla.components.feature.toolbar.ToolbarBehaviorController
|
||||
import mozilla.components.support.base.feature.LifecycleAwareFeature
|
||||
|
||||
/**
|
||||
* The feature responsible for scrolling behaviour of the navigation bar.
|
||||
* When the content of a tab is being scrolled, the nav bar will react
|
||||
* to the user interactions.
|
||||
*/
|
||||
class NavbarIntegration(
|
||||
val toolbar: ScrollableToolbar,
|
||||
val store: BrowserStore,
|
||||
sessionId: String?,
|
||||
) : LifecycleAwareFeature {
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
var toolbarController = ToolbarBehaviorController(toolbar, store, sessionId)
|
||||
|
||||
override fun start() {
|
||||
toolbarController.start()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
toolbarController.stop()
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.components.toolbar
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.fenix.components.toolbar.navbar.NavbarIntegration
|
||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||
|
||||
@RunWith(FenixRobolectricTestRunner::class)
|
||||
class NavbarIntegrationTest {
|
||||
private lateinit var feature: NavbarIntegration
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
feature = NavbarIntegration(
|
||||
toolbar = mockk(),
|
||||
store = mockk(),
|
||||
sessionId = null,
|
||||
).apply {
|
||||
toolbarController = mockk(relaxed = true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN the feature starts THEN toolbar controllers starts as well`() {
|
||||
feature.start()
|
||||
|
||||
verify { feature.toolbarController.start() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN the feature stops THEN toolbar controllers stops as well`() {
|
||||
feature.stop()
|
||||
|
||||
verify { feature.toolbarController.stop() }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue