From fc32b7f2813387c4b04497e607a869e7dc8cece0 Mon Sep 17 00:00:00 2001 From: rohks Date: Wed, 30 Oct 2024 09:59:26 -0700 Subject: [PATCH] Refactor `OpusDecoderTest` to use `OpusLibrary.isAvailable()` Replaced the custom `LibraryLoader` instance with `OpusLibrary.isAvailable()` to verify the library loading. This simplifies the code by leveraging the existing library loading mechanism. #cherrypick PiperOrigin-RevId: 691457871 (cherry picked from commit 2b27e33784e9839e8c14fdddba90efc1435acb3a) --- .../media3/decoder/opus/OpusDecoderTest.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/libraries/decoder_opus/src/androidTest/java/androidx/media3/decoder/opus/OpusDecoderTest.java b/libraries/decoder_opus/src/androidTest/java/androidx/media3/decoder/opus/OpusDecoderTest.java index 9aa17cffcf..5b74c44dac 100644 --- a/libraries/decoder_opus/src/androidTest/java/androidx/media3/decoder/opus/OpusDecoderTest.java +++ b/libraries/decoder_opus/src/androidTest/java/androidx/media3/decoder/opus/OpusDecoderTest.java @@ -20,7 +20,6 @@ import static org.junit.Assume.assumeTrue; import androidx.annotation.Nullable; import androidx.media3.common.C; -import androidx.media3.common.util.LibraryLoader; import androidx.media3.decoder.DecoderInputBuffer; import androidx.media3.decoder.SimpleDecoderOutputBuffer; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -34,14 +33,6 @@ import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public final class OpusDecoderTest { - private static final LibraryLoader LOADER = - new LibraryLoader("opusV2JNI") { - @Override - protected void loadLibrary(String name) { - System.loadLibrary(name); - } - }; - private static final byte[] HEADER = new byte[] {79, 112, 117, 115, 72, 101, 97, 100, 0, 2, 1, 56, 0, 0, -69, -128, 0, 0, 0}; @@ -115,7 +106,7 @@ public final class OpusDecoderTest { @Test public void decode_removesPreSkipFromOutput() throws OpusDecoderException { - assumeTrue(LOADER.isAvailable()); + assumeTrue(OpusLibrary.isAvailable()); OpusDecoder decoder = new OpusDecoder( /* numInputBuffers= */ 0, @@ -135,7 +126,7 @@ public final class OpusDecoderTest { @Test public void decode_whenDiscardPaddingDisabled_returnsDiscardPadding() throws OpusDecoderException { - assumeTrue(LOADER.isAvailable()); + assumeTrue(OpusLibrary.isAvailable()); OpusDecoder decoder = new OpusDecoder( /* numInputBuffers= */ 0, @@ -156,7 +147,7 @@ public final class OpusDecoderTest { @Test public void decode_whenDiscardPaddingEnabled_removesDiscardPadding() throws OpusDecoderException { - assumeTrue(LOADER.isAvailable()); + assumeTrue(OpusLibrary.isAvailable()); OpusDecoder decoder = new OpusDecoder( /* numInputBuffers= */ 0,