diff options
| author | 2024-07-31 11:38:00 +0000 | |
|---|---|---|
| committer | 2024-07-31 11:40:19 +0000 | |
| commit | eeb6051d91ae3c99b9a8f229a5211d02b2172926 (patch) | |
| tree | 21209c3c360809ba307ef6ef429745a02dd92506 | |
| parent | ab4779e9007e392bb11212adf1739d053c0db45d (diff) | |
Fix ModifierShortcutManagerTests on AOSP build.
Stub PackageManager.resolveActivity() in the tests to always return
an activity, even if there isn't something installed that could handle
it. This makes the test independent of the state of the device which
may have some typical apps for handling the shortcuts missing.
Fixes: 356277860
Flag: TEST_ONLY
Test: atest WmTests:com.android.server.policy.ModifierShortcutManagerTests
Change-Id: Ie7d41a29f33d4c095f71472327523ddbe2bb7efe
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/policy/ModifierShortcutManagerTests.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutManagerTests.java b/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutManagerTests.java index 50041d023e64..d147325921bf 100644 --- a/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutManagerTests.java +++ b/services/tests/wmtests/src/com/android/server/policy/ModifierShortcutManagerTests.java @@ -35,6 +35,7 @@ import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; import android.content.res.Resources; import android.content.res.XmlResourceParser; import android.os.Handler; @@ -89,9 +90,12 @@ public class ModifierShortcutManagerTests { testActivityInfo.applicationInfo = new ApplicationInfo(); testActivityInfo.packageName = testActivityInfo.applicationInfo.packageName = "com.test"; + ResolveInfo testResolveInfo = new ResolveInfo(); + testResolveInfo.activityInfo = testActivityInfo; doReturn(testActivityInfo).when(mPackageManager).getActivityInfo( eq(new ComponentName("com.test", "com.test.BookmarkTest")), anyInt()); + doReturn(testResolveInfo).when(mPackageManager).resolveActivity(anyObject(), anyInt()); doThrow(new PackageManager.NameNotFoundException("com.test3")).when(mPackageManager) .getActivityInfo(eq(new ComponentName("com.test3", "com.test.BookmarkTest")), anyInt()); |