FormatSupportAssumptions


@UnstableApi
public class FormatSupportAssumptions


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
assumeFormatsSupported(
    Context context,
    String testId,
    @Nullable Format inputFormat,
    @Nullable Format outputFormat
)

Assumes that the device supports decoding the input format, and encoding/muxing the output format if needed.

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

Assumes that the device supports decoding the input format, and encoding/muxing the output format if needed.

Public methods

assumeFormatsSupported

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

Assumes that the device supports decoding the input format, and encoding/muxing the output format if needed.

This is equivalent to calling assumeFormatsSupported with isPortraitEncodingEnabled set to false.

assumeFormatsSupported

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

Assumes that the device supports decoding the input format, and encoding/muxing the output format if needed.

Parameters
Context context

The context.

String testId

The test ID.

@Nullable Format inputFormat

The format to decode, or the input is not produced by MediaCodec, like an image.

@Nullable Format outputFormat

The format to encode/mux or null if the output won't be encoded or muxed.

boolean isPortraitEncodingEnabled

Whether portrait encoding is enabled.

Throws
org.junit.AssumptionViolatedException

If the device does not support the formats. In this case, the reason for skipping the test is logged.

java.io.IOException
org.json.JSONException
androidx.media3.exoplayer.mediacodec.MediaCodecUtil.DecoderQueryException