Commit 922b8a2c by ibaker Committed by Oliver Woodman

Add option to FakeTrackOutput to de-duplicate repeated formats

Expose this through ExtractorAsserts via a new AssertionConfig object

PiperOrigin-RevId: 308980701
parent 625c7347
Showing with 180 additions and 131 deletions
...@@ -38,18 +38,18 @@ public final class AmrExtractorParameterizedTest { ...@@ -38,18 +38,18 @@ public final class AmrExtractorParameterizedTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void extractingNarrowBandSamples() throws Exception { public void extractingNarrowBandSamples() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_nb.amr", assertionConfig); createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_nb.amr", simulationConfig);
} }
@Test @Test
public void extractingWideBandSamples() throws Exception { public void extractingWideBandSamples() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_wb.amr", assertionConfig); createAmrExtractorFactory(/* withSeeking= */ false), "amr/sample_wb.amr", simulationConfig);
} }
@Test @Test
...@@ -57,7 +57,7 @@ public final class AmrExtractorParameterizedTest { ...@@ -57,7 +57,7 @@ public final class AmrExtractorParameterizedTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ true), createAmrExtractorFactory(/* withSeeking= */ true),
"amr/sample_nb_cbr.amr", "amr/sample_nb_cbr.amr",
assertionConfig); simulationConfig);
} }
@Test @Test
...@@ -65,7 +65,7 @@ public final class AmrExtractorParameterizedTest { ...@@ -65,7 +65,7 @@ public final class AmrExtractorParameterizedTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
createAmrExtractorFactory(/* withSeeking= */ true), createAmrExtractorFactory(/* withSeeking= */ true),
"amr/sample_wb_cbr.amr", "amr/sample_wb_cbr.amr",
assertionConfig); simulationConfig);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.flac; package com.google.android.exoplayer2.extractor.flac;
import com.google.android.exoplayer2.testutil.ExtractorAsserts; import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -33,95 +34,107 @@ public class FlacExtractorTest { ...@@ -33,95 +34,107 @@ public class FlacExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void sample() throws Exception { public void sample() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear.flac", "flac/bear.flac",
assertionConfig, new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_flac").build(),
/* dumpFilesPrefix= */ "flac/bear_flac"); simulationConfig);
} }
@Test @Test
public void sampleWithId3HeaderAndId3Enabled() throws Exception { public void sampleWithId3HeaderAndId3Enabled() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_with_id3.flac", "flac/bear_with_id3.flac",
assertionConfig, new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_with_id3_enabled_flac").build(),
/* dumpFilesPrefix= */ "flac/bear_with_id3_enabled_flac"); simulationConfig);
} }
@Test @Test
public void sampleWithId3HeaderAndId3Disabled() throws Exception { public void sampleWithId3HeaderAndId3Disabled() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new FlacExtractor(FlacExtractor.FLAG_DISABLE_ID3_METADATA), () -> new FlacExtractor(FlacExtractor.FLAG_DISABLE_ID3_METADATA),
/* file= */ "flac/bear_with_id3.flac", "flac/bear_with_id3.flac",
assertionConfig, new AssertionConfig.Builder()
/* dumpFilesPrefix= */ "flac/bear_with_id3_disabled_flac"); .setDumpFilesPrefix("flac/bear_with_id3_disabled_flac")
.build(),
simulationConfig);
} }
@Test @Test
public void sampleUnseekable() throws Exception { public void sampleUnseekable() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_no_seek_table_no_num_samples.flac", "flac/bear_no_seek_table_no_num_samples.flac",
assertionConfig, new AssertionConfig.Builder()
/* dumpFilesPrefix= */ "flac/bear_no_seek_table_no_num_samples_flac"); .setDumpFilesPrefix("flac/bear_no_seek_table_no_num_samples_flac")
.build(),
simulationConfig);
} }
@Test @Test
public void sampleWithVorbisComments() throws Exception { public void sampleWithVorbisComments() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_with_vorbis_comments.flac", "flac/bear_with_vorbis_comments.flac",
assertionConfig, new AssertionConfig.Builder()
/* dumpFilesPrefix= */ "flac/bear_with_vorbis_comments_flac"); .setDumpFilesPrefix("flac/bear_with_vorbis_comments_flac")
.build(),
simulationConfig);
} }
@Test @Test
public void sampleWithPicture() throws Exception { public void sampleWithPicture() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_with_picture.flac", "flac/bear_with_picture.flac",
assertionConfig, new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_with_picture_flac").build(),
/* dumpFilesPrefix= */ "flac/bear_with_picture_flac"); simulationConfig);
} }
@Test @Test
public void oneMetadataBlock() throws Exception { public void oneMetadataBlock() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_one_metadata_block.flac", "flac/bear_one_metadata_block.flac",
assertionConfig, new AssertionConfig.Builder()
/* dumpFilesPrefix= */ "flac/bear_one_metadata_block_flac"); .setDumpFilesPrefix("flac/bear_one_metadata_block_flac")
.build(),
simulationConfig);
} }
@Test @Test
public void noMinMaxFrameSize() throws Exception { public void noMinMaxFrameSize() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_no_min_max_frame_size.flac", "flac/bear_no_min_max_frame_size.flac",
assertionConfig, new AssertionConfig.Builder()
/* dumpFilesPrefix= */ "flac/bear_no_min_max_frame_size_flac"); .setDumpFilesPrefix("flac/bear_no_min_max_frame_size_flac")
.build(),
simulationConfig);
} }
@Test @Test
public void noNumSamples() throws Exception { public void noNumSamples() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_no_num_samples.flac", "flac/bear_no_num_samples.flac",
assertionConfig, new AssertionConfig.Builder().setDumpFilesPrefix("flac/bear_no_num_samples_flac").build(),
/* dumpFilesPrefix= */ "flac/bear_no_num_samples_flac"); simulationConfig);
} }
@Test @Test
public void uncommonSampleRate() throws Exception { public void uncommonSampleRate() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_uncommon_sample_rate.flac", "flac/bear_uncommon_sample_rate.flac",
assertionConfig, new AssertionConfig.Builder()
/* dumpFilesPrefix= */ "flac/bear_uncommon_sample_rate_flac"); .setDumpFilesPrefix("flac/bear_uncommon_sample_rate_flac")
.build(),
simulationConfig);
} }
} }
...@@ -33,10 +33,10 @@ public final class FlvExtractorTest { ...@@ -33,10 +33,10 @@ public final class FlvExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void sample() throws Exception { public void sample() throws Exception {
ExtractorAsserts.assertBehavior(FlvExtractor::new, "flv/sample.flv", assertionConfig); ExtractorAsserts.assertBehavior(FlvExtractor::new, "flv/sample.flv", simulationConfig);
} }
} }
...@@ -33,39 +33,40 @@ public final class MatroskaExtractorTest { ...@@ -33,39 +33,40 @@ public final class MatroskaExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void mkvSample() throws Exception { public void mkvSample() throws Exception {
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/sample.mkv", assertionConfig); ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/sample.mkv", simulationConfig);
} }
@Test @Test
public void mkvSample_withSubripSubtitles() throws Exception { public void mkvSample_withSubripSubtitles() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/sample_with_srt.mkv", assertionConfig); MatroskaExtractor::new, "mkv/sample_with_srt.mkv", simulationConfig);
} }
@Test @Test
public void mkvSample_withHtcRotationInfoInTrackName() throws Exception { public void mkvSample_withHtcRotationInfoInTrackName() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/sample_with_htc_rotation_track_name.mkv", assertionConfig); MatroskaExtractor::new, "mkv/sample_with_htc_rotation_track_name.mkv", simulationConfig);
} }
@Test @Test
public void mkvFullBlocksSample() throws Exception { public void mkvFullBlocksSample() throws Exception {
ExtractorAsserts.assertBehavior(MatroskaExtractor::new, "mkv/full_blocks.mkv", assertionConfig); ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/full_blocks.mkv", simulationConfig);
} }
@Test @Test
public void webmSubsampleEncryption() throws Exception { public void webmSubsampleEncryption() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/subsample_encrypted_noaltref.webm", assertionConfig); MatroskaExtractor::new, "mkv/subsample_encrypted_noaltref.webm", simulationConfig);
} }
@Test @Test
public void webmSubsampleEncryptionWithAltrefFrames() throws Exception { public void webmSubsampleEncryptionWithAltrefFrames() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
MatroskaExtractor::new, "mkv/subsample_encrypted_altref.webm", assertionConfig); MatroskaExtractor::new, "mkv/subsample_encrypted_altref.webm", simulationConfig);
} }
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.mp3; package com.google.android.exoplayer2.extractor.mp3;
import com.google.android.exoplayer2.testutil.ExtractorAsserts; import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -33,18 +34,18 @@ public final class Mp3ExtractorTest { ...@@ -33,18 +34,18 @@ public final class Mp3ExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void mp3SampleWithXingHeader() throws Exception { public void mp3SampleWithXingHeader() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
Mp3Extractor::new, "mp3/bear-vbr-xing-header.mp3", assertionConfig); Mp3Extractor::new, "mp3/bear-vbr-xing-header.mp3", simulationConfig);
} }
@Test @Test
public void mp3SampleWithCbrSeeker() throws Exception { public void mp3SampleWithCbrSeeker() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
Mp3Extractor::new, "mp3/bear-cbr-variable-frame-size-no-seek-table.mp3", assertionConfig); Mp3Extractor::new, "mp3/bear-cbr-variable-frame-size-no-seek-table.mp3", simulationConfig);
} }
@Test @Test
...@@ -52,29 +53,29 @@ public final class Mp3ExtractorTest { ...@@ -52,29 +53,29 @@ public final class Mp3ExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new Mp3Extractor(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING), () -> new Mp3Extractor(Mp3Extractor.FLAG_ENABLE_INDEX_SEEKING),
"mp3/bear-vbr-no-seek-table.mp3", "mp3/bear-vbr-no-seek-table.mp3",
assertionConfig); simulationConfig);
} }
@Test @Test
public void trimmedMp3Sample() throws Exception { public void trimmedMp3Sample() throws Exception {
ExtractorAsserts.assertBehavior(Mp3Extractor::new, "mp3/play-trimmed.mp3", assertionConfig); ExtractorAsserts.assertBehavior(Mp3Extractor::new, "mp3/play-trimmed.mp3", simulationConfig);
} }
@Test @Test
public void mp3SampleWithId3Enabled() throws Exception { public void mp3SampleWithId3Enabled() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
Mp3Extractor::new, Mp3Extractor::new,
/* file= */ "mp3/bear-id3.mp3", "mp3/bear-id3.mp3",
assertionConfig, new AssertionConfig.Builder().setDumpFilesPrefix("mp3/bear-id3-enabled").build(),
/* dumpFilesPrefix= */ "mp3/bear-id3-enabled"); simulationConfig);
} }
@Test @Test
public void mp3SampleWithId3Disabled() throws Exception { public void mp3SampleWithId3Disabled() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new Mp3Extractor(Mp3Extractor.FLAG_DISABLE_ID3_METADATA), () -> new Mp3Extractor(Mp3Extractor.FLAG_DISABLE_ID3_METADATA),
/* file= */ "mp3/bear-id3.mp3", "mp3/bear-id3.mp3",
assertionConfig, new AssertionConfig.Builder().setDumpFilesPrefix("mp3/bear-id3-disabled").build(),
/* dumpFilesPrefix= */ "mp3/bear-id3-disabled"); simulationConfig);
} }
} }
...@@ -38,12 +38,12 @@ public final class FragmentedMp4ExtractorTest { ...@@ -38,12 +38,12 @@ public final class FragmentedMp4ExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void sample() throws Exception { public void sample() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_fragmented.mp4", assertionConfig); getExtractorFactory(ImmutableList.of()), "mp4/sample_fragmented.mp4", simulationConfig);
} }
@Test @Test
...@@ -51,7 +51,7 @@ public final class FragmentedMp4ExtractorTest { ...@@ -51,7 +51,7 @@ public final class FragmentedMp4ExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), getExtractorFactory(ImmutableList.of()),
"mp4/sample_fragmented_seekable.mp4", "mp4/sample_fragmented_seekable.mp4",
assertionConfig); simulationConfig);
} }
@Test @Test
...@@ -62,31 +62,33 @@ public final class FragmentedMp4ExtractorTest { ...@@ -62,31 +62,33 @@ public final class FragmentedMp4ExtractorTest {
Collections.singletonList( Collections.singletonList(
new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build())); new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).build()));
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
extractorFactory, "mp4/sample_fragmented_sei.mp4", assertionConfig); extractorFactory, "mp4/sample_fragmented_sei.mp4", simulationConfig);
} }
@Test @Test
public void sampleWithAc3Track() throws Exception { public void sampleWithAc3Track() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac3_fragmented.mp4", assertionConfig); getExtractorFactory(ImmutableList.of()), "mp4/sample_ac3_fragmented.mp4", simulationConfig);
} }
@Test @Test
public void sampleWithAc4Track() throws Exception { public void sampleWithAc4Track() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_fragmented.mp4", assertionConfig); getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_fragmented.mp4", simulationConfig);
} }
@Test @Test
public void sampleWithProtectedAc4Track() throws Exception { public void sampleWithProtectedAc4Track() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_protected.mp4", assertionConfig); getExtractorFactory(ImmutableList.of()), "mp4/sample_ac4_protected.mp4", simulationConfig);
} }
@Test @Test
public void sampleWithEac3Track() throws Exception { public void sampleWithEac3Track() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), "mp4/sample_eac3_fragmented.mp4", assertionConfig); getExtractorFactory(ImmutableList.of()),
"mp4/sample_eac3_fragmented.mp4",
simulationConfig);
} }
@Test @Test
...@@ -94,7 +96,7 @@ public final class FragmentedMp4ExtractorTest { ...@@ -94,7 +96,7 @@ public final class FragmentedMp4ExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
getExtractorFactory(ImmutableList.of()), getExtractorFactory(ImmutableList.of()),
"mp4/sample_eac3joc_fragmented.mp4", "mp4/sample_eac3joc_fragmented.mp4",
assertionConfig); simulationConfig);
} }
private static ExtractorFactory getExtractorFactory(final List<Format> closedCaptionFormats) { private static ExtractorFactory getExtractorFactory(final List<Format> closedCaptionFormats) {
......
...@@ -33,17 +33,17 @@ public final class Mp4ExtractorTest { ...@@ -33,17 +33,17 @@ public final class Mp4ExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void mp4Sample() throws Exception { public void mp4Sample() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample.mp4", assertionConfig); ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample.mp4", simulationConfig);
} }
@Test @Test
public void mp4SampleWithSlowMotionMetadata() throws Exception { public void mp4SampleWithSlowMotionMetadata() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
Mp4Extractor::new, "mp4/sample_android_slow_motion.mp4", assertionConfig); Mp4Extractor::new, "mp4/sample_android_slow_motion.mp4", simulationConfig);
} }
/** /**
...@@ -53,26 +53,26 @@ public final class Mp4ExtractorTest { ...@@ -53,26 +53,26 @@ public final class Mp4ExtractorTest {
@Test @Test
public void mp4SampleWithMdatTooLong() throws Exception { public void mp4SampleWithMdatTooLong() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
Mp4Extractor::new, "mp4/sample_mdat_too_long.mp4", assertionConfig); Mp4Extractor::new, "mp4/sample_mdat_too_long.mp4", simulationConfig);
} }
@Test @Test
public void mp4SampleWithAc3Track() throws Exception { public void mp4SampleWithAc3Track() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac3.mp4", assertionConfig); ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac3.mp4", simulationConfig);
} }
@Test @Test
public void mp4SampleWithAc4Track() throws Exception { public void mp4SampleWithAc4Track() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac4.mp4", assertionConfig); ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_ac4.mp4", simulationConfig);
} }
@Test @Test
public void mp4SampleWithEac3Track() throws Exception { public void mp4SampleWithEac3Track() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3.mp4", assertionConfig); ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3.mp4", simulationConfig);
} }
@Test @Test
public void mp4SampleWithEac3jocTrack() throws Exception { public void mp4SampleWithEac3jocTrack() throws Exception {
ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3joc.mp4", assertionConfig); ExtractorAsserts.assertBehavior(Mp4Extractor::new, "mp4/sample_eac3joc.mp4", simulationConfig);
} }
} }
...@@ -37,26 +37,26 @@ public final class OggExtractorParameterizedTest { ...@@ -37,26 +37,26 @@ public final class OggExtractorParameterizedTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void opus() throws Exception { public void opus() throws Exception {
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear.opus", assertionConfig); ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear.opus", simulationConfig);
} }
@Test @Test
public void flac() throws Exception { public void flac() throws Exception {
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_flac.ogg", assertionConfig); ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_flac.ogg", simulationConfig);
} }
@Test @Test
public void flacNoSeektable() throws Exception { public void flacNoSeektable() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
OggExtractor::new, "ogg/bear_flac_noseektable.ogg", assertionConfig); OggExtractor::new, "ogg/bear_flac_noseektable.ogg", simulationConfig);
} }
@Test @Test
public void vorbis() throws Exception { public void vorbis() throws Exception {
ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_vorbis.ogg", assertionConfig); ExtractorAsserts.assertBehavior(OggExtractor::new, "ogg/bear_vorbis.ogg", simulationConfig);
} }
} }
...@@ -33,7 +33,7 @@ public final class RawCcExtractorTest { ...@@ -33,7 +33,7 @@ public final class RawCcExtractorTest {
} }
@ParameterizedRobolectricTestRunner.Parameter(0) @ParameterizedRobolectricTestRunner.Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void rawCcSample() throws Exception { public void rawCcSample() throws Exception {
...@@ -44,6 +44,6 @@ public final class RawCcExtractorTest { ...@@ -44,6 +44,6 @@ public final class RawCcExtractorTest {
.setAccessibilityChannel(1) .setAccessibilityChannel(1)
.build(); .build();
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new RawCcExtractor(format), "rawcc/sample.rawcc", assertionConfig); () -> new RawCcExtractor(format), "rawcc/sample.rawcc", simulationConfig);
} }
} }
...@@ -33,20 +33,20 @@ public final class Ac3ExtractorTest { ...@@ -33,20 +33,20 @@ public final class Ac3ExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void ac3Sample() throws Exception { public void ac3Sample() throws Exception {
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.ac3", assertionConfig); ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.ac3", simulationConfig);
} }
@Test @Test
public void eAc3Sample() throws Exception { public void eAc3Sample() throws Exception {
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.eac3", assertionConfig); ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample.eac3", simulationConfig);
} }
@Test @Test
public void eAc3jocSample() throws Exception { public void eAc3jocSample() throws Exception {
ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample_eac3joc.ec3", assertionConfig); ExtractorAsserts.assertBehavior(Ac3Extractor::new, "ts/sample_eac3joc.ec3", simulationConfig);
} }
} }
...@@ -33,10 +33,10 @@ public final class Ac4ExtractorTest { ...@@ -33,10 +33,10 @@ public final class Ac4ExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void ac4Sample() throws Exception { public void ac4Sample() throws Exception {
ExtractorAsserts.assertBehavior(Ac4Extractor::new, "ts/sample.ac4", assertionConfig); ExtractorAsserts.assertBehavior(Ac4Extractor::new, "ts/sample.ac4", simulationConfig);
} }
} }
...@@ -33,16 +33,17 @@ public final class AdtsExtractorTest { ...@@ -33,16 +33,17 @@ public final class AdtsExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void sample() throws Exception { public void sample() throws Exception {
ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample.adts", assertionConfig); ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample.adts", simulationConfig);
} }
@Test @Test
public void sample_with_id3() throws Exception { public void sample_with_id3() throws Exception {
ExtractorAsserts.assertBehavior(AdtsExtractor::new, "ts/sample_with_id3.adts", assertionConfig); ExtractorAsserts.assertBehavior(
AdtsExtractor::new, "ts/sample_with_id3.adts", simulationConfig);
} }
@Test @Test
...@@ -50,7 +51,7 @@ public final class AdtsExtractorTest { ...@@ -50,7 +51,7 @@ public final class AdtsExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING), () -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
"ts/sample_cbs.adts", "ts/sample_cbs.adts",
assertionConfig); simulationConfig);
} }
// https://github.com/google/ExoPlayer/issues/6700 // https://github.com/google/ExoPlayer/issues/6700
...@@ -59,6 +60,6 @@ public final class AdtsExtractorTest { ...@@ -59,6 +60,6 @@ public final class AdtsExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING), () -> new AdtsExtractor(/* flags= */ AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING),
"ts/sample_cbs_truncated.adts", "ts/sample_cbs_truncated.adts",
assertionConfig); simulationConfig);
} }
} }
...@@ -33,16 +33,16 @@ public final class PsExtractorTest { ...@@ -33,16 +33,16 @@ public final class PsExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void sampleWithH262AndMpegAudio() throws Exception { public void sampleWithH262AndMpegAudio() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
PsExtractor::new, "ts/sample_h262_mpeg_audio.ps", assertionConfig); PsExtractor::new, "ts/sample_h262_mpeg_audio.ps", simulationConfig);
} }
@Test @Test
public void sampleWithAc3() throws Exception { public void sampleWithAc3() throws Exception {
ExtractorAsserts.assertBehavior(PsExtractor::new, "ts/sample_ac3.ps", assertionConfig); ExtractorAsserts.assertBehavior(PsExtractor::new, "ts/sample_ac3.ps", simulationConfig);
} }
} }
...@@ -37,7 +37,6 @@ import com.google.android.exoplayer2.testutil.TestUtil; ...@@ -37,7 +37,6 @@ import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.TimestampAdjuster; import com.google.android.exoplayer2.util.TimestampAdjuster;
import java.util.List; import java.util.List;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.ParameterizedRobolectricTestRunner; import org.robolectric.ParameterizedRobolectricTestRunner;
...@@ -54,18 +53,18 @@ public final class TsExtractorTest { ...@@ -54,18 +53,18 @@ public final class TsExtractorTest {
} }
@Parameter(0) @Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void sampleWithH262AndMpegAudio() throws Exception { public void sampleWithH262AndMpegAudio() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
TsExtractor::new, "ts/sample_h262_mpeg_audio.ts", assertionConfig); TsExtractor::new, "ts/sample_h262_mpeg_audio.ts", simulationConfig);
} }
@Test @Test
public void sampleWithH264AndMpegAudio() throws Exception { public void sampleWithH264AndMpegAudio() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
TsExtractor::new, "ts/sample_h264_mpeg_audio.ts", assertionConfig); TsExtractor::new, "ts/sample_h264_mpeg_audio.ts", simulationConfig);
} }
@Test @Test
...@@ -73,7 +72,7 @@ public final class TsExtractorTest { ...@@ -73,7 +72,7 @@ public final class TsExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new TsExtractor(FLAG_DETECT_ACCESS_UNITS), () -> new TsExtractor(FLAG_DETECT_ACCESS_UNITS),
"ts/sample_h264_no_access_unit_delimiters.ts", "ts/sample_h264_no_access_unit_delimiters.ts",
assertionConfig); simulationConfig);
} }
@Test @Test
...@@ -81,58 +80,64 @@ public final class TsExtractorTest { ...@@ -81,58 +80,64 @@ public final class TsExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
() -> new TsExtractor(DefaultTsPayloadReaderFactory.FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS), () -> new TsExtractor(DefaultTsPayloadReaderFactory.FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS),
"ts/sample_h264_dts_audio.ts", "ts/sample_h264_dts_audio.ts",
assertionConfig); simulationConfig);
} }
@Test @Test
public void sampleWithH265() throws Exception { public void sampleWithH265() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_h265.ts", assertionConfig); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_h265.ts", simulationConfig);
} }
@Test @Test
@Ignore
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
// formats and seeking.
public void sampleWithScte35() throws Exception { public void sampleWithScte35() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_scte35.ts", assertionConfig); ExtractorAsserts.assertBehavior(
TsExtractor::new,
"ts/sample_scte35.ts",
new ExtractorAsserts.AssertionConfig.Builder()
.setDeduplicateConsecutiveFormats(true)
.build(),
simulationConfig);
} }
@Test @Test
@Ignore
// TODO(internal: b/153539929) Re-enable when ExtractorAsserts is less strict around repeated
// formats and seeking.
public void sampleWithAit() throws Exception { public void sampleWithAit() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ait.ts", assertionConfig); ExtractorAsserts.assertBehavior(
TsExtractor::new,
"ts/sample_ait.ts",
new ExtractorAsserts.AssertionConfig.Builder()
.setDeduplicateConsecutiveFormats(true)
.build(),
simulationConfig);
} }
@Test @Test
public void sampleWithAc3() throws Exception { public void sampleWithAc3() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac3.ts", assertionConfig); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac3.ts", simulationConfig);
} }
@Test @Test
public void sampleWithAc4() throws Exception { public void sampleWithAc4() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac4.ts", assertionConfig); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_ac4.ts", simulationConfig);
} }
@Test @Test
public void sampleWithEac3() throws Exception { public void sampleWithEac3() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3.ts", assertionConfig); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3.ts", simulationConfig);
} }
@Test @Test
public void sampleWithEac3joc() throws Exception { public void sampleWithEac3joc() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3joc.ts", assertionConfig); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_eac3joc.ts", simulationConfig);
} }
@Test @Test
public void sampleWithLatm() throws Exception { public void sampleWithLatm() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_latm.ts", assertionConfig); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_latm.ts", simulationConfig);
} }
@Test @Test
public void streamWithJunkData() throws Exception { public void streamWithJunkData() throws Exception {
ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_with_junk", assertionConfig); ExtractorAsserts.assertBehavior(TsExtractor::new, "ts/sample_with_junk", simulationConfig);
} }
@Test @Test
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.extractor.wav; package com.google.android.exoplayer2.extractor.wav;
import com.google.android.exoplayer2.testutil.ExtractorAsserts; import com.google.android.exoplayer2.testutil.ExtractorAsserts;
import com.google.android.exoplayer2.testutil.ExtractorAsserts.AssertionConfig;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -31,11 +32,11 @@ public final class WavExtractorTest { ...@@ -31,11 +32,11 @@ public final class WavExtractorTest {
} }
@ParameterizedRobolectricTestRunner.Parameter(0) @ParameterizedRobolectricTestRunner.Parameter(0)
public ExtractorAsserts.Config assertionConfig; public ExtractorAsserts.SimulationConfig simulationConfig;
@Test @Test
public void sample() throws Exception { public void sample() throws Exception {
ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample.wav", assertionConfig); ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample.wav", simulationConfig);
} }
@Test @Test
...@@ -43,12 +44,13 @@ public final class WavExtractorTest { ...@@ -43,12 +44,13 @@ public final class WavExtractorTest {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertBehavior(
WavExtractor::new, WavExtractor::new,
"wav/sample_with_trailing_bytes.wav", "wav/sample_with_trailing_bytes.wav",
assertionConfig, new AssertionConfig.Builder().setDumpFilesPrefix("wav/sample.wav").build(),
/* dumpFilesPrefix= */ "wav/sample.wav"); simulationConfig);
} }
@Test @Test
public void sample_imaAdpcm() throws Exception { public void sample_imaAdpcm() throws Exception {
ExtractorAsserts.assertBehavior(WavExtractor::new, "wav/sample_ima_adpcm.wav", assertionConfig); ExtractorAsserts.assertBehavior(
WavExtractor::new, "wav/sample_ima_adpcm.wav", simulationConfig);
} }
} }
...@@ -55,7 +55,7 @@ track 600: ...@@ -55,7 +55,7 @@ track 600:
sample count = 3 sample count = 3
format 0: format 0:
sampleMimeType = application/x-scte35 sampleMimeType = application/x-scte35
subsampleOffsetUs = -1400000 subsampleOffsetUs = -1377756
sample 0: sample 0:
time = 55610 time = 55610
flags = 1 flags = 1
......
...@@ -55,7 +55,7 @@ track 600: ...@@ -55,7 +55,7 @@ track 600:
sample count = 3 sample count = 3
format 0: format 0:
sampleMimeType = application/x-scte35 sampleMimeType = application/x-scte35
subsampleOffsetUs = -1400000 subsampleOffsetUs = -1355512
sample 0: sample 0:
time = 77854 time = 77854
flags = 1 flags = 1
......
...@@ -39,7 +39,7 @@ track 600: ...@@ -39,7 +39,7 @@ track 600:
sample count = 0 sample count = 0
format 0: format 0:
sampleMimeType = application/x-scte35 sampleMimeType = application/x-scte35
subsampleOffsetUs = -1400000 subsampleOffsetUs = -1355512
track 8448: track 8448:
total output bytes = 0 total output bytes = 0
sample count = 0 sample count = 0
......
...@@ -68,12 +68,18 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab ...@@ -68,12 +68,18 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
@DumpFilesAction private static final int DUMP_FILE_ACTION = COMPARE_WITH_EXISTING; @DumpFilesAction private static final int DUMP_FILE_ACTION = COMPARE_WITH_EXISTING;
public final SparseArray<FakeTrackOutput> trackOutputs; public final SparseArray<FakeTrackOutput> trackOutputs;
private final FakeTrackOutput.Factory trackOutputFactory;
public int numberOfTracks; public int numberOfTracks;
public boolean tracksEnded; public boolean tracksEnded;
public @MonotonicNonNull SeekMap seekMap; public @MonotonicNonNull SeekMap seekMap;
public FakeExtractorOutput() { public FakeExtractorOutput() {
this(FakeTrackOutput.DEFAULT_FACTORY);
}
public FakeExtractorOutput(FakeTrackOutput.Factory trackOutputFactory) {
this.trackOutputFactory = trackOutputFactory;
trackOutputs = new SparseArray<>(); trackOutputs = new SparseArray<>();
} }
...@@ -83,7 +89,7 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab ...@@ -83,7 +89,7 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab
if (output == null) { if (output == null) {
assertThat(tracksEnded).isFalse(); assertThat(tracksEnded).isFalse();
numberOfTracks++; numberOfTracks++;
output = new FakeTrackOutput(); output = trackOutputFactory.create(id, type);
trackOutputs.put(id, output); trackOutputs.put(id, output);
} }
return output; return output;
......
...@@ -35,11 +35,18 @@ import java.util.Collections; ...@@ -35,11 +35,18 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.checkerframework.checker.nullness.compatqual.NullableType; import org.checkerframework.checker.nullness.compatqual.NullableType;
/** /** A fake {@link TrackOutput}. */
* A fake {@link TrackOutput}.
*/
public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable { public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
public static final Factory DEFAULT_FACTORY =
(id, type) -> new FakeTrackOutput(/* deduplicateConsecutiveFormats= */ false);
/** Factory for {@link FakeTrackOutput} instances. */
public interface Factory {
FakeTrackOutput create(int id, int type);
}
private final boolean deduplicateConsecutiveFormats;
private final ArrayList<DumpableSampleInfo> sampleInfos; private final ArrayList<DumpableSampleInfo> sampleInfos;
private final ArrayList<Dumpable> dumpables; private final ArrayList<Dumpable> dumpables;
...@@ -49,7 +56,8 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable { ...@@ -49,7 +56,8 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
@Nullable public Format lastFormat; @Nullable public Format lastFormat;
public FakeTrackOutput() { public FakeTrackOutput(boolean deduplicateConsecutiveFormats) {
this.deduplicateConsecutiveFormats = deduplicateConsecutiveFormats;
sampleInfos = new ArrayList<>(); sampleInfos = new ArrayList<>();
dumpables = new ArrayList<>(); dumpables = new ArrayList<>();
sampleData = Util.EMPTY_BYTE_ARRAY; sampleData = Util.EMPTY_BYTE_ARRAY;
...@@ -67,9 +75,19 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable { ...@@ -67,9 +75,19 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable {
@Override @Override
public void format(Format format) { public void format(Format format) {
Assertions.checkState( if (!deduplicateConsecutiveFormats) {
receivedSampleInFormat, Assertions.checkState(
"TrackOutput must receive at least one sampleMetadata() call between format() calls."); receivedSampleInFormat,
"deduplicateConsecutiveFormats=false so TrackOutput must receive at least one"
+ " sampleMetadata() call between format() calls.");
} else if (!receivedSampleInFormat) {
Dumpable dumpable = dumpables.remove(dumpables.size() - 1);
formatCount--;
Assertions.checkState(
dumpable instanceof DumpableFormat,
"receivedSampleInFormat=false so expected last dumpable to be a DumpableFormat. Found: "
+ dumpable.getClass().getCanonicalName());
}
receivedSampleInFormat = false; receivedSampleInFormat = false;
addFormat(format); addFormat(format);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment