@Test
  public void testCenterCropHandlesBitmapsWithNullConfigs() {
    Bitmap toTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565);
    Shadows.shadowOf(toTransform).setConfig(null);

    Bitmap transformed = TransformationUtils.centerCrop(bitmapPool, toTransform, 50, 50);

    assertEquals(Bitmap.Config.ARGB_8888, transformed.getConfig());
  }
  @Test
  public void testCenterCropReturnsGivenBitmapIfGivenBitmapExactlyMatchesGivenDimensions() {
    Bitmap toCrop = Bitmap.createBitmap(200, 300, Bitmap.Config.ARGB_8888);
    Bitmap transformed =
        TransformationUtils.centerCrop(bitmapPool, toCrop, toCrop.getWidth(), toCrop.getHeight());

    // Robolectric incorrectly implements equals() for Bitmaps, we want the original object not
    // just an equivalent.
    assertTrue(toCrop == transformed);
  }
  @Test
  public void testCenterCropSetsOutBitmapToNotHaveAlphaIfInBitmapDoesNotHaveAlpha() {
    Bitmap toTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

    toTransform.setHasAlpha(false);

    Bitmap result =
        TransformationUtils.centerCrop(
            bitmapPool, toTransform, toTransform.getWidth() / 2, toTransform.getHeight() / 2);

    assertFalse(result.hasAlpha());
  }
  @Test
  public void testCenterCropSetsOutBitmapToHaveAlphaIfInBitmapHasAlphaAndOutBitmapIsReused() {
    Bitmap toTransform = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);

    Bitmap toReuse = Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
    reset(bitmapPool);
    when(bitmapPool.get(eq(50), eq(50), eq(Bitmap.Config.ARGB_8888))).thenReturn(toReuse);

    toReuse.setHasAlpha(false);
    toTransform.setHasAlpha(true);

    Bitmap result =
        TransformationUtils.centerCrop(
            bitmapPool, toTransform, toReuse.getWidth(), toReuse.getHeight());

    assertEquals(toReuse, result);
    assertTrue(result.hasAlpha());
  }