mirror of
https://github.com/androidx/media.git
synced 2025-05-15 19:49:50 +08:00
Delete ExtractorAsserts.assertThrows
This doesn't seem to be used anywhere PiperOrigin-RevId: 306391995
This commit is contained in:
parent
d1e0572448
commit
af81238c92
@ -236,86 +236,6 @@ public final class ExtractorAsserts {
|
|||||||
return extractorOutput;
|
return extractorOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls {@link #assertThrows(Extractor, byte[], Class, boolean, boolean, boolean)} with all
|
|
||||||
* possible combinations of "simulate" parameters.
|
|
||||||
*
|
|
||||||
* @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 context To be used to load the sample file.
|
|
||||||
* @param expectedThrowable Expected {@link Throwable} class.
|
|
||||||
* @throws IOException If reading from the input fails.
|
|
||||||
* @see #assertThrows(Extractor, byte[], Class, boolean, boolean, boolean)
|
|
||||||
*/
|
|
||||||
public static void assertThrows(
|
|
||||||
ExtractorFactory factory,
|
|
||||||
String sampleFile,
|
|
||||||
Context context,
|
|
||||||
Class<? extends Throwable> expectedThrowable)
|
|
||||||
throws IOException {
|
|
||||||
byte[] fileData = TestUtil.getByteArray(context, sampleFile);
|
|
||||||
assertThrows(factory, fileData, expectedThrowable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls {@link #assertThrows(Extractor, byte[], Class, boolean, boolean, boolean)} with all
|
|
||||||
* possible combinations of "simulate" parameters.
|
|
||||||
*
|
|
||||||
* @param factory An {@link ExtractorFactory} which creates instances of the {@link Extractor}
|
|
||||||
* class which is to be tested.
|
|
||||||
* @param fileData Content of the input file.
|
|
||||||
* @param expectedThrowable Expected {@link Throwable} class.
|
|
||||||
* @throws IOException If reading from the input fails.
|
|
||||||
* @see #assertThrows(Extractor, byte[], Class, boolean, boolean, boolean)
|
|
||||||
*/
|
|
||||||
private static void assertThrows(
|
|
||||||
ExtractorFactory factory, byte[] fileData, Class<? extends Throwable> expectedThrowable)
|
|
||||||
throws IOException {
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, false, false, false);
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, true, false, false);
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, false, true, false);
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, true, true, false);
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, false, false, true);
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, true, false, true);
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, false, true, true);
|
|
||||||
assertThrows(factory.create(), fileData, expectedThrowable, true, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asserts {@code extractor} throws {@code expectedThrowable} while consuming {@code fileData}.
|
|
||||||
*
|
|
||||||
* @param extractor The {@link Extractor} to be tested.
|
|
||||||
* @param fileData Content of the input file.
|
|
||||||
* @param expectedThrowable Expected {@link Throwable} class.
|
|
||||||
* @param simulateIOErrors If true simulates IOErrors.
|
|
||||||
* @param simulateUnknownLength If true simulates unknown input length.
|
|
||||||
* @param simulatePartialReads If true simulates partial reads.
|
|
||||||
* @throws IOException If reading from the input fails.
|
|
||||||
*/
|
|
||||||
private static void assertThrows(
|
|
||||||
Extractor extractor,
|
|
||||||
byte[] fileData,
|
|
||||||
Class<? extends Throwable> expectedThrowable,
|
|
||||||
boolean simulateIOErrors,
|
|
||||||
boolean simulateUnknownLength,
|
|
||||||
boolean simulatePartialReads)
|
|
||||||
throws IOException {
|
|
||||||
FakeExtractorInput input = new FakeExtractorInput.Builder().setData(fileData)
|
|
||||||
.setSimulateIOErrors(simulateIOErrors)
|
|
||||||
.setSimulateUnknownLength(simulateUnknownLength)
|
|
||||||
.setSimulatePartialReads(simulatePartialReads).build();
|
|
||||||
try {
|
|
||||||
consumeTestData(extractor, input, 0, true);
|
|
||||||
throw new AssertionError(expectedThrowable.getSimpleName() + " expected but not thrown");
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
if (expectedThrowable.equals(throwable.getClass())) {
|
|
||||||
return; // Pass!
|
|
||||||
}
|
|
||||||
throw throwable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ExtractorAsserts() {}
|
private ExtractorAsserts() {}
|
||||||
|
|
||||||
private static FakeExtractorOutput consumeTestData(
|
private static FakeExtractorOutput consumeTestData(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user