mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Create new ImageRenderer in render_tiledImageNonSquare_rendersAllImagesToOutput to allow it to use a separate bitmap from the other tests
This commit is contained in:
parent
e27f527ed1
commit
cf41ba3a3d
@ -84,25 +84,16 @@ public class ImageRendererTest {
|
|||||||
Bitmap.createBitmap(/* width= */ 2, /* height= */ 2, Bitmap.Config.ARGB_8888);
|
Bitmap.createBitmap(/* width= */ 2, /* height= */ 2, Bitmap.Config.ARGB_8888);
|
||||||
private final Bitmap fakeDecodedBitmap2 =
|
private final Bitmap fakeDecodedBitmap2 =
|
||||||
Bitmap.createBitmap(/* width= */ 4, /* height= */ 4, Bitmap.Config.ARGB_8888);
|
Bitmap.createBitmap(/* width= */ 4, /* height= */ 4, Bitmap.Config.ARGB_8888);
|
||||||
private final Bitmap fakeDecodedBitmap3 =
|
|
||||||
Bitmap.createBitmap(/* width= */ 2, /* height= */ 3, Bitmap.Config.ARGB_8888);
|
|
||||||
|
|
||||||
private ImageRenderer renderer;
|
private ImageRenderer renderer;
|
||||||
private int decodeCallCount;
|
private int decodeCallCount;
|
||||||
private Bitmap overridenBitmap = null;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
decodeCallCount = 0;
|
decodeCallCount = 0;
|
||||||
ImageDecoder.Factory fakeDecoderFactory =
|
ImageDecoder.Factory fakeDecoderFactory =
|
||||||
new BitmapFactoryImageDecoder.Factory(
|
new BitmapFactoryImageDecoder.Factory(
|
||||||
(data, length) -> {
|
(data, length) -> ++decodeCallCount == 1 ? fakeDecodedBitmap1 : fakeDecodedBitmap2);
|
||||||
if (overridenBitmap != null) {
|
|
||||||
return overridenBitmap;
|
|
||||||
} else {
|
|
||||||
return ++decodeCallCount == 1 ? fakeDecodedBitmap1 : fakeDecodedBitmap2;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ImageOutput queuingImageOutput =
|
ImageOutput queuingImageOutput =
|
||||||
new ImageOutput() {
|
new ImageOutput() {
|
||||||
@Override
|
@Override
|
||||||
@ -728,7 +719,26 @@ public class ImageRendererTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void render_tiledImageNonSquare_rendersAllImagesToOutput() throws Exception {
|
public void render_tiledImageNonSquare_rendersAllImagesToOutput() throws Exception {
|
||||||
overridenBitmap = fakeDecodedBitmap3;
|
ImageDecoder.Factory fakeDecoderFactory =
|
||||||
|
new BitmapFactoryImageDecoder.Factory(
|
||||||
|
(data, length) ->
|
||||||
|
Bitmap.createBitmap(/* width= */ 2, /* height= */ 3, Bitmap.Config.ARGB_8888));
|
||||||
|
ImageOutput queuingImageOutput =
|
||||||
|
new ImageOutput() {
|
||||||
|
@Override
|
||||||
|
public void onImageAvailable(long presentationTimeUs, Bitmap bitmap) {
|
||||||
|
renderedBitmaps.add(Pair.create(presentationTimeUs, bitmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisabled() {
|
||||||
|
// Do nothing.
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
renderer = new ImageRenderer(fakeDecoderFactory, queuingImageOutput);
|
||||||
|
renderer.init(/* index= */ 0, PlayerId.UNSET, Clock.DEFAULT);
|
||||||
|
|
||||||
FakeSampleStream fakeSampleStream =
|
FakeSampleStream fakeSampleStream =
|
||||||
createSampleStream(
|
createSampleStream(
|
||||||
JPEG_FORMAT_WITH_SIX_TILES,
|
JPEG_FORMAT_WITH_SIX_TILES,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user