mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Simulate IO exceptions in all FlacExtractor tests
- Simulate IO exceptions in the test using FlacBinarySearchSeeker for seeking in FlacExtractorTests. This makes the test slower but covers more test cases. PiperOrigin-RevId: 288285057
This commit is contained in:
parent
3a31bc1724
commit
06fcf29edd
1 changed files with 1 additions and 65 deletions
|
|
@ -15,13 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.extractor.flac;
|
package com.google.android.exoplayer2.extractor.flac;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import androidx.test.core.app.ApplicationProvider;
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
|
||||||
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
||||||
import com.google.android.exoplayer2.testutil.TestUtil;
|
|
||||||
import java.io.IOException;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
|
@ -66,9 +61,7 @@ public class FlacExtractorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOneMetadataBlock() throws Exception {
|
public void testOneMetadataBlock() throws Exception {
|
||||||
// Don't simulate IO errors as it is too slow when using the binary search seek map (see
|
ExtractorAsserts.assertBehavior(FlacExtractor::new, "flac/bear_one_metadata_block.flac");
|
||||||
// [Internal: b/145994869]).
|
|
||||||
assertBehaviorWithoutSimulatingIOErrors("flac/bear_one_metadata_block.flac");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -85,61 +78,4 @@ public class FlacExtractorTest {
|
||||||
public void testUncommonSampleRate() throws Exception {
|
public void testUncommonSampleRate() throws Exception {
|
||||||
ExtractorAsserts.assertBehavior(FlacExtractor::new, "flac/bear_uncommon_sample_rate.flac");
|
ExtractorAsserts.assertBehavior(FlacExtractor::new, "flac/bear_uncommon_sample_rate.flac");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void assertBehaviorWithoutSimulatingIOErrors(String file)
|
|
||||||
throws IOException, InterruptedException {
|
|
||||||
// Check behavior prior to initialization.
|
|
||||||
Extractor extractor = new FlacExtractor();
|
|
||||||
extractor.seek(0, 0);
|
|
||||||
extractor.release();
|
|
||||||
|
|
||||||
// Assert output.
|
|
||||||
Context context = ApplicationProvider.getApplicationContext();
|
|
||||||
byte[] data = TestUtil.getByteArray(context, file);
|
|
||||||
ExtractorAsserts.assertOutput(
|
|
||||||
new FlacExtractor(),
|
|
||||||
file,
|
|
||||||
data,
|
|
||||||
context,
|
|
||||||
/* sniffFirst= */ true,
|
|
||||||
/* simulateIOErrors= */ false,
|
|
||||||
/* simulateUnknownLength= */ false,
|
|
||||||
/* simulatePartialReads= */ false);
|
|
||||||
ExtractorAsserts.assertOutput(
|
|
||||||
new FlacExtractor(),
|
|
||||||
file,
|
|
||||||
data,
|
|
||||||
context,
|
|
||||||
/* sniffFirst= */ true,
|
|
||||||
/* simulateIOErrors= */ false,
|
|
||||||
/* simulateUnknownLength= */ false,
|
|
||||||
/* simulatePartialReads= */ true);
|
|
||||||
ExtractorAsserts.assertOutput(
|
|
||||||
new FlacExtractor(),
|
|
||||||
file,
|
|
||||||
data,
|
|
||||||
context,
|
|
||||||
/* sniffFirst= */ true,
|
|
||||||
/* simulateIOErrors= */ false,
|
|
||||||
/* simulateUnknownLength= */ true,
|
|
||||||
/* simulatePartialReads= */ false);
|
|
||||||
ExtractorAsserts.assertOutput(
|
|
||||||
new FlacExtractor(),
|
|
||||||
file,
|
|
||||||
data,
|
|
||||||
context,
|
|
||||||
/* sniffFirst= */ true,
|
|
||||||
/* simulateIOErrors= */ false,
|
|
||||||
/* simulateUnknownLength= */ true,
|
|
||||||
/* simulatePartialReads= */ true);
|
|
||||||
ExtractorAsserts.assertOutput(
|
|
||||||
new FlacExtractor(),
|
|
||||||
file,
|
|
||||||
data,
|
|
||||||
context,
|
|
||||||
/* sniffFirst= */ false,
|
|
||||||
/* simulateIOErrors= */ false,
|
|
||||||
/* simulateUnknownLength= */ false,
|
|
||||||
/* simulatePartialReads= */ false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue