Commit 13ebbb2b authored by MozLando's avatar MozLando
Browse files

Merge #6141



6141: Feature/#6140 add toolbar menu dismiss setter r=Amejia481 a=BranescuMihai
Co-authored-by: default avatarMihai Branescu <branescu.mihai@gmail.com>
parents 52de7118 b9c80ce4
......@@ -267,6 +267,13 @@ class DisplayToolbar internal constructor(
}
}
/**
* Sets a lambda to be invoked when the menu is dismissed
*/
fun setMenuDismissAction(onDismiss: () -> Unit) {
views.menu.setMenuDismissAction(onDismiss)
}
/**
* List of indicators that should be displayed next to the URL.
*/
......
......@@ -41,5 +41,12 @@ internal class MenuButton(
fun dismissMenu() = impl.dismissMenu()
/**
* Sets a lambda to be invoked when the menu is dismissed
*/
fun setMenuDismissAction(onDismiss: () -> Unit) {
impl.onDismiss = onDismiss
}
fun setColorFilter(@ColorInt color: Int) = impl.setColorFilter(color)
}
......@@ -685,4 +685,17 @@ class DisplayToolbarTest {
assertTrue(wasDismissed)
}
@Test
fun `set a dismiss lambda on the menu button`() {
var wasDismissed = false
val (_, displayToolbar) = createDisplayToolbar()
displayToolbar.setMenuDismissAction { wasDismissed = true }
val menuView = displayToolbar.views.menu
menuView.menuBuilder = BrowserMenuBuilder(emptyList())
menuView.impl.performClick()
menuView.dismissMenu()
assertTrue(wasDismissed)
}
}
......@@ -15,11 +15,11 @@ import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
import mozilla.components.support.test.any
import mozilla.components.support.test.mock
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.whenever
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when`
import org.mockito.Mockito.doReturn
import org.mockito.Mockito.never
import org.mockito.Mockito.spy
......@@ -54,6 +54,14 @@ class MenuButtonTest {
verify(menuButtonInternal, times(2)).visibility = View.GONE
}
@Test
fun `menu button sets onDismiss action`() {
val action = {}
menuButton.setMenuDismissAction(action)
verify(menuButtonInternal).onDismiss = action
}
@Test
fun `icon displays dot if low highlighted item is present in menu`() {
verify(menuButtonInternal, never()).invalidateBrowserMenu()
......@@ -69,7 +77,7 @@ class MenuButtonTest {
isHighlighted = { isHighlighted }
)
)))
`when`(highlightMenuBuilder.build(testContext)).thenReturn(menu)
whenever(highlightMenuBuilder.build(testContext)).thenReturn(menu)
menuButton.menuBuilder = highlightMenuBuilder
doReturn(highlightMenuBuilder).`when`(menuButtonInternal).menuBuilder
......
......@@ -28,6 +28,9 @@ permalink: /changelog/
* **feature-accounts-push**
* Add known prefix to FxA push scope.
* **browser-toolbar**
* Add the possibility to listen to menu dismissal through `setMenuDismissAction` in `DisplayToolbar`
* **concept-storage**
* New interface: `LoginsStorage`, describes a logins storage. A slightly cleaned-up version of what was in the `service-sync-logins`.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment