Package com.google.android.exoplayer2.testutil

## Class ExtractorAsserts

- java.lang.Object
- - com.google.android.exoplayer2.testutil.ExtractorAsserts

-     public final class ExtractorAsserts
      extends Object

  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<ExtractorAsserts.SimulationConfig> 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<Object[]> 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,
                                         FakeExtractorInput input,
                                         boolean expectedResult)
                                  throws IOException

      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 factory,
                                                String file)
                                         throws IOException

      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 factory,
                                                String file,
                                                String dumpFilesPrefix)
                                         throws IOException

      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 factory,
                                            String file,
                                            ExtractorAsserts.SimulationConfig simulationConfig)
                                     throws IOException

      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 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 by `simulationConfig`.

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

      Parameters:
        `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.