Skip to content

Commit 7e31dab

Browse files
committed
Fix tests
1 parent 082f402 commit 7e31dab

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.github/workflows/test-webp.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Test WebP
22

33
on:
44
push:
5-
branches:
6-
- 'main'
75
paths:
86
- 'webp/**'
97
- '.github/workflows/test-webp.yml'
@@ -24,13 +22,16 @@ jobs:
2422
name: Linux (NgEngine)
2523
install: sudo find /usr -name 'libwebp*.so*' -exec mv {} {}.disabled \;
2624
expected-decode: Java (ngengine)
25+
expected-encode: libwebp (lossless-only)
2726
- os: macos-latest
2827
name: macOS (ImageIO)
2928
expected-decode: macOS ImageIO
29+
expected-encode: libwebp (lossless-only)
3030
- os: windows-latest
3131
name: Windows (WIC)
3232
install: winget install --id 9PG2DK419DRG --accept-package-agreements --accept-source-agreements --source msstore --silent
3333
expected-decode: Windows WIC
34+
expected-encode: libwebp (lossless-only)
3435

3536
name: ${{ matrix.name }}
3637
runs-on: ${{ matrix.os }}

webp/src/test/java/org/redlance/platformtools/webp/LibWebPTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
class LibWebPTest {
1616
@Test
17-
void encoderAvailableWithDecoder() {
18-
PlatformWebPDecoder dec = LibWebPDecoder.tryCreate();
19-
assumeTrue(dec != null, "libwebp not available");
20-
assertNotNull(LibWebPEncoder.tryCreate(), "libwebp encoder should be available when decoder is");
17+
void encoderAvailable() {
18+
assertNotNull(LibWebPEncoder.tryCreate(), "libwebp encoder should be available (bundled or system)");
2119
}
2220

2321
@Test
@@ -46,6 +44,18 @@ void lossyRoundtripDimensions() {
4644
assertEquals(original.length, decoded.argb().length);
4745
}
4846

47+
@Test
48+
void bundledLosslessRoundtrip() {
49+
LibWebPEncoder enc = LibWebPEncoder.tryCreate();
50+
assumeTrue(enc != null, "libwebp encoder not available");
51+
assumeTrue(PlatformWebPDecoder.INSTANCE.isAvailable(), "No decoder available");
52+
53+
int[] original = TestUtils.generateTestImage();
54+
byte[] encoded = enc.encodeLossless(original, TestUtils.W, TestUtils.H);
55+
DecodedImage decoded = PlatformWebPDecoder.INSTANCE.decode(encoded);
56+
assertArrayEquals(original, decoded.argb(), "Lossless roundtrip pixels must match exactly");
57+
}
58+
4959
@Test
5060
void decodeTestFile() throws IOException {
5161
PlatformWebPDecoder dec = LibWebPDecoder.tryCreate();

0 commit comments

Comments
 (0)