# ExtractorAsserts

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/ExtractorAsserts.java+class:androidx.media3.test.utils.ExtractorAsserts)

*** ** * ** ***


```
@UnstableApi
public final class ExtractorAsserts
```

<br />

*** ** * ** ***

Assertion methods for `https://developer.android.com/reference/androidx/media3/extractor/Extractor`.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig` A config for the assertions made (e.g. dump file location). |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig.Builder` Builder for `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig` instances. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ConfigProvider extends https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.html` A `https://google.github.io/TestParameterInjector/docs/latest/com/google/testing/junit/testparameterinjector/TestParameterValuesProvider.html` that provides `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig` objects from `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#configs()` to exercise different extractor paths. |
| `public interface https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` A factory for `https://developer.android.com/reference/androidx/media3/extractor/Extractor` instances. |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig` A config of different environments to simulate and extractor behaviours to test. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#PEEK_LIMIT_FAIL_WITH_MAX() = -2` |

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#assertBehavior(androidx.media3.test.utils.ExtractorAsserts.ExtractorFactory,java.lang.String,androidx.media3.test.utils.ExtractorAsserts.SimulationConfig)( https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory, https://developer.android.com/reference/java/lang/String.html file, https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#assertBehavior(androidx.media3.test.utils.ExtractorAsserts.ExtractorFactory,java.lang.String,androidx.media3.test.utils.ExtractorAsserts.AssertionConfig,androidx.media3.test.utils.ExtractorAsserts.SimulationConfig)( https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory, https://developer.android.com/reference/java/lang/String.html file, https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig assertionConfig, https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#assertBehavior(androidx.media3.test.utils.ExtractorAsserts.ExtractorFactory,java.lang.String,int,androidx.media3.test.utils.ExtractorAsserts.SimulationConfig)( https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory, https://developer.android.com/reference/java/lang/String.html file, int peekLimit, https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#assertBehavior(androidx.media3.test.utils.ExtractorAsserts.ExtractorFactory,java.lang.String,int,androidx.media3.test.utils.ExtractorAsserts.AssertionConfig,androidx.media3.test.utils.ExtractorAsserts.SimulationConfig)( https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory, https://developer.android.com/reference/java/lang/String.html file, int peekLimit, https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig assertionConfig, https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#assertSniff(androidx.media3.extractor.Extractor,androidx.media3.test.utils.FakeExtractorInput,boolean)( https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor, https://developer.android.com/reference/androidx/media3/test/utils/FakeExtractorInput input, boolean expectedResult )` Asserts that `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` returns the `expectedResult` for a given `input`, retrying repeatedly when `https://developer.android.com/reference/androidx/media3/test/utils/FakeExtractorInput.SimulatedIOException` is thrown. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#assertSniff(androidx.media3.extractor.Extractor,java.lang.String,int,boolean)( https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor, https://developer.android.com/reference/java/lang/String.html file, int peekLimit, boolean expectedResult )` Asserts that `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` returns the `expectedResult` for a given `file`, retrying repeatedly when `https://developer.android.com/reference/androidx/media3/test/utils/FakeExtractorInput.SimulatedIOException` is thrown. |
| `static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig>` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#configs()()` Returns a list of arrays containing `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig` objects to exercise different extractor paths. |
| `static https://developer.android.com/reference/java/util/List.html<Object[]>` | `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#configsNoSniffing()()` Returns a list of arrays containing `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig` objects to exercise different extractor paths in which the input is not sniffed. |

## Constants

### PEEK_LIMIT_FAIL_WITH_MAX

```
public static final int PEEK_LIMIT_FAIL_WITH_MAX = -2
```

## Public methods

### assertBehavior

```
public 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`.

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 `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig#dumpFilesPrefix()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory` | An `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` class which is to be tested. |
| `https://developer.android.com/reference/java/lang/String.html file` | The path to the input sample. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig` | Details on the environment to simulate and behaviours to assert. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. |

### assertBehavior

```
public static void assertBehavior(
    ExtractorAsserts.ExtractorFactory factory,
    String file,
    ExtractorAsserts.AssertionConfig assertionConfig,
    ExtractorAsserts.SimulationConfig simulationConfig
)
```

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.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory` | An `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` class which is to be tested. |
| `https://developer.android.com/reference/java/lang/String.html file` | The input file to pass to the extractor. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig assertionConfig` | Details of how to read and process the source and dump files. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig` | Details on the environment to simulate and behaviours to assert. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. |

### assertBehavior

```
public static void assertBehavior(
    ExtractorAsserts.ExtractorFactory factory,
    String file,
    int peekLimit,
    ExtractorAsserts.SimulationConfig simulationConfig
)
```

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 `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig#dumpFilesPrefix()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory` | An `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` class which is to be tested. |
| `https://developer.android.com/reference/java/lang/String.html file` | The path to the input sample. |
| `int peekLimit` | The limit that `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#getPeekPosition()` is permitted to advance ahead of `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#getPosition()`. `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` disables enforcement of this limit. `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#PEEK_LIMIT_FAIL_WITH_MAX()` forces the test to fail at the end and print the max limit that was used (which can be helpful when setting this value). |
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig` | Details on the environment to simulate and behaviours to assert. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. |

### assertBehavior

```
public static void assertBehavior(
    ExtractorAsserts.ExtractorFactory factory,
    String file,
    int peekLimit,
    ExtractorAsserts.AssertionConfig assertionConfig,
    ExtractorAsserts.SimulationConfig simulationConfig
)
```

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.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory factory` | An `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` class which is to be tested. |
| `https://developer.android.com/reference/java/lang/String.html file` | The input file to pass to the extractor. |
| `int peekLimit` | The limit that `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#getPeekPosition()` is permitted to advance ahead of `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#getPosition()`. `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` disables enforcement of this limit. `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#PEEK_LIMIT_FAIL_WITH_MAX()` forces the test to fail at the end and print the max limit that was used (which can be helpful when setting this value). |
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig assertionConfig` | Details of how to read and process the source and dump files. |
| `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig simulationConfig` | Details on the environment to simulate and behaviours to assert. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. |

### assertSniff

```
public static void assertSniff(
    Extractor extractor,
    FakeExtractorInput input,
    boolean expectedResult
)
```

Asserts that `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` returns the `expectedResult` for a given `input`, retrying repeatedly when `https://developer.android.com/reference/androidx/media3/test/utils/FakeExtractorInput.SimulatedIOException` is thrown.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor` | The extractor to test. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeExtractorInput input` | The extractor input. |
| `boolean expectedResult` | The expected return value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. |

### assertSniff

```
public static void assertSniff(
    Extractor extractor,
    String file,
    int peekLimit,
    boolean expectedResult
)
```

Asserts that `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` returns the `expectedResult` for a given `file`, retrying repeatedly when `https://developer.android.com/reference/androidx/media3/test/utils/FakeExtractorInput.SimulatedIOException` is thrown.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor` | The extractor to test. |
| `https://developer.android.com/reference/java/lang/String.html file` | The path to the input sample. |
| `int peekLimit` | The limit that `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#getPeekPosition()` is permitted to advance ahead of `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#getPosition()`. `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` disables enforcement of this limit. `https://developer.android.com/reference/androidx/media3/test/utils/ExtractorAsserts#PEEK_LIMIT_FAIL_WITH_MAX()` forces the test to fail at the end and print the max limit that was used (which can be helpful when setting this value). |
| `boolean expectedResult` | The expected return value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If reading from the input fails. |

### configs

```
public static ImmutableList<ExtractorAsserts.SimulationConfig> configs()
```

Returns a list of arrays containing `https://developer.android.com/reference/androidx/media3/test/utils/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 `https://developer.android.com/reference/androidx/media3/test/utils/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`.