# FormatSupportAssumptions

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/FormatSupportAssumptions.java+class:androidx.media3.test.utils.FormatSupportAssumptions)

*** ** * ** ***


```
@UnstableApi
public class FormatSupportAssumptions
```

<br />

*** ** * ** ***

Utility methods for checking and assuming format support in instrumentation tests.

These methods are used to skip tests based on device capabilities for decoding and encoding specific media formats.

## Summary

| ### Public methods |
|---|---|
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/FormatSupportAssumptions#assumeAllFormatsSupported(android.content.Context,java.lang.String,java.util.List<androidx.media3.common.Format>,androidx.media3.common.Format)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html testId, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> inputFormats, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format outputFormat )` `https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` that the device supports decoding the input formats, and encoding/muxing the output format if needed. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/FormatSupportAssumptions#assumeFormatsSupported(android.content.Context,java.lang.String,androidx.media3.common.Format,androidx.media3.common.Format)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html testId, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format inputFormat, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format outputFormat )` `https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` that the device supports decoding the input format, and encoding/muxing the output format if needed. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/FormatSupportAssumptions#assumeFormatsSupported(android.content.Context,java.lang.String,androidx.media3.common.Format,androidx.media3.common.Format,boolean)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html testId, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format inputFormat, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format outputFormat, boolean isPortraitEncodingEnabled )` `https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` that the device supports decoding the input format, and encoding/muxing the output format if needed. |

## Public methods

### assumeAllFormatsSupported

```
public static void assumeAllFormatsSupported(
    Context context,
    String testId,
    List<Format> inputFormats,
    @Nullable Format outputFormat
)
```

`https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` that the device supports decoding the input formats, and encoding/muxing the output format if needed.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `https://developer.android.com/reference/java/lang/String.html testId` | The test ID. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> inputFormats` | The `https://developer.android.com/reference/androidx/media3/common/Format` to decode. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format outputFormat` | The `https://developer.android.com/reference/androidx/media3/common/Format` to encode/mux or `null` if the output won't be encoded or muxed. |

| Throws |
|---|---|
| `https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` | If the device does not support the formats. In this case, the reason for skipping the test is logged. |
| `https://developer.android.com/reference/java/io/IOException.html` |   |
| `https://developer.android.com/reference/org/json/JSONException.html` |   |
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` |   |

### assumeFormatsSupported

```
public static void assumeFormatsSupported(
    Context context,
    String testId,
    @Nullable Format inputFormat,
    @Nullable Format outputFormat
)
```

`https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` that the device supports decoding the input format, and encoding/muxing the output format if needed.

This is equivalent to calling `https://developer.android.com/reference/androidx/media3/test/utils/FormatSupportAssumptions#assumeFormatsSupported(android.content.Context,java.lang.String,androidx.media3.common.Format,androidx.media3.common.Format,boolean)` with `isPortraitEncodingEnabled` set to `false`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |
| `https://developer.android.com/reference/org/json/JSONException.html` |   |
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` |   |

### assumeFormatsSupported

```
public static void assumeFormatsSupported(
    Context context,
    String testId,
    @Nullable Format inputFormat,
    @Nullable Format outputFormat,
    boolean isPortraitEncodingEnabled
)
```

`https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` that the device supports decoding the input format, and encoding/muxing the output format if needed.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `https://developer.android.com/reference/java/lang/String.html testId` | The test ID. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format inputFormat` | The `https://developer.android.com/reference/androidx/media3/common/Format` to decode, or the input is not produced by MediaCodec, like an image. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format outputFormat` | The `https://developer.android.com/reference/androidx/media3/common/Format` to encode/mux or `null` if the output won't be encoded or muxed. |
| `boolean isPortraitEncodingEnabled` | Whether portrait encoding is enabled. |

| Throws |
|---|---|
| `https://junit.org/junit4/javadoc/latest/org/junit/AssumptionViolatedException.html` | If the device does not support the formats. In this case, the reason for skipping the test is logged. |
| `https://developer.android.com/reference/java/io/IOException.html` |   |
| `https://developer.android.com/reference/org/json/JSONException.html` |   |
| `https://developer.android.com/reference/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.DecoderQueryException` |   |