[fenix] For https://github.com/mozilla-mobile/fenix/issues/24461 - Increase touch target for scan, search engine & voice search button
parent
a316b42f44
commit
abb02bd596
@ -0,0 +1,28 @@
|
||||
/* 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.search.toolbar
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import mozilla.components.concept.toolbar.Toolbar
|
||||
import org.mozilla.fenix.ext.increaseTapArea
|
||||
|
||||
/**
|
||||
* A Decorator that accepts a [Toolbar.Action] and increases its tap area.
|
||||
*/
|
||||
class IncreasedTapAreaActionDecorator(
|
||||
private val action: Toolbar.Action
|
||||
) : Toolbar.Action by action {
|
||||
|
||||
override fun bind(view: View) {
|
||||
action.bind(view)
|
||||
view.increaseTapArea(TAP_INCREASE_DPS)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@VisibleForTesting
|
||||
const val TAP_INCREASE_DPS = 8
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/* 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.search.toolbar
|
||||
|
||||
import android.view.View
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.justRun
|
||||
import io.mockk.mockkStatic
|
||||
import io.mockk.verify
|
||||
import mozilla.components.concept.toolbar.Toolbar
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.ext.increaseTapArea
|
||||
|
||||
class IncreasedTapAreaActionDecoratorTest {
|
||||
|
||||
@MockK lateinit var action: Toolbar.Action
|
||||
@MockK lateinit var view: View
|
||||
|
||||
private lateinit var increasedTapAreaActionDecorator: IncreasedTapAreaActionDecorator
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this)
|
||||
increasedTapAreaActionDecorator = IncreasedTapAreaActionDecorator(action)
|
||||
justRun { action.bind(view) }
|
||||
mockkStatic(View::increaseTapArea)
|
||||
justRun { view.increaseTapArea(IncreasedTapAreaActionDecorator.TAP_INCREASE_DPS) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `increased tap area of view on bind`() {
|
||||
increasedTapAreaActionDecorator.bind(view)
|
||||
|
||||
verify { view.increaseTapArea(IncreasedTapAreaActionDecorator.TAP_INCREASE_DPS) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should invoke provided action bind`() {
|
||||
increasedTapAreaActionDecorator.bind(view)
|
||||
|
||||
verify { action.bind(view) }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue