public static Bitmap create(int width, int height, Bitmap.Config config) {
    Preconditions.checkArgument(width > 0);
    Preconditions.checkArgument(height > 0);
    Preconditions.checkNotNull(config);
    Bitmap bitmap = mock(Bitmap.class);
    when(bitmap.getWidth()).thenReturn(width);
    when(bitmap.getHeight()).thenReturn(height);
    // NULLSAFE_FIXME[Parameter Not Nullable]
    when(bitmap.getConfig()).thenReturn(config);
    when(bitmap.isMutable()).thenReturn(true);
    when(bitmap.getRowBytes()).thenReturn(width * BitmapUtil.getPixelSizeForBitmapConfig(config));
    when(bitmap.getByteCount()).thenReturn(bitmapSize(width, height, config));
    return bitmap;
  }
Helper class for creating bitmap mocks in tests.
imagepipeline-test/src/main/java/com/facebook/imagepipeline/testing/MockBitmapFactory.java