use of com.bumptech.glide.GlideBuilder in project glide by bumptech.
the class DrawableTransformationTest method transform_withColorDrawable_andUnitBitmapTransformation_recycles.
@Test
public void transform_withColorDrawable_andUnitBitmapTransformation_recycles() {
bitmapPool = mock(BitmapPool.class);
Glide.tearDown();
Glide.init(context, new GlideBuilder().setBitmapPool(bitmapPool));
when(bitmapTransformation.transform(any(Context.class), anyBitmapResource(), anyInt(), anyInt())).thenAnswer(new ReturnGivenResource());
ColorDrawable colorDrawable = new ColorDrawable(Color.RED);
final Resource<Drawable> input = new SimpleResource<Drawable>(colorDrawable);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
Bitmap bitmap = (Bitmap) invocationOnMock.getArguments()[0];
assertThat(bitmap.getWidth()).isEqualTo(100);
assertThat(bitmap.getHeight()).isEqualTo(200);
return null;
}
}).when(bitmapPool).put(any(Bitmap.class));
when(bitmapPool.get(anyInt(), anyInt(), any(Bitmap.Config.class))).thenAnswer(new Answer<Bitmap>() {
@Override
public Bitmap answer(InvocationOnMock invocationOnMock) throws Throwable {
int width = (Integer) invocationOnMock.getArguments()[0];
int height = (Integer) invocationOnMock.getArguments()[1];
Bitmap.Config config = (Bitmap.Config) invocationOnMock.getArguments()[2];
return Bitmap.createBitmap(width, height, config);
}
});
transformation.transform(context, input, /*outWidth=*/
100, /*outHeight=*/
200);
verify(bitmapPool).put(isA(Bitmap.class));
}
use of com.bumptech.glide.GlideBuilder in project glide by bumptech.
the class BitmapDrawableTransformationTest method setUp.
@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);
}
use of com.bumptech.glide.GlideBuilder in project glide by bumptech.
the class FitCenterTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
bitmapWidth = 100;
bitmapHeight = 100;
Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
when(resource.get()).thenReturn(bitmap);
BitmapPool pool = new BitmapPoolAdapter();
context = RuntimeEnvironment.application;
Glide.init(context, new GlideBuilder().setBitmapPool(pool));
fitCenter = new FitCenter();
}
use of com.bumptech.glide.GlideBuilder in project glide by bumptech.
the class CircleCropTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(bitmapPool.get(anyInt(), anyInt(), any(Bitmap.Config.class))).thenAnswer(new Util.CreateBitmap());
Context context = RuntimeEnvironment.application;
Glide.init(context, new GlideBuilder().setBitmapPool(bitmapPool));
circleCrop = new CircleCrop();
}
use of com.bumptech.glide.GlideBuilder in project glide by bumptech.
the class CenterInsideTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
bitmapWidth = 100;
bitmapHeight = 100;
Bitmap bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
when(resource.get()).thenReturn(bitmap);
context = RuntimeEnvironment.application;
BitmapPool pool = new BitmapPoolAdapter();
Glide.init(context, new GlideBuilder().setBitmapPool(pool));
centerInside = new CenterInside();
}
Aggregations