@Test
public void transform_withBitmapDrawable_andFunctionalBitmapTransformation_doesNotRecycle() {
when(bitmapTransformation.transform(
any(Context.class), anyBitmapResource(), anyInt(), anyInt()))
.thenAnswer(new Answer<Resource<Bitmap>>() {
@Override
public Resource<Bitmap> answer(InvocationOnMock invocationOnMock) throws Throwable {
return BitmapResource.obtain(
Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888), bitmapPool);
}
});
Bitmap bitmap = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888);
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
@SuppressWarnings("unchecked")
Resource<Drawable> input =
(Resource<Drawable>) (Resource<?>) new BitmapDrawableResource(drawable, bitmapPool);
transformation.transform(context, input, 100, 200);
assertThat(bitmap.isRecycled()).isFalse();
}