Commit 9dac4007 by ibaker Committed by Ian Baker

Rename ExtractorAsserts "test everything" methods

This makes the distinction more clear between the methods that test
a specific behaviour (and are meant to be used with parameterized
tests) and those that test everything in one go.

Also add a TODO to FlacExtractorTest to migrate it when we can

PiperOrigin-RevId: 308228421
parent 0e6b3181
...@@ -24,6 +24,8 @@ import org.junit.Test; ...@@ -24,6 +24,8 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
/** Unit test for {@link FlacExtractor}. */ /** Unit test for {@link FlacExtractor}. */
// TODO(internal: b/26110951): Use org.junit.runners.Parameterized (and corresponding methods on
// ExtractorAsserts) when it's supported by our testing infrastructure.
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class FlacExtractorTest { public class FlacExtractorTest {
...@@ -36,15 +38,13 @@ public class FlacExtractorTest { ...@@ -36,15 +38,13 @@ public class FlacExtractorTest {
@Test @Test
public void sample() throws Exception { public void sample() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new, /* file= */ "flac/bear.flac", /* dumpFilesPrefix= */ "flac/bear_raw");
/* file= */ "flac/bear.flac",
/* dumpFilesPrefix= */ "flac/bear_raw");
} }
@Test @Test
public void sampleWithId3HeaderAndId3Enabled() throws Exception { public void sampleWithId3HeaderAndId3Enabled() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_with_id3.flac", /* file= */ "flac/bear_with_id3.flac",
/* dumpFilesPrefix= */ "flac/bear_with_id3_enabled_raw"); /* dumpFilesPrefix= */ "flac/bear_with_id3_enabled_raw");
...@@ -52,7 +52,7 @@ public class FlacExtractorTest { ...@@ -52,7 +52,7 @@ public class FlacExtractorTest {
@Test @Test
public void sampleWithId3HeaderAndId3Disabled() throws Exception { public void sampleWithId3HeaderAndId3Disabled() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
() -> new FlacExtractor(FlacExtractor.FLAG_DISABLE_ID3_METADATA), () -> new FlacExtractor(FlacExtractor.FLAG_DISABLE_ID3_METADATA),
/* file= */ "flac/bear_with_id3.flac", /* file= */ "flac/bear_with_id3.flac",
/* dumpFilesPrefix= */ "flac/bear_with_id3_disabled_raw"); /* dumpFilesPrefix= */ "flac/bear_with_id3_disabled_raw");
...@@ -60,7 +60,7 @@ public class FlacExtractorTest { ...@@ -60,7 +60,7 @@ public class FlacExtractorTest {
@Test @Test
public void sampleUnseekable() throws Exception { public void sampleUnseekable() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_no_seek_table_no_num_samples.flac", /* file= */ "flac/bear_no_seek_table_no_num_samples.flac",
/* dumpFilesPrefix= */ "flac/bear_no_seek_table_no_num_samples_raw"); /* dumpFilesPrefix= */ "flac/bear_no_seek_table_no_num_samples_raw");
...@@ -68,7 +68,7 @@ public class FlacExtractorTest { ...@@ -68,7 +68,7 @@ public class FlacExtractorTest {
@Test @Test
public void sampleWithVorbisComments() throws Exception { public void sampleWithVorbisComments() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_with_vorbis_comments.flac", /* file= */ "flac/bear_with_vorbis_comments.flac",
/* dumpFilesPrefix= */ "flac/bear_with_vorbis_comments_raw"); /* dumpFilesPrefix= */ "flac/bear_with_vorbis_comments_raw");
...@@ -76,7 +76,7 @@ public class FlacExtractorTest { ...@@ -76,7 +76,7 @@ public class FlacExtractorTest {
@Test @Test
public void sampleWithPicture() throws Exception { public void sampleWithPicture() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_with_picture.flac", /* file= */ "flac/bear_with_picture.flac",
/* dumpFilesPrefix= */ "flac/bear_with_picture_raw"); /* dumpFilesPrefix= */ "flac/bear_with_picture_raw");
...@@ -84,7 +84,7 @@ public class FlacExtractorTest { ...@@ -84,7 +84,7 @@ public class FlacExtractorTest {
@Test @Test
public void oneMetadataBlock() throws Exception { public void oneMetadataBlock() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_one_metadata_block.flac", /* file= */ "flac/bear_one_metadata_block.flac",
/* dumpFilesPrefix= */ "flac/bear_one_metadata_block_raw"); /* dumpFilesPrefix= */ "flac/bear_one_metadata_block_raw");
...@@ -92,7 +92,7 @@ public class FlacExtractorTest { ...@@ -92,7 +92,7 @@ public class FlacExtractorTest {
@Test @Test
public void noMinMaxFrameSize() throws Exception { public void noMinMaxFrameSize() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_no_min_max_frame_size.flac", /* file= */ "flac/bear_no_min_max_frame_size.flac",
/* dumpFilesPrefix= */ "flac/bear_no_min_max_frame_size_raw"); /* dumpFilesPrefix= */ "flac/bear_no_min_max_frame_size_raw");
...@@ -100,7 +100,7 @@ public class FlacExtractorTest { ...@@ -100,7 +100,7 @@ public class FlacExtractorTest {
@Test @Test
public void noNumSamples() throws Exception { public void noNumSamples() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_no_num_samples.flac", /* file= */ "flac/bear_no_num_samples.flac",
/* dumpFilesPrefix= */ "flac/bear_no_num_samples_raw"); /* dumpFilesPrefix= */ "flac/bear_no_num_samples_raw");
...@@ -108,7 +108,7 @@ public class FlacExtractorTest { ...@@ -108,7 +108,7 @@ public class FlacExtractorTest {
@Test @Test
public void uncommonSampleRate() throws Exception { public void uncommonSampleRate() throws Exception {
ExtractorAsserts.assertBehavior( ExtractorAsserts.assertAllBehaviors(
FlacExtractor::new, FlacExtractor::new,
/* file= */ "flac/bear_uncommon_sample_rate.flac", /* file= */ "flac/bear_uncommon_sample_rate.flac",
/* dumpFilesPrefix= */ "flac/bear_uncommon_sample_rate_raw"); /* dumpFilesPrefix= */ "flac/bear_uncommon_sample_rate_raw");
......
...@@ -135,8 +135,8 @@ public final class ExtractorAsserts { ...@@ -135,8 +135,8 @@ public final class ExtractorAsserts {
* @param file The path to the input sample. * @param file The path to the input sample.
* @throws IOException If reading from the input fails. * @throws IOException If reading from the input fails.
*/ */
public static void assertBehavior(ExtractorFactory factory, String file) throws IOException { public static void assertAllBehaviors(ExtractorFactory factory, String file) throws IOException {
assertBehavior(factory, file, file); assertAllBehaviors(factory, file, file);
} }
/** /**
...@@ -155,8 +155,8 @@ public final class ExtractorAsserts { ...@@ -155,8 +155,8 @@ public final class ExtractorAsserts {
* @param dumpFilesPrefix The dump files prefix appended to the dump files path. * @param dumpFilesPrefix The dump files prefix appended to the dump files path.
* @throws IOException If reading from the input fails. * @throws IOException If reading from the input fails.
*/ */
public static void assertBehavior(ExtractorFactory factory, String file, String dumpFilesPrefix) public static void assertAllBehaviors(
throws IOException { ExtractorFactory factory, String file, String dumpFilesPrefix) throws IOException {
// Check behavior prior to initialization. // Check behavior prior to initialization.
Extractor extractor = factory.create(); Extractor extractor = factory.create();
extractor.seek(0, 0); extractor.seek(0, 0);
......
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