# 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
class ExtractorAsserts
```

<br />

*** ** * ** ***

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

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig` A config for the assertions made (e.g. dump file location). |
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig.Builder` Builder for `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig` instances. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ConfigProvider : 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/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig` objects from `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#configs()` to exercise different extractor paths. |
| `interface https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` A factory for `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` instances. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig` A config of different environments to simulate and extractor behaviours to test. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#PEEK_LIMIT_FAIL_WITH_MAX() = -2` |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#assertBehavior(androidx.media3.test.utils.ExtractorAsserts.ExtractorFactory,java.lang.String,androidx.media3.test.utils.ExtractorAsserts.SimulationConfig)( factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!, file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig! )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/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)( factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!, file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, assertionConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig!, simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig! )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#assertBehavior(androidx.media3.test.utils.ExtractorAsserts.ExtractorFactory,java.lang.String,int,androidx.media3.test.utils.ExtractorAsserts.SimulationConfig)( factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!, file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, peekLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig! )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/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)( factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!, file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, peekLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, assertionConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig!, simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig! )` Asserts that an extractor consumes valid input data successfully under the conditions specified by `simulationConfig`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#assertSniff(androidx.media3.extractor.Extractor,androidx.media3.test.utils.FakeExtractorInput,boolean)( extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!, input: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorInput!, expectedResult: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Asserts that `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` returns the `expectedResult` for a given `input`, retrying repeatedly when `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorInput.SimulatedIOException` is thrown. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#assertSniff(androidx.media3.extractor.Extractor,java.lang.String,int,boolean)( extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!, file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, peekLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, expectedResult: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Asserts that `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)` returns the `expectedResult` for a given `file`, retrying repeatedly when `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorInput.SimulatedIOException` is thrown. |
| `java-static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#configs()()` Returns a list of arrays containing `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.SimulationConfig` objects to exercise different extractor paths. |
| `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!>!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts#configsNoSniffing()()` Returns a list of arrays containing `https://developer.android.com/reference/kotlin/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

```
const val PEEK_LIMIT_FAIL_WITH_MAX = -2: Int
```

## Public functions

### assertBehavior

```
java-static fun assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
): Unit
```

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/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig#dumpFilesPrefix()`.

| Parameters |
|---|---|
| `factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!` | An `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` class which is to be tested. |
| `file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The path to the input sample. |
| `simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.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

```
java-static fun assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    assertionConfig: ExtractorAsserts.AssertionConfig!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
): Unit
```

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 |
|---|---|
| `factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!` | An `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` class which is to be tested. |
| `file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The input file to pass to the extractor. |
| `assertionConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig!` | Details of how to read and process the source and dump files. |
| `simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.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

```
java-static fun assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    peekLimit: Int,
    simulationConfig: ExtractorAsserts.SimulationConfig!
): Unit
```

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/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig#dumpFilesPrefix()`.

| Parameters |
|---|---|
| `factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!` | An `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` class which is to be tested. |
| `file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The path to the input sample. |
| `peekLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit that `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput#getPeekPosition()` is permitted to advance ahead of `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput#getPosition()`. `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` disables enforcement of this limit. `https://developer.android.com/reference/kotlin/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). |
| `simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.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

```
java-static fun assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    peekLimit: Int,
    assertionConfig: ExtractorAsserts.AssertionConfig!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
): Unit
```

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 |
|---|---|
| `factory: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory!` | An `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.ExtractorFactory` which creates instances of the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` class which is to be tested. |
| `file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The input file to pass to the extractor. |
| `peekLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit that `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput#getPeekPosition()` is permitted to advance ahead of `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput#getPosition()`. `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` disables enforcement of this limit. `https://developer.android.com/reference/kotlin/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). |
| `assertionConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.AssertionConfig!` | Details of how to read and process the source and dump files. |
| `simulationConfig: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ExtractorAsserts.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

```
java-static fun assertSniff(
    extractor: Extractor!,
    input: FakeExtractorInput!,
    expectedResult: Boolean
): Unit
```

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

| Parameters |
|---|---|
| `extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!` | The extractor to test. |
| `input: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorInput!` | The extractor input. |
| `expectedResult: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | The expected return value. |

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

### assertSniff

```
java-static fun assertSniff(
    extractor: Extractor!,
    file: String!,
    peekLimit: Int,
    expectedResult: Boolean
): Unit
```

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

| Parameters |
|---|---|
| `extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!` | The extractor to test. |
| `file: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The path to the input sample. |
| `peekLimit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The limit that `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput#getPeekPosition()` is permitted to advance ahead of `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput#getPosition()`. `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` disables enforcement of this limit. `https://developer.android.com/reference/kotlin/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). |
| `expectedResult: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | The expected return value. |

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

### configs

```
java-static fun configs(): ImmutableList<ExtractorAsserts.SimulationConfig!>!
```

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

```
java-static fun configsNoSniffing(): (Mutable)List<Array<Any!>!>!
```

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