Class ExtractorAsserts
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.ExtractorAsserts
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExtractorAsserts.AssertionConfigA config for the assertions made (e.g.static interfaceExtractorAsserts.ExtractorFactoryA factory forExtractorinstances.static classExtractorAsserts.SimulationConfigA config of different environments to simulate and extractor behaviours to test.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertAllBehaviors(ExtractorAsserts.ExtractorFactory factory, String file)Asserts that an extractor behaves correctly given valid input data.static voidassertAllBehaviors(ExtractorAsserts.ExtractorFactory factory, String file, String dumpFilesPrefix)Asserts that an extractor behaves correctly given valid input data: CallsExtractor.seek(long, long)andExtractor.release()without callingExtractor.init(ExtractorOutput)to check these calls do not fail.static voidassertBehavior(ExtractorAsserts.ExtractorFactory factory, String file, ExtractorAsserts.AssertionConfig assertionConfig, ExtractorAsserts.SimulationConfig simulationConfig)Asserts that an extractor consumes valid input data successfully successfully under the conditions specified bysimulationConfig.static voidassertBehavior(ExtractorAsserts.ExtractorFactory factory, String file, ExtractorAsserts.SimulationConfig simulationConfig)Asserts that an extractor consumes valid input data successfully under the conditions specified bysimulationConfig.static voidassertSniff(Extractor extractor, FakeExtractorInput input, boolean expectedResult)Asserts thatExtractor.sniff(ExtractorInput)returns theexpectedResultfor a giveninput, retrying repeatedly whenFakeExtractorInput.SimulatedIOExceptionis thrown.static ImmutableList<ExtractorAsserts.SimulationConfig>configs()Returns a list of arrays containingExtractorAsserts.SimulationConfigobjects to exercise different extractor paths.static List<Object[]>configsNoSniffing()Returns a list of arrays containingExtractorAsserts.SimulationConfigobjects to exercise different extractor paths in which the input is not sniffed.
-
-
-
Method Detail
-
configs
public static ImmutableList<ExtractorAsserts.SimulationConfig> configs()
Returns a list of arrays containingExtractorAsserts.SimulationConfigobjects to exercise different extractor paths.This is intended to be used from tests using
ParameterizedRobolectricTestRunnerororg.junit.runners.Parameterized.
-
configsNoSniffing
public static List<Object[]> configsNoSniffing()
Returns a list of arrays containingExtractorAsserts.SimulationConfigobjects to exercise different extractor paths in which the input is not sniffed.This is intended to be used from tests using
ParameterizedRobolectricTestRunnerororg.junit.runners.Parameterized.
-
assertSniff
public static void assertSniff(Extractor extractor, FakeExtractorInput input, boolean expectedResult) throws IOException
Asserts thatExtractor.sniff(ExtractorInput)returns theexpectedResultfor a giveninput, retrying repeatedly whenFakeExtractorInput.SimulatedIOExceptionis thrown.- Parameters:
extractor- The extractor to test.input- The extractor input.expectedResult- The expected return value.- Throws:
IOException- If reading from the input fails.
-
assertAllBehaviors
public static void assertAllBehaviors(ExtractorAsserts.ExtractorFactory factory, String file) throws IOException
Asserts that an extractor behaves correctly given valid input data.- Calls
Extractor.seek(long, long)andExtractor.release()without callingExtractor.init(ExtractorOutput)to check these calls do not fail. - Calls
assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean, boolean, boolean)with all possible combinations of "simulate" parameters.
- Parameters:
factory- AnExtractorAsserts.ExtractorFactorywhich creates instances of theExtractorclass which is to be tested.file- The path to the input sample.- Throws:
IOException- If reading from the input fails.
- Calls
-
assertAllBehaviors
public static void assertAllBehaviors(ExtractorAsserts.ExtractorFactory factory, String file, String dumpFilesPrefix) throws IOException
Asserts that an extractor behaves correctly given valid input data:- Calls
Extractor.seek(long, long)andExtractor.release()without callingExtractor.init(ExtractorOutput)to check these calls do not fail. - Calls
assertOutput(Extractor, String, byte[], Context, boolean, boolean, boolean, boolean, boolean)with all possible combinations of "simulate" parameters.
- Parameters:
factory- AnExtractorAsserts.ExtractorFactorywhich creates instances of theExtractorclass which is to be tested.file- The path to the input sample.dumpFilesPrefix- The dump files prefix appended to the dump files path.- Throws:
IOException- If reading from the input fails.
- Calls
-
assertBehavior
public static void assertBehavior(ExtractorAsserts.ExtractorFactory factory, String file, ExtractorAsserts.SimulationConfig simulationConfig) throws IOException
Asserts that an extractor consumes valid input data successfully under the conditions specified bysimulationConfig.The output of the extractor is compared against prerecorded dump files whose names are derived from the
fileparameter as specified in the docs forExtractorAsserts.AssertionConfig.dumpFilesPrefix.- Parameters:
factory- AnExtractorAsserts.ExtractorFactorywhich creates instances of theExtractorclass which is to be tested.file- The path to the input sample.simulationConfig- Details on the environment to simulate and behaviours to assert.- Throws:
IOException- If reading from the input fails.
-
assertBehavior
public static void assertBehavior(ExtractorAsserts.ExtractorFactory factory, String file, ExtractorAsserts.AssertionConfig assertionConfig, ExtractorAsserts.SimulationConfig simulationConfig) throws IOException
Asserts that an extractor consumes valid input data successfully successfully under the conditions specified bysimulationConfig.The output of the extractor is compared against prerecorded dump files.
- Parameters:
factory- AnExtractorAsserts.ExtractorFactorywhich creates instances of theExtractorclass which is to be tested.file- The input file to pass to the extractor.assertionConfig- Details of how to read and process the source and dump files.simulationConfig- Details on the environment to simulate and behaviours to assert.- Throws:
IOException- If reading from the input fails.
-
-