### Question:
IconCompat { public static IconCompat createWithResource(Context context, @DrawableRes int resId) { if (context == null) { throw new IllegalArgumentException("Context must not be null."); } final IconCompat rep = new IconCompat(TYPE_RESOURCE); rep.mInt1 = resId; rep.mObj1 = context.getPackageName(); return rep; } private  IconCompat(int mType); static IconCompat createWithResource(Context context, @DrawableRes int resId); static IconCompat createWithBitmap(Bitmap bits); static IconCompat createWithAdaptiveBitmap(Bitmap bits); static IconCompat createWithData(byte[] data, int offset, int length); static IconCompat createWithContentUri(String uri); static IconCompat createWithContentUri(Uri uri); @IconType int getType(); @NonNull String getResPackage(); @IdRes int getResId(); @NonNull Uri getUri(); IconCompat setTint(@ColorInt int tint); IconCompat setTintList(ColorStateList tintList); IconCompat setTintMode(PorterDuff.Mode mode); @RequiresApi(23) Icon toIcon(); Drawable loadDrawable(Context context); @RestrictTo(LIBRARY_GROUP) @SuppressWarnings("deprecation") void addToShortcutIntent(@NonNull Intent outIntent, @Nullable Drawable badge,
            @NonNull Context c); Bundle toBundle(); @Override String toString(); static @Nullable IconCompat createFromBundle(@NonNull Bundle bundle); @RequiresApi(23) @Nullable static IconCompat createFromIcon(@NonNull Icon icon); @IconType @RequiresApi(23) static int getType(@NonNull Icon icon); @Nullable @RequiresApi(23) static String getResPackage(@NonNull Icon icon); @IdRes @RequiresApi(23) static int getResId(@NonNull Icon icon); @Nullable @RequiresApi(23) Uri getUri(@NonNull Icon icon); static final int TYPE_UNKOWN; }### Answer:
@Test @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) public void testCreateWithResource() { Context context = InstrumentationRegistry.getContext(); Drawable original = context.getDrawable(R.drawable.test_drawable_red); IconCompat compat = IconCompat.createWithResource(context, R.drawable.test_drawable_red); Drawable d = compat.toIcon().loadDrawable(InstrumentationRegistry.getContext()); assertEquals(original.getClass(), d.getClass()); Bitmap orgBitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888); original.setBounds(0, 0, 200, 200); original.draw(new Canvas(orgBitmap)); Bitmap compatBitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888); d.setBounds(0, 0, 200, 200); d.draw(new Canvas(compatBitmap)); assertTrue(orgBitmap.sameAs(compatBitmap)); }
@Test public void testResourceIconCompat() { verifyIconCompatValidity(IconCompat.createWithResource(mContext, R.drawable.bmp_test)); }