Class ExtractorAsserts
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.ExtractorAsserts
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExtractorAsserts.AssertionConfig
A config for the assertions made (e.g.static interface
ExtractorAsserts.ExtractorFactory
A factory forExtractor
instances.static class
ExtractorAsserts.SimulationConfig
A 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 void
assertAllBehaviors(ExtractorAsserts.ExtractorFactory factory, String file)
Asserts that an extractor behaves correctly given valid input data.static void
assertAllBehaviors(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 void
assertBehavior(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 void
assertBehavior(ExtractorAsserts.ExtractorFactory factory, String file, ExtractorAsserts.SimulationConfig simulationConfig)
Asserts that an extractor consumes valid input data successfully under the conditions specified bysimulationConfig
.static void
assertSniff(Extractor extractor, FakeExtractorInput input, boolean expectedResult)
Asserts thatExtractor.sniff(ExtractorInput)
returns theexpectedResult
for a giveninput
, retrying repeatedly whenFakeExtractorInput.SimulatedIOException
is thrown.static ImmutableList<ExtractorAsserts.SimulationConfig>
configs()
Returns a list of arrays containingExtractorAsserts.SimulationConfig
objects to exercise different extractor paths.static List<Object[]>
configsNoSniffing()
Returns a list of arrays containingExtractorAsserts.SimulationConfig
objects 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.SimulationConfig
objects to exercise different extractor paths.This is intended to be used from tests using
ParameterizedRobolectricTestRunner
ororg.junit.runners.Parameterized
.
-
configsNoSniffing
public static List<Object[]> configsNoSniffing()
Returns a list of arrays containingExtractorAsserts.SimulationConfig
objects to exercise different extractor paths in which the input is not sniffed.This is intended to be used from tests using
ParameterizedRobolectricTestRunner
ororg.junit.runners.Parameterized
.
-
assertSniff
public static void assertSniff(Extractor extractor, FakeExtractorInput input, boolean expectedResult) throws IOException
Asserts thatExtractor.sniff(ExtractorInput)
returns theexpectedResult
for a giveninput
, retrying repeatedly whenFakeExtractorInput.SimulatedIOException
is 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.ExtractorFactory
which creates instances of theExtractor
class 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.ExtractorFactory
which creates instances of theExtractor
class 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
file
parameter as specified in the docs forExtractorAsserts.AssertionConfig.dumpFilesPrefix
.- Parameters:
factory
- AnExtractorAsserts.ExtractorFactory
which creates instances of theExtractor
class 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.ExtractorFactory
which creates instances of theExtractor
class 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.
-
-