Skip to content

Commit

Permalink
For mozilla-mobile#11670: Replace deprecated addResolveInfoForIntent …
Browse files Browse the repository at this point in the history
…with addIntentFilterForActivity.
  • Loading branch information
mcarare committed Mar 8, 2022
1 parent 690c3db commit 3618ef5
Showing 1 changed file with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
}
}
}

0 comments on commit 3618ef5

Please sign in to comment.