From 85111f538a787e1852b76aab328078047ee69d10 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Thu, 28 Nov 2019 14:30:41 -0500 Subject: [PATCH] For #6857 - Replace BackHandler with UserInteractionHandler in InflationAwareFeature and InflationAwareFeatureTest --- .../org/mozilla/fenix/components/InflationAwareFeature.kt | 3 ++- .../mozilla/fenix/components/InflationAwareFeatureTest.kt | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/InflationAwareFeature.kt b/app/src/main/java/org/mozilla/fenix/components/InflationAwareFeature.kt index ac26197c3..a065ef2aa 100644 --- a/app/src/main/java/org/mozilla/fenix/components/InflationAwareFeature.kt +++ b/app/src/main/java/org/mozilla/fenix/components/InflationAwareFeature.kt @@ -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 diff --git a/app/src/test/java/org/mozilla/fenix/components/InflationAwareFeatureTest.kt b/app/src/test/java/org/mozilla/fenix/components/InflationAwareFeatureTest.kt index 8cf4eaa27..5f80a8230 100644 --- a/app/src/test/java/org/mozilla/fenix/components/InflationAwareFeatureTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/InflationAwareFeatureTest.kt @@ -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()) }