Back to Exoplayer

ExtractorAsserts (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/testutil/ExtractorAsserts.html

latest12.6 KB
Original Source

Package com.google.android.exoplayer2.testutil

Class ExtractorAsserts


public final classExtractorAssertsextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")

Assertion methods for Extractor.

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 for Extractor 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: Calls Extractor.seek(long, long) and Extractor.release() without calling Extractor.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 by simulationConfig. | | static void | assertBehavior​(ExtractorAsserts.ExtractorFactory factory, String file, ExtractorAsserts.SimulationConfig simulationConfig) | Asserts that an extractor consumes valid input data successfully under the conditions specified by simulationConfig. | | static void | assertSniff​(Extractor extractor, FakeExtractorInput input, boolean expectedResult) | Asserts that Extractor.sniff(ExtractorInput) returns the expectedResult for a given input, retrying repeatedly when FakeExtractorInput.SimulatedIOException is thrown. | | static ImmutableList<ExtractorAsserts.SimulationConfig> | configs() | Returns a list of arrays containing ExtractorAsserts.SimulationConfig objects to exercise different extractor paths. | | static List<Object[]> | configsNoSniffing() | Returns a list of arrays containing ExtractorAsserts.SimulationConfig objects to exercise different extractor paths in which the input is not sniffed. |

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail

- 

configs

public static[ImmutableList](https://guava.dev/releases/31.1-android/api/docs/com/google/common/collect/ImmutableList.html?is-external=true "class or interface in com.google.common.collect")<[ExtractorAsserts.SimulationConfig](ExtractorAsserts.SimulationConfig.html "class in com.google.android.exoplayer2.testutil")> configs()

Returns a list of arrays containing ExtractorAsserts.SimulationConfig objects to exercise different extractor paths.

This is intended to be used from tests using ParameterizedRobolectricTestRunner or org.junit.runners.Parameterized.

- 

configsNoSniffing

public static[List](https://developer.android.com/reference/java/util/List.html "class or interface in java.util")<[Object](https://developer.android.com/reference/java/lang/Object.html?is-external=true "class or interface in java.lang")[]> configsNoSniffing()

Returns a list of arrays containing ExtractorAsserts.SimulationConfig objects to exercise different extractor paths in which the input is not sniffed.

This is intended to be used from tests using ParameterizedRobolectricTestRunner or org.junit.runners.Parameterized.

- 

assertSniff

public static void assertSniff​([Extractor](../extractor/Extractor.html "interface in com.google.android.exoplayer2.extractor")extractor,[FakeExtractorInput](FakeExtractorInput.html "class in com.google.android.exoplayer2.testutil")input,
                               boolean expectedResult)
                        throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that Extractor.sniff(ExtractorInput) returns the expectedResult for a given input, retrying repeatedly when FakeExtractorInput.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](ExtractorAsserts.ExtractorFactory.html "interface in com.google.android.exoplayer2.testutil")factory,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")file)
                               throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that an extractor behaves correctly given valid input data. - Calls Extractor.seek(long, long) and Extractor.release() without calling Extractor.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 - An ExtractorAsserts.ExtractorFactory which creates instances of the Extractor class which is to be tested.file - The path to the input sample.Throws:IOException - If reading from the input fails.

- 

assertAllBehaviors

public static void assertAllBehaviors​([ExtractorAsserts.ExtractorFactory](ExtractorAsserts.ExtractorFactory.html "interface in com.google.android.exoplayer2.testutil")factory,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")file,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")dumpFilesPrefix)
                               throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that an extractor behaves correctly given valid input data: - Calls Extractor.seek(long, long) and Extractor.release() without calling Extractor.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 - An ExtractorAsserts.ExtractorFactory which creates instances of the Extractor 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.

- 

assertBehavior

public static void assertBehavior​([ExtractorAsserts.ExtractorFactory](ExtractorAsserts.ExtractorFactory.html "interface in com.google.android.exoplayer2.testutil")factory,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")file,[ExtractorAsserts.SimulationConfig](ExtractorAsserts.SimulationConfig.html "class in com.google.android.exoplayer2.testutil")simulationConfig)
                           throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that an extractor consumes valid input data successfully under the conditions specified by simulationConfig.

The output of the extractor is compared against prerecorded dump files whose names are derived from the file parameter as specified in the docs for ExtractorAsserts.AssertionConfig.dumpFilesPrefix.

Parameters:factory - An ExtractorAsserts.ExtractorFactory which creates instances of the Extractor 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](ExtractorAsserts.ExtractorFactory.html "interface in com.google.android.exoplayer2.testutil")factory,[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")file,[ExtractorAsserts.AssertionConfig](ExtractorAsserts.AssertionConfig.html "class in com.google.android.exoplayer2.testutil")assertionConfig,[ExtractorAsserts.SimulationConfig](ExtractorAsserts.SimulationConfig.html "class in com.google.android.exoplayer2.testutil")simulationConfig)
                           throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Asserts that an extractor consumes valid input data successfully successfully under the conditions specified by simulationConfig.

The output of the extractor is compared against prerecorded dump files.

Parameters:factory - An ExtractorAsserts.ExtractorFactory which creates instances of the Extractor 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.