@Before public void setUp() { MockitoAnnotations.initMocks(this); bitmapToTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); BitmapDrawable drawableToTransform = new BitmapDrawable(bitmapToTransform); context = RuntimeEnvironment.application; Glide.init(context, new GlideBuilder().setBitmapPool(bitmapPool)); when(drawableResourceToTransform.get()).thenReturn(drawableToTransform); transformation = new BitmapDrawableTransformation(wrapped); }
@Test public void testEquals() throws NoSuchAlgorithmException { doAnswer(new Util.WriteDigest("wrapped")).when(wrapped) .updateDiskCacheKey(any(MessageDigest.class)); @SuppressWarnings("unchecked") Transformation<Bitmap> other = mock(Transformation.class); doAnswer(new Util.WriteDigest("other")).when(other) .updateDiskCacheKey(any(MessageDigest.class)); keyTester .addEquivalenceGroup( transformation, new BitmapDrawableTransformation(wrapped)) .addEquivalenceGroup(new BitmapDrawableTransformation(other)) .addEquivalenceGroup(wrapped) .addRegressionTest( transformation, "adbf45b08ad6468aa147e5b2a23758ef56ab631a2b70ad52501ca358441a34f3") .test(); } }
/** * Applies the given {@link Transformation} for * {@link Bitmap Bitmaps} to the default types ({@link Bitmap}, * {@link android.graphics.drawable.BitmapDrawable}, and ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()}. * * @param transformation Any {@link Transformation} for {@link Bitmap}s. * @see #transform(Transformation) * @see #transform(Class, Transformation) */ // Guaranteed to modify the current object by the isAutoCloneEnabledCheck. @SuppressWarnings("CheckResult") @CheckResult public RequestOptions optionalTransform(Transformation<Bitmap> transformation) { if (isAutoCloneEnabled) { return clone().optionalTransform(transformation); } optionalTransform(Bitmap.class, transformation); // TODO: remove BitmapDrawable decoder and this transformation. optionalTransform(BitmapDrawable.class, new BitmapDrawableTransformation(transformation)); return selfOrThrowIfLocked(); }