1
0
Fork 0

For #6857 - Replace BackHandler with UserInteractionHandler in InflationAwareFeature and InflationAwareFeatureTest

master
Gabriel Luong 2019-11-28 14:30:41 -05:00 committed by Jonathan Almeida
parent 1b1f9348dc
commit 85111f538a
2 changed files with 6 additions and 5 deletions

View File

@ -59,7 +59,8 @@ abstract class InflationAwareFeature(
/**
* Called when the feature gets the option to handle the user pressing the back key.
*
* @return true if the feature also implements [BackHandler] and the feature has been initiated.
* @return true if the feature also implements [UserInteractionHandler] and the feature has
* been initiated.
*/
override fun onBackPressed(): Boolean {
return (feature as? UserInteractionHandler)?.onBackPressed() ?: false

View File

@ -2,7 +2,7 @@ package org.mozilla.fenix.components
import android.view.View
import android.view.ViewStub
import mozilla.components.support.base.feature.BackHandler
import mozilla.components.support.base.feature.UserInteractionHandler
import mozilla.components.support.base.feature.LifecycleAwareFeature
import mozilla.components.support.test.any
import mozilla.components.support.test.mock
@ -68,11 +68,11 @@ class InflationAwareFeatureTest {
}
@Test
fun `if feature has implemented BackHandler invoke it`() {
fun `if feature has implemented UserInteractionHandler invoke it`() {
val stub: ViewStub = mock()
val inflationFeature: InflationAwareFeature = spy(TestableInflationAwareFeature(stub))
val innerFeature: LifecycleAwareFeature = mock()
val backHandlerFeature = object : LifecycleAwareFeature, BackHandler {
val userInteractionHandlerFeature = object : LifecycleAwareFeature, UserInteractionHandler {
override fun onBackPressed() = true
override fun start() {}
@ -86,7 +86,7 @@ class InflationAwareFeatureTest {
assert(!inflationFeature.onBackPressed())
inflationFeature.feature = backHandlerFeature
inflationFeature.feature = userInteractionHandlerFeature
assert(inflationFeature.onBackPressed())
}