From eeb6051d91ae3c99b9a8f229a5211d02b2172926 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Wed, 31 Jul 2024 11:38:00 +0000 Subject: 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 --- .../src/com/android/server/policy/ModifierShortcutManagerTests.java | 4 ++++ 1 file changed, 4 insertions(+) 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()); -- cgit v1.2.3-59-g8ed1b