### Question:
ShortcutInfoCompat { Intent addToIntent(Intent outIntent) { outIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, mIntents[mIntents.length - 1]) .putExtra(Intent.EXTRA_SHORTCUT_NAME, mLabel.toString()); if (mIcon != null) { Drawable badge = null; if (mIsAlwaysBadged) { PackageManager pm = mContext.getPackageManager(); if (mActivity != null) { try { badge = pm.getActivityIcon(mActivity); } catch (PackageManager.NameNotFoundException e) { } } if (badge == null) { badge = mContext.getApplicationInfo().loadIcon(pm); } } mIcon.addToShortcutIntent(outIntent, badge, mContext); } return outIntent; } private  ShortcutInfoCompat(); @RequiresApi(25) ShortcutInfo toShortcutInfo(); @NonNull String getId(); @Nullable ComponentName getActivity(); @NonNull CharSequence getShortLabel(); @Nullable CharSequence getLongLabel(); @Nullable CharSequence getDisabledMessage(); @NonNull Intent getIntent(); @NonNull Intent[] getIntents();  }### Answer:
@Test public void testAddToIntent_noBadge() { Intent intent = new Intent(); mBuilder.setActivity(new ComponentName(mContext, TestActivity.class)) .build() .addToIntent(intent); assertEquals(mAction, intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT)); assertNotNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE)); assertNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON)); }
@Test public void testAddToIntent_badgeActivity() { Intent intent = new Intent(); mBuilder.setActivity(new ComponentName(mContext, TestActivity.class)) .setAlwaysBadged() .build() .addToIntent(intent); assertEquals(mAction, intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT)); assertNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE)); verifyBadgeBitmap(intent, ContextCompat.getColor(mContext, R.color.test_red), ContextCompat.getColor(mContext, R.color.test_blue)); }
@Test public void testAddToIntent_badgeApplication() { ApplicationInfo appInfo = spy(mContext.getApplicationInfo()); doReturn(ContextCompat.getDrawable(mContext, R.drawable.test_drawable_green)) .when(appInfo).loadIcon(any(PackageManager.class)); doReturn(appInfo).when(mContext).getApplicationInfo(); Intent intent = new Intent(); mBuilder.setAlwaysBadged() .build() .addToIntent(intent); assertEquals(mAction, intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT)); assertNull(intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE)); verifyBadgeBitmap(intent, ContextCompat.getColor(mContext, R.color.test_red), ContextCompat.getColor(mContext, R.color.test_green)); }