[go: nahoru, domu]

Skip to content

Commit

Permalink
Create new ImageRenderer in render_tiledImageNonSquare_rendersAllImag…
Browse files Browse the repository at this point in the history
…esToOutput to allow it to use a separate bitmap from the other tests
  • Loading branch information
hakonschia committed Apr 30, 2024
1 parent 25befed commit 1d242bd
Showing 1 changed file with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,16 @@ public class ImageRendererTest {
Bitmap.createBitmap(/* width= */ 2, /* height= */ 2, Bitmap.Config.ARGB_8888);
private final Bitmap fakeDecodedBitmap2 =
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 int decodeCallCount;
private Bitmap overridenBitmap = null;

@Before
public void setUp() throws Exception {
decodeCallCount = 0;
ImageDecoder.Factory fakeDecoderFactory =
new BitmapFactoryImageDecoder.Factory(
(data, length) -> {
if (overridenBitmap != null) {
return overridenBitmap;
} else {
return ++decodeCallCount == 1 ? fakeDecodedBitmap1 : fakeDecodedBitmap2;
}
});
(data, length) -> ++decodeCallCount == 1 ? fakeDecodedBitmap1 : fakeDecodedBitmap2);
ImageOutput queuingImageOutput =
new ImageOutput() {
@Override
Expand Down Expand Up @@ -728,7 +719,26 @@ public void render_tiledImageStartPositionRightBeforeEOSAndWithinThreshold_rende

@Test
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 =
createSampleStream(
JPEG_FORMAT_WITH_SIX_TILES,
Expand Down

0 comments on commit 1d242bd

Please sign in to comment.