@Test
public void dataProviderTest() {

  final String BITMAP_CLASS_NAME = "android.graphics.Bitmap";
  final String BYTES_CLASS_NAME = "byte[]";
  FakeCaptureObject fakeCaptureObject = new FakeCaptureObject.Builder().build();
  FakeInstanceObject bitmapInstance = new FakeInstanceObject.Builder(fakeCaptureObject, 1, BITMAP_CLASS_NAME)
    .setFields(Arrays.asList("mBuffer", "mIsMutable", "mWidth", "mHeight")).build();
  bitmapInstance
    .setFieldValue("mBuffer", ARRAY,
                   new FakeInstanceObject.Builder(fakeCaptureObject, 2, BYTES_CLASS_NAME).setValueType(ARRAY)
                     .setArray(BYTE, new byte[]{0, 0, 0, 0, 0, 0, 0, 0,}, 8).build())
    .setFieldValue("mWidth", INT, 2)
    .setFieldValue("mHeight", INT, 1)
    .setFieldValue("mIsMutable", BOOLEAN, false);
  FakeInstanceObject badBitmapInstance1 = new FakeInstanceObject.Builder(fakeCaptureObject, 1, BITMAP_CLASS_NAME)
    .setFields(Arrays.asList("mBuffer", "mIsMutable", "mWidth", "mHeight")).build();
  bitmapInstance // dimension larger than buffer
    .setFieldValue("mBuffer", ARRAY,
                   new FakeInstanceObject.Builder(fakeCaptureObject, 2, BYTES_CLASS_NAME).setValueType(ARRAY)
                     .setArray(BYTE, new byte[]{0, 0, 0, 0, 0, 0, 0, 0,}, 8).build())
    .setFieldValue("mWidth", INT, 3)
    .setFieldValue("mHeight", INT, 1)
    .setFieldValue("mIsMutable", BOOLEAN, false);
  FakeInstanceObject badBitmapInstance2 = new FakeInstanceObject.Builder(fakeCaptureObject, 1, BITMAP_CLASS_NAME)
    .setFields(Arrays.asList("mBuffer", "mIsMutable", "mWidth", "mHeight")).build();
  bitmapInstance // MIA fields
    .setFieldValue("mBuffer", ARRAY,
                   new FakeInstanceObject.Builder(fakeCaptureObject, 2, BYTES_CLASS_NAME).setValueType(ARRAY)
                     .setArray(BYTE, new byte[]{0, 0, 0, 0, 0, 0, 0, 0,}, 8).build())
    .setFieldValue("mWidth", INT, 2)
    .setFieldValue("mIsMutable", BOOLEAN, false);
  fakeCaptureObject.addInstanceObjects(ImmutableSet.of(bitmapInstance, badBitmapInstance1, badBitmapInstance2));
  BitmapDecoder.BitmapDataProvider dataProvider = AndroidBitmapDataProvider.createDecoder(bitmapInstance);
  assertNotNull(dataProvider);
  assertNotNull(BitmapDecoder.getBitmap(dataProvider));
  assertNull(AndroidBitmapDataProvider.createDecoder(badBitmapInstance1));
  assertNull(AndroidBitmapDataProvider.createDecoder(badBitmapInstance2));
}