use of android.graphics.Bitmap in project glide by bumptech.
the class BitmapPreFillRunnerTest method testAllocatesABitmapPerSizeInAllocationOrder.
@Test
public void testAllocatesABitmapPerSizeInAllocationOrder() {
PreFillType size = new PreFillType.Builder(100).setConfig(Bitmap.Config.ARGB_8888).build();
final int toAdd = 3;
Map<PreFillType, Integer> allocationOrder = new HashMap<>();
allocationOrder.put(size, toAdd);
BitmapPreFillRunner handler = getHandler(allocationOrder);
handler.run();
Bitmap expected = Bitmap.createBitmap(size.getWidth(), size.getHeight(), size.getConfig());
// TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
// assertThat(addedBitmaps).containsExactly(expected, expected, expected);
}
use of android.graphics.Bitmap in project glide by bumptech.
the class BitmapPreFillRunnerTest method testAllocatesBitmapsInOrderGivenByAllocationOrder.
@Test
public void testAllocatesBitmapsInOrderGivenByAllocationOrder() {
PreFillType smallWidth = new PreFillType.Builder(50, 100).setConfig(Bitmap.Config.ARGB_8888).build();
PreFillType smallHeight = new PreFillType.Builder(100, 50).setConfig(Bitmap.Config.RGB_565).build();
PreFillType[] expectedOrder = new PreFillType[] { smallWidth, smallHeight, smallWidth, smallHeight };
HashMap<PreFillType, Integer> allocationOrder = new HashMap<>();
allocationOrder.put(smallWidth, 2);
allocationOrder.put(smallHeight, 2);
BitmapPreFillRunner handler = getHandler(allocationOrder);
handler.run();
Bitmap[] expectedBitmaps = new Bitmap[expectedOrder.length];
for (int i = 0; i < expectedBitmaps.length; i++) {
PreFillType current = expectedOrder[i];
expectedBitmaps[i] = Bitmap.createBitmap(current.getWidth(), current.getHeight(), current.getConfig());
}
Bitmap current = addedBitmaps.get(0);
for (int i = 1; i < addedBitmaps.size(); i++) {
assertNotEquals(current, addedBitmaps.get(i));
current = addedBitmaps.get(i);
}
assertThat(addedBitmaps).hasSize(4);
}
use of android.graphics.Bitmap in project glide by bumptech.
the class TransformationUtilsTest method testFitCenterUsesFloorInsteadOfRoundingForOutputBitmapSize.
// Test for Issue #195.
@Test
public void testFitCenterUsesFloorInsteadOfRoundingForOutputBitmapSize() {
Bitmap toTransform = Bitmap.createBitmap(1230, 1640, Bitmap.Config.RGB_565);
Bitmap transformed = TransformationUtils.fitCenter(bitmapPool, toTransform, 1075, 1366);
assertEquals(1024, transformed.getWidth());
assertEquals(1366, transformed.getHeight());
}
use of android.graphics.Bitmap in project glide by bumptech.
the class TransformationUtilsTest method testRotateImageExifHandlesBitmapsWithNullConfigs.
@Test
public void testRotateImageExifHandlesBitmapsWithNullConfigs() {
Bitmap toRotate = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
Shadows.shadowOf(toRotate).setConfig(null);
Bitmap rotated = TransformationUtils.rotateImageExif(bitmapPool, toRotate, ExifInterface.ORIENTATION_ROTATE_180);
assertEquals(Bitmap.Config.ARGB_8888, rotated.getConfig());
}
use of android.graphics.Bitmap in project glide by bumptech.
the class VideoBitmapDecoderTest method testReturnsRetrievedFrameForResource.
@Test
public void testReturnsRetrievedFrameForResource() throws IOException {
Bitmap expected = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
when(retriever.getFrameAtTime()).thenReturn(expected);
FileDescriptor toSet = FileDescriptor.in;
when(resource.getFileDescriptor()).thenReturn(toSet);
Resource<Bitmap> result = decoder.decode(resource, 100, 100, options);
verify(retriever).setDataSource(eq(toSet));
assertEquals(expected, result.get());
}
Aggregations