Switch playback tests to single-parameter parameterized syntax

This is simpler than instantiating a single-element string array for
every parameter.

PiperOrigin-RevId: 338469324
This commit is contained in:
ibaker 2020-10-22 15:38:06 +01:00 committed by Oliver Woodman
parent 09b4a473ff
commit 18c6b16f91
4 changed files with 59 additions and 56 deletions

View File

@ -42,17 +42,17 @@ import org.robolectric.annotation.Config;
public class FlacPlaybackTest { public class FlacPlaybackTest {
@Parameters(name = "{0}") @Parameters(name = "{0}")
public static ImmutableList<String[]> params() { public static ImmutableList<String> mediaSamples() {
return ImmutableList.of( return ImmutableList.of(
new String[] {"bear.flac"}, "bear.flac",
new String[] {"bear_no_min_max_frame_size.flac"}, "bear_no_min_max_frame_size.flac",
new String[] {"bear_no_num_samples.flac"}, "bear_no_num_samples.flac",
new String[] {"bear_no_seek_table_no_num_samples.flac"}, "bear_no_seek_table_no_num_samples.flac",
new String[] {"bear_one_metadata_block.flac"}, "bear_one_metadata_block.flac",
new String[] {"bear_uncommon_sample_rate.flac"}, "bear_uncommon_sample_rate.flac",
new String[] {"bear_with_id3.flac"}, "bear_with_id3.flac",
new String[] {"bear_with_picture.flac"}, "bear_with_picture.flac",
new String[] {"bear_with_vorbis_comments.flac"}); "bear_with_vorbis_comments.flac");
} }
@Parameter public String inputFile; @Parameter public String inputFile;

View File

@ -32,6 +32,7 @@ import org.junit.Rule;
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;
import org.robolectric.ParameterizedRobolectricTestRunner.Parameters;
import org.robolectric.annotation.Config; import org.robolectric.annotation.Config;
/** End-to-end tests using MP3 samples. */ /** End-to-end tests using MP3 samples. */
@ -39,16 +40,16 @@ import org.robolectric.annotation.Config;
@Config(sdk = 29) @Config(sdk = 29)
@RunWith(ParameterizedRobolectricTestRunner.class) @RunWith(ParameterizedRobolectricTestRunner.class)
public final class Mp3PlaybackTest { public final class Mp3PlaybackTest {
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}") @Parameters(name = "{0}")
public static ImmutableList<String[]> params() { public static ImmutableList<String> mediaSamples() {
return ImmutableList.of( return ImmutableList.of(
new String[] {"bear-cbr-constant-frame-size-no-seek-table.mp3"}, "bear-cbr-constant-frame-size-no-seek-table.mp3",
new String[] {"bear-cbr-variable-frame-size-no-seek-table.mp3"}, "bear-cbr-variable-frame-size-no-seek-table.mp3",
new String[] {"bear-id3.mp3"}, "bear-id3.mp3",
new String[] {"bear-vbr-no-seek-table.mp3"}, "bear-vbr-no-seek-table.mp3",
new String[] {"bear-vbr-xing-header.mp3"}, "bear-vbr-xing-header.mp3",
new String[] {"play-trimmed.mp3"}, "play-trimmed.mp3",
new String[] {"test.mp3"}); "test.mp3");
} }
@ParameterizedRobolectricTestRunner.Parameter public String inputFile; @ParameterizedRobolectricTestRunner.Parameter public String inputFile;

View File

@ -32,6 +32,8 @@ import org.junit.Rule;
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;
import org.robolectric.ParameterizedRobolectricTestRunner.Parameter;
import org.robolectric.ParameterizedRobolectricTestRunner.Parameters;
import org.robolectric.annotation.Config; import org.robolectric.annotation.Config;
/** End-to-end tests using MP4 samples. */ /** End-to-end tests using MP4 samples. */
@ -43,27 +45,27 @@ public class Mp4PlaybackTest {
// TODO: Add samples with >2 audio channels when supported (sample_ac3_fragmented.mp4, // TODO: Add samples with >2 audio channels when supported (sample_ac3_fragmented.mp4,
// sample_ac3.mp4sample_eac3.mp4, sample_eac3_fragmented.mp4, sample_eac3joc.mp4, // sample_ac3.mp4sample_eac3.mp4, sample_eac3_fragmented.mp4, sample_eac3joc.mp4,
// sample_eac3joc_fragmented.mp4). // sample_eac3joc_fragmented.mp4).
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}") @Parameters(name = "{0}")
public static ImmutableList<String[]> params() { public static ImmutableList<String> mediaSamples() {
return ImmutableList.of( return ImmutableList.of(
new String[] {"midroll-5s.mp4"}, "midroll-5s.mp4",
new String[] {"postroll-5s.mp4"}, "postroll-5s.mp4",
new String[] {"preroll-5s.mp4"}, "preroll-5s.mp4",
new String[] {"sample_ac4_fragmented.mp4"}, "sample_ac4_fragmented.mp4",
new String[] {"sample_ac4.mp4"}, "sample_ac4.mp4",
new String[] {"sample_android_slow_motion.mp4"}, "sample_android_slow_motion.mp4",
new String[] {"sample_fragmented.mp4"}, "sample_fragmented.mp4",
new String[] {"sample_fragmented_seekable.mp4"}, "sample_fragmented_seekable.mp4",
new String[] {"sample_fragmented_sei.mp4"}, "sample_fragmented_sei.mp4",
new String[] {"sample_mdat_too_long.mp4"}, "sample_mdat_too_long.mp4",
new String[] {"sample.mp4"}, "sample.mp4",
new String[] {"sample_opus_fragmented.mp4"}, "sample_opus_fragmented.mp4",
new String[] {"sample_opus.mp4"}, "sample_opus.mp4",
new String[] {"sample_partially_fragmented.mp4"}, "sample_partially_fragmented.mp4",
new String[] {"testvid_1022ms.mp4"}); "testvid_1022ms.mp4");
} }
@ParameterizedRobolectricTestRunner.Parameter public String inputFile; @Parameter public String inputFile;
@Rule @Rule
public ShadowMediaCodecConfig mediaCodecConfig = public ShadowMediaCodecConfig mediaCodecConfig =

View File

@ -44,26 +44,26 @@ public class TsPlaybackTest {
// TODO: Add samples with >2 audio channels when supported (sample.ac3, sample_ac3.ts, // TODO: Add samples with >2 audio channels when supported (sample.ac3, sample_ac3.ts,
// sample.eac3, sample_eac3joc.ec3, sample_eac3joc.ts, sample_eac3.ts). // sample.eac3, sample_eac3joc.ec3, sample_eac3joc.ts, sample_eac3.ts).
@Parameters(name = "{0}") @Parameters(name = "{0}")
public static ImmutableList<String[]> params() { public static ImmutableList<String> mediaSamples() {
return ImmutableList.of( return ImmutableList.of(
new String[] {"bbb_2500ms.ts"}, "bbb_2500ms.ts",
new String[] {"elephants_dream.mpg"}, "elephants_dream.mpg",
new String[] {"sample.ac4"}, "sample.ac4",
new String[] {"sample_ac4.ts"}, "sample_ac4.ts",
new String[] {"sample.adts"}, "sample.adts",
new String[] {"sample_ait.ts"}, "sample_ait.ts",
new String[] {"sample_cbs_truncated.adts"}, "sample_cbs_truncated.adts",
new String[] {"sample_h262_mpeg_audio.ps"}, "sample_h262_mpeg_audio.ps",
new String[] {"sample_h262_mpeg_audio.ts"}, "sample_h262_mpeg_audio.ts",
new String[] {"sample_h263.ts"}, "sample_h263.ts",
new String[] {"sample_h264_dts_audio.ts"}, "sample_h264_dts_audio.ts",
new String[] {"sample_h264_mpeg_audio.ts"}, "sample_h264_mpeg_audio.ts",
new String[] {"sample_h264_no_access_unit_delimiters.ts"}, "sample_h264_no_access_unit_delimiters.ts",
new String[] {"sample_h265.ts"}, "sample_h265.ts",
new String[] {"sample_latm.ts"}, "sample_latm.ts",
new String[] {"sample_scte35.ts"}, "sample_scte35.ts",
new String[] {"sample_with_id3.adts"}, "sample_with_id3.adts",
new String[] {"sample_with_junk"}); "sample_with_junk");
} }
@Parameter public String inputFile; @Parameter public String inputFile;