From 3618ef567c0f2cca7b96d278f6215362082ebd7c Mon Sep 17 00:00:00 2001 From: mcarare Date: Mon, 7 Mar 2022 12:56:13 +0200 Subject: [PATCH] For #11670: Replace deprecated addResolveInfoForIntent with addIntentFilterForActivity. --- .../RecordingDevicesMiddlewareTest.kt | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/RecordingDevicesMiddlewareTest.kt b/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/RecordingDevicesMiddlewareTest.kt index b3b62d08b02..5eab97eaf76 100644 --- a/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/RecordingDevicesMiddlewareTest.kt +++ b/components/feature/media/src/test/java/mozilla/components/feature/media/middleware/RecordingDevicesMiddlewareTest.kt @@ -5,10 +5,10 @@ package mozilla.components.feature.media.middleware import android.app.NotificationManager +import android.content.ComponentName import android.content.Context import android.content.Intent -import android.content.pm.ActivityInfo -import android.content.pm.ResolveInfo +import android.content.IntentFilter import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.browser.state.action.ContentAction import mozilla.components.browser.state.state.BrowserState @@ -30,7 +30,14 @@ class RecordingDevicesMiddlewareTest { fun setup() { // Prepare the PackageManager to answer getLaunchIntentForPackage call. val applicationManager = Shadows.shadowOf(testContext.packageManager) - applicationManager.addResolveInfoForIntent(mockedLaunchIntent, mockedResolveInfo) + + val activityComponent = ComponentName(testContext.packageName, "Test") + applicationManager.addActivityIfNotPresent(activityComponent) + + applicationManager.addIntentFilterForActivity( + activityComponent, + IntentFilter(Intent.ACTION_MAIN).apply { addCategory(Intent.CATEGORY_INFO) } + ) } @Test @@ -112,18 +119,4 @@ class RecordingDevicesMiddlewareTest { assertEquals(0, notificationManager.size()) } - - private val mockedLaunchIntent - get() = Intent(Intent.ACTION_MAIN).apply { - addCategory(Intent.CATEGORY_INFO) - setPackage(testContext.packageName) - } - - private val mockedResolveInfo - get() = ResolveInfo().apply { - activityInfo = ActivityInfo().apply { - packageName = testContext.packageName - name = "Name" - } - } }