summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author Andrey Yepin <ayepin@google.com> 2024-11-01 13:38:34 -0700
committer Andrey Yepin <ayepin@google.com> 2024-11-01 15:19:29 -0700
commit40389e404f72cb13f9632fa86cd0f13905f682ea (patch)
treea30f27e7396a591248a331c5cb6e7bf5ed314ee4 /tests
parent2588fa09d9a6f162c97593318558a25dd1758d84 (diff)
Fix shortcut icon loading.
The SimpleIconFactory constructor fails when invoked with a context returned by Context.createContextAsUser(). Previously, shortcut icons were loaded due to the reuse of cached icon factory instances from prior tasks. This change introduces SimpleIconFactory as a dependency to ensure correct instance creation. Fix: 376891146 Test: Disable SimpleIconFactory instance pooling through an injecetd debug code and verify that shortcut icons are loaded. Test: atest IntentResolver-tests-unit Flag: EXEMPT bugfix Change-Id: I2ad2a2bda2e4e152b11be852a04873d3c8104166
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/src/com/android/intentresolver/TargetPresentationGetterTest.kt26
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/unit/src/com/android/intentresolver/TargetPresentationGetterTest.kt b/tests/unit/src/com/android/intentresolver/TargetPresentationGetterTest.kt
index 92848b2c..b5b05eb9 100644
--- a/tests/unit/src/com/android/intentresolver/TargetPresentationGetterTest.kt
+++ b/tests/unit/src/com/android/intentresolver/TargetPresentationGetterTest.kt
@@ -32,32 +32,42 @@ class TargetPresentationGetterTest {
withSubstitutePermission: Boolean,
appLabel: String,
activityLabel: String,
- resolveInfoLabel: String
+ resolveInfoLabel: String,
): TargetPresentationGetter {
val testPackageInfo =
ResolverDataProvider.createPackageManagerMockedInfo(
withSubstitutePermission,
appLabel,
activityLabel,
- resolveInfoLabel
+ resolveInfoLabel,
+ )
+ val factory =
+ TargetPresentationGetter.Factory(
+ { SimpleIconFactory.obtain(testPackageInfo.ctx) },
+ testPackageInfo.ctx.packageManager,
+ 100,
)
- val factory = TargetPresentationGetter.Factory(testPackageInfo.ctx, 100)
return factory.makePresentationGetter(testPackageInfo.resolveInfo)
}
fun makeActivityInfoPresentationGetter(
withSubstitutePermission: Boolean,
appLabel: String?,
- activityLabel: String?
+ activityLabel: String?,
): TargetPresentationGetter {
val testPackageInfo =
ResolverDataProvider.createPackageManagerMockedInfo(
withSubstitutePermission,
appLabel,
activityLabel,
- ""
+ "",
+ )
+ val factory =
+ TargetPresentationGetter.Factory(
+ { SimpleIconFactory.obtain(testPackageInfo.ctx) },
+ testPackageInfo.ctx.packageManager,
+ 100,
)
- val factory = TargetPresentationGetter.Factory(testPackageInfo.ctx, 100)
return factory.makePresentationGetter(testPackageInfo.activityInfo)
}
@@ -158,7 +168,7 @@ class TargetPresentationGetterTest {
false,
"app_label",
"activity_label",
- "resolve_info_label"
+ "resolve_info_label",
)
assertThat(presentationGetter.getLabel()).isEqualTo("app_label")
assertThat(presentationGetter.getSubLabel()).isEqualTo("resolve_info_label")
@@ -192,7 +202,7 @@ class TargetPresentationGetterTest {
true,
"app_label",
"activity_label",
- "resolve_info_label"
+ "resolve_info_label",
)
assertThat(presentationGetter.getLabel()).isEqualTo("activity_label")
assertThat(presentationGetter.getSubLabel()).isEqualTo("resolve_info_label")