### Question:
ShortcutManagerCompat { public static boolean isRequestPinShortcutSupported(@NonNull Context context) { if (Build.VERSION.SDK_INT >= 26) { return context.getSystemService(ShortcutManager.class).isRequestPinShortcutSupported(); } if (ContextCompat.checkSelfPermission(context, INSTALL_SHORTCUT_PERMISSION) != PackageManager.PERMISSION_GRANTED) { return false; } for (ResolveInfo info : context.getPackageManager().queryBroadcastReceivers( new Intent(ACTION_INSTALL_SHORTCUT), 0)) { String permission = info.activityInfo.permission; if (TextUtils.isEmpty(permission) || INSTALL_SHORTCUT_PERMISSION.equals(permission)) { return true; } } return false; } private  ShortcutManagerCompat(); static boolean isRequestPinShortcutSupported(@NonNull Context context); static boolean requestPinShortcut(@NonNull final Context context,
            @NonNull ShortcutInfoCompat shortcut, @Nullable final IntentSender callback); @NonNull static Intent createShortcutResultIntent(@NonNull Context context,
            @NonNull ShortcutInfoCompat shortcut);  }### Answer:
@Test @SmallTest @SdkSuppress(minSdkVersion = 26) public void testIsRequestPinShortcutSupported_v26() throws Throwable { ShortcutManager mockShortcutManager = mock(ShortcutManager.class); doReturn(mockShortcutManager).when(mContext).getSystemService(eq(Context.SHORTCUT_SERVICE)); when(mockShortcutManager.isRequestPinShortcutSupported()).thenReturn(true, false, true); assertTrue(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); assertFalse(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); assertTrue(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); verify(mockShortcutManager, times(3)).isRequestPinShortcutSupported(); }
@SmallTest @Test @SdkSuppress(maxSdkVersion = 25) public void testIsRequestPinShortcutSupported_v4() throws Throwable { setMockPm(mockResolveInfo(null)); assertTrue(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); setMockPm(mockResolveInfo("com.android.permission.something-we-dont-have")); assertFalse(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); setMockPm(); assertFalse(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); setMockPm(mockResolveInfo("com.android.permission.something-we-dont-have"), mockResolveInfo(null)); assertTrue(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); setMockPm(mockResolveInfo(ShortcutManagerCompat.INSTALL_SHORTCUT_PERMISSION)); assertTrue(ShortcutManagerCompat.isRequestPinShortcutSupported(mContext)); }