AndroidUtil { public static Bitmap toBitmap(Picture pic) { return inst().toBitmapImpl(pic); } AndroidUtil(BitmapUtil bitmapUtil); static Bitmap toBitmap(Picture pic); static void toBitmap(Picture pic, Bitmap out); static Picture fromBitmap(Bitmap bitmap, ColorSpace colorSpace); static Picture fromBitmap(Bitmap bitmap, VideoEncoder encoder); static void fromBitmap(Bitmap bitmap, Picture out); Bitmap toBitmapImpl(Picture pic); void toBitmapImpl(Picture pic, Bitmap out); Picture fromBitmapImpl(Bitmap bitmap, ColorSpace colorSpace); Picture fromBitmapImpl(Bitmap bitmap, VideoEncoder encoder); void fromBitmapImpl(Bitmap bitmap, Picture out);  }
@Test public void testToBitmap() { BitmapUtil bitmapUtil = mock(BitmapUtil.class); Picture expected = Picture.create(16, 16, ColorSpace.RGB); Picture src = Picture.create(16, 16, ColorSpace.YUV420J); Arrays.fill(src.getPlaneData(0), (byte) (169 - 128)); Arrays.fill(src.getPlaneData(1), (byte) (45 - 128)); Arrays.fill(src.getPlaneData(2), (byte) (103 - 128)); for (int i = 0; i < 256 * 3; i += 3) { expected.getPlaneData(0)[i] = (byte) (134 - 128); expected.getPlaneData(0)[i + 1] = (byte) (215 - 128); expected.getPlaneData(0)[i + 2] = (byte) (22 - 128); } AndroidUtil util = new AndroidUtil(bitmapUtil); util.toBitmapImpl(src); verify(bitmapUtil).toBitmapImpl(eq(expected)); }