diff --git a/library/src/androidTest/java/com/google/android/exoplayer/extractor/ogg/OggExtractorFileTests.java b/library/src/androidTest/java/com/google/android/exoplayer/extractor/ogg/OggExtractorFileTests.java index 4234dd03bc..d4aca29f98 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer/extractor/ogg/OggExtractorFileTests.java +++ b/library/src/androidTest/java/com/google/android/exoplayer/extractor/ogg/OggExtractorFileTests.java @@ -15,7 +15,9 @@ */ package com.google.android.exoplayer.extractor.ogg; +import com.google.android.exoplayer.extractor.Extractor; import com.google.android.exoplayer.testutil.TestUtil; +import com.google.android.exoplayer.testutil.TestUtil.ExtractorFactory; import android.test.InstrumentationTestCase; @@ -24,21 +26,28 @@ import android.test.InstrumentationTestCase; */ public final class OggExtractorFileTests extends InstrumentationTestCase { + private static final ExtractorFactory OGG_EXTRACTOR_FACTORY = new ExtractorFactory() { + @Override + public Extractor create() { + return new OggExtractor(); + } + }; + public void testOpus() throws Exception { - TestUtil.assertOutput(new OggExtractor(), "ogg/bear.opus", getInstrumentation()); + TestUtil.assertOutput(OGG_EXTRACTOR_FACTORY, "ogg/bear.opus", getInstrumentation()); } public void testFlac() throws Exception { - TestUtil.assertOutput(new OggExtractor(), "ogg/bear_flac.ogg", getInstrumentation()); + TestUtil.assertOutput(OGG_EXTRACTOR_FACTORY, "ogg/bear_flac.ogg", getInstrumentation()); } public void testFlacNoSeektable() throws Exception { - TestUtil.assertOutput(new OggExtractor(), "ogg/bear_flac_noseektable.ogg", + TestUtil.assertOutput(OGG_EXTRACTOR_FACTORY, "ogg/bear_flac_noseektable.ogg", getInstrumentation()); } public void testVorbis() throws Exception { - TestUtil.assertOutput(new OggExtractor(), "ogg/bear_vorbis.ogg", getInstrumentation()); + TestUtil.assertOutput(OGG_EXTRACTOR_FACTORY, "ogg/bear_vorbis.ogg", getInstrumentation()); } } diff --git a/library/src/androidTest/java/com/google/android/exoplayer/testutil/TestUtil.java b/library/src/androidTest/java/com/google/android/exoplayer/testutil/TestUtil.java index 0f73e7e94e..f366fd0dd8 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer/testutil/TestUtil.java +++ b/library/src/androidTest/java/com/google/android/exoplayer/testutil/TestUtil.java @@ -36,6 +36,13 @@ import java.util.Random; */ public class TestUtil { + /** + * A factory for {@link Extractor} instances. + */ + public interface ExtractorFactory { + Extractor create(); + } + private static final String DUMP_EXTENSION = ".dump"; private static final String UNKNOWN_LENGTH_EXTENSION = ".unklen"; @@ -170,23 +177,24 @@ public class TestUtil { * Calls {@link #assertOutput(Extractor, String, Instrumentation, boolean, boolean, boolean)} with * all possible combinations of "simulate" parameters. * - * @param extractor The {@link Extractor} to be tested. + * @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor} + * class which is to be tested. * @param sampleFile The path to the input sample. * @param instrumentation To be used to load the sample file. * @throws IOException If reading from the input fails. * @throws InterruptedException If interrupted while reading from the input. * @see #assertOutput(Extractor, String, Instrumentation, boolean, boolean, boolean) */ - public static void assertOutput(Extractor extractor, String sampleFile, + public static void assertOutput(ExtractorFactory factory, String sampleFile, Instrumentation instrumentation) throws IOException, InterruptedException { - assertOutput(extractor, sampleFile, instrumentation, false, false, false); - assertOutput(extractor, sampleFile, instrumentation, true, false, false); - assertOutput(extractor, sampleFile, instrumentation, false, true, false); - assertOutput(extractor, sampleFile, instrumentation, true, true, false); - assertOutput(extractor, sampleFile, instrumentation, false, false, true); - assertOutput(extractor, sampleFile, instrumentation, true, false, true); - assertOutput(extractor, sampleFile, instrumentation, false, true, true); - assertOutput(extractor, sampleFile, instrumentation, true, true, true); + assertOutput(factory.create(), sampleFile, instrumentation, false, false, false); + assertOutput(factory.create(), sampleFile, instrumentation, true, false, false); + assertOutput(factory.create(), sampleFile, instrumentation, false, true, false); + assertOutput(factory.create(), sampleFile, instrumentation, true, true, false); + assertOutput(factory.create(), sampleFile, instrumentation, false, false, true); + assertOutput(factory.create(), sampleFile, instrumentation, true, false, true); + assertOutput(factory.create(), sampleFile, instrumentation, false, true, true); + assertOutput(factory.create(), sampleFile, instrumentation, true, true, true); } /**