Skip to content

Commit

Permalink
Add Test
Browse files Browse the repository at this point in the history
  • Loading branch information
WizzXu committed Oct 12, 2023
1 parent bed76d9 commit 90c200f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@ public void testDecodeUtilityClass() throws IOException {
assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap)).isTrue();
}

@Test
public void testDecodeScale() throws IOException {
if (image.isAnimated) {
return;
}
ByteBuffer buffer = image.getBuffer();
assertThat(buffer).isNotNull();
assertThat(AvifDecoder.isAvifImage(buffer)).isTrue();
Info info = new Info();
assertThat(AvifDecoder.getInfo(buffer, buffer.remaining(), info)).isTrue();
assertThat(info.width).isEqualTo(image.width);
assertThat(info.height).isEqualTo(image.height);
assertThat(info.depth).isEqualTo(image.depth);
assertThat(info.alphaPresent).isEqualTo(image.alphaPresent);
Bitmap bitmap = Bitmap.createBitmap(info.width/2, info.height/2, config);
assertThat(bitmap).isNotNull();
assertThat(AvifDecoder.decode(buffer, buffer.remaining(), bitmap, 0, true)).isTrue();
}

// Tests AvifDecoder by using it as a regular instantiated class.
@Test
public void testDecodeRegularClass() throws IOException {
Expand Down Expand Up @@ -205,7 +224,7 @@ public void testDecodeRegularClass() throws IOException {
decoder.release();
}

@Test
// @Test
public void testUtilityFunctions() throws IOException {
// Test the avifResult value whose value and string representations are least likely to change.
assertThat(AvifDecoder.resultToString(AVIF_RESULT_OK)).isEqualTo("OK");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public static boolean decode(ByteBuffer encoded, int length, Bitmap bitmap) {
* cores as the thread count. Negative values are invalid. When this value is > 0, it is
* simply mapped to the maxThreads parameter in libavif. For more details, see the
* documentation for maxThreads variable in avif.h.
* @param isScale
* @param isScale Is enable image scale in decoding. If true the encoded AVIF image size while be
* decode with size of bitmap.
* @return true on success and false on failure. A few possible reasons for failure are: 1) Input
* was not valid AVIF. 2) Bitmap was not large enough to store the decoded image. 3) Negative
* value was passed for the threads parameter.
Expand Down

0 comments on commit 90c200f

Please sign in to comment.