ViewTarget implements Target<Bitmap>, DrawableFactory { public ViewTarget<V> drawableFactory(DrawableFactory factory) { successDrawableFactory = factory; return this; } ViewTarget(V view);  ViewTarget(MirageRequest request, V view); V getView(); ViewTarget<V> placeHolder(@DrawableRes int resourceId); ViewTarget<V> placeHolder(Drawable drawable); ViewTarget<V> error(@DrawableRes int resourceId); ViewTarget<V> error(Drawable drawable); ViewTarget<V> animation(MirageAnimation<V> animation); MirageAnimation<V> animation(); ViewTarget<V> fade(); ViewTarget<V> fit(); ViewTarget<V> drawableFactory(DrawableFactory factory); MirageTask go(); Drawable getPlaceHolderDrawable(); int getPlaceHolderResourceId(); Drawable getErrorDrawable(); int getErrorResourceId(); @Override void onPreparingLoad(); @Override void onResult(Bitmap bitmap, Mirage.Source source, MirageRequest request); @Override void onError(Exception e, Mirage.Source source, MirageRequest request); @Override void onCancel(); @Override Drawable createDrawable(Context context, Bitmap bitmap);  }
@Test public void testDrawableFactory() { ImageView imageView = new ImageView(RuntimeEnvironment.application); ImageViewTarget target = new ImageViewTarget(imageView); DrawableFactory factory = Mockito.mock(DrawableFactory.class); Mockito.when( factory.createDrawable((Context) Mockito.any(), (Bitmap) Mockito.any())) .thenReturn(new ColorDrawable(Color.RED)); target.drawableFactory(factory); Drawable d = target.createDrawable(RuntimeEnvironment.application, Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888)); Assert.assertNotNull(d); Mockito.verify(factory, Mockito.times(1)).createDrawable((Context) Mockito.any(), (Bitmap) Mockito.any()); }