# TestUtil

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

*** ** * ** ***


```
@UnstableApi
class TestUtil
```

<br />

*** ** * ** ***

Utility methods for tests.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#PSNR_THRESHOLD() = 35.0f` Luma PSNR values between 30 and 50 are considered good for lossy compression (See [Quality estimation with PSNR](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio#Quality_estimation_with_PSNR) ). |

| ### 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/TestUtil#assertBitmapsAreSimilar(android.graphics.Bitmap,android.graphics.Bitmap,double)( expectedBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!, actualBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!, psnrThresholdDb: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html )` Asserts whether actual bitmap is very similar to the expected bitmap at some quality level. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertBufferInfosEqual(android.media.MediaCodec.BufferInfo,android.media.MediaCodec.BufferInfo)( expected: https://developer.android.com/reference/android/media/MediaCodec.BufferInfo.html!, actual: https://developer.android.com/reference/android/media/MediaCodec.BufferInfo.html! )` Returns whether two `https://developer.android.com/reference/android/media/MediaCodec.BufferInfo.html` are equal. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertDataSourceContent(androidx.media3.datasource.DataSource,androidx.media3.datasource.DataSpec,byte[],boolean)( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!, expectedData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, expectKnownLength: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Asserts that data read from a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` matches `expected`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, F : T?> https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertForwardingClassForwardsAllMethods(java.lang.Class<T>,com.google.common.base.Function<T,F>)( superType: https://developer.android.com/reference/java/lang/Class.html<T!>!, forwardingInstanceFactory: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Function.html<T!, F!>! )` Use reflection to assert that calling every non-final method declared on `superType` on an instance of `forwardingType` results in the call being forwarded to the ` superType` delegate. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, F : T?> https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertForwardingClassForwardsAllMethodsExcept(java.lang.Class<T>,com.google.common.base.Function<T,F>,java.util.Set<java.lang.String>)( superType: https://developer.android.com/reference/java/lang/Class.html<T!>!, forwardingInstanceFactory: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Function.html<T!, F!>!, excludedMethods: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>! )` Use reflection to assert that calling every non-final, non-excluded method declared on ` superType` on an instance of `forwardingType` results in the call being forwarded to the `superType` delegate. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 29) https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertFp16BitmapsAreSimilar(android.graphics.Bitmap,android.graphics.Bitmap,double)( expectedBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!, actualBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!, psnrThresholdDb: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html )` Asserts whether actual FP16 bitmap is very similar to the expected FP16 bitmap at some quality level. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T> https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertSubclassOverridesAllMethods(java.lang.Class<T>,java.lang.Class<? extends T>)( superType: https://developer.android.com/reference/java/lang/Class.html<T!>!, subType: https://developer.android.com/reference/java/lang/Class.html<T!>! )` Use reflection to assert that every non-final method declared on `superType` is overridden by `subType`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `<T> https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertSubclassOverridesAllMethodsExcept(java.lang.Class<T>,java.lang.Class<? extends T>,java.util.Set<java.lang.String>)( superType: https://developer.android.com/reference/java/lang/Class.html<T!>!, subType: https://developer.android.com/reference/java/lang/Class.html<T!>!, excludedMethods: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>! )` Use reflection to assert that every non-final, non-excluded method declared on ` superType` is overridden by `subType`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#assertTimelinesSame(java.util.List<androidx.media3.common.Timeline>,java.util.List<androidx.media3.common.Timeline>)( actualTimelines: (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://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!>!, expectedTimelines: (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://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!>! )` Asserts that the actual timelines are the same to the expected timelines. |
| `java-static https://developer.android.com/reference/android/net/Uri.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildAssetUri(java.lang.String)(assetPath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the `https://developer.android.com/reference/android/net/Uri.html` for the given asset path. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildDoubleTestSamples(int,java.util.Random)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, random: https://developer.android.com/reference/java/util/Random.html!)` Returns an array of random doubles between `[-1; 1]` with the specified length. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildFloatTestSamples(int,java.util.Random)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, random: https://developer.android.com/reference/java/util/Random.html!)` Returns an array of random floats between `[-1; 1]` with the specified length. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildFullyCustomizedMediaItem()()` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` that has all fields set to non-default values. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildTestData(int)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Equivalent to `buildTestData(length, length)`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildTestData(int,java.util.Random)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, random: https://developer.android.com/reference/java/util/Random.html!)` Generates an array of random bytes with the specified length. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildTestData(int,int)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, seed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Generates an array of random bytes with the specified length. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#buildTestString(int,java.util.Random)(length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, random: https://developer.android.com/reference/java/util/Random.html!)` Generates a random string with the specified length. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteArray(java.nio.ByteBuffer)(byteBuffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `byte[]`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteArray(int...)(bytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` Converts an array of integers in the range \[0, 255\] into an equivalent byte array. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteBuffer(float[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>!)` Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteBuffer(double[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html>!)` Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteBuffer(int[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteBuffer(long[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!)` Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteBuffer(short[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-short-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-short/index.html>!)` Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteBuffer(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessor!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteCountingAudioProcessor(java.util.concurrent.atomic.AtomicInteger)(byteCount: https://developer.android.com/reference/java/util/concurrent/atomic/AtomicInteger.html!)` Returns an `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessor` that counts the number of bytes input to it. |
| `java-static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createByteList(int...)(bytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` Converts an array of integers in the range \[0, 255\] into an equivalent byte list. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createFloatArray(java.nio.ByteBuffer)(byteBuffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `float[]`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createInt24Array(java.nio.ByteBuffer)(byteBuffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as 24-bit integer values in `int[]`. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createInt24ByteBuffer(int[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)` Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` with the contents of `data` as 24-bit integers. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createIntArray(java.nio.ByteBuffer)(byteBuffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `int[]`. |
| `java-static https://developer.android.com/reference/java/io/File.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createInternalCacheFile(android.content.Context,java.lang.String)(context: https://developer.android.com/reference/android/content/Context.html!, fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Creates a `https://developer.android.com/reference/java/io/File.html``fileName` within the `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`. |
| `java-static https://developer.android.com/reference/java/io/File.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createInternalCacheFile(android.content.Context,java.lang.String,java.lang.String)( context: https://developer.android.com/reference/android/content/Context.html!, directoryName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html! )` Creates a `https://developer.android.com/reference/java/io/File.html``fileName` in a directory `directoryName` within the `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/extractor/metadata/MetadataInputBuffer!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createMetadataInputBuffer(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Create a new `https://developer.android.com/reference/kotlin/androidx/media3/extractor/metadata/MetadataInputBuffer` and copy `data` into the backing `https://developer.android.com/reference/java/nio/ByteBuffer.html`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-short/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createShortArray(java.nio.ByteBuffer)(byteBuffer: https://developer.android.com/reference/java/nio/ByteBuffer.html!)` Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `short[]`. |
| `java-static https://developer.android.com/reference/android/view/SurfaceView.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createSurfaceView(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html!)` Creates a `https://developer.android.com/reference/android/view/SurfaceView.html` for tests where the creation is moved to the main thread if run on a non-Looper thread. |
| `java-static https://developer.android.com/reference/java/io/File.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createTestFile(java.io.File,java.lang.String)(directory: https://developer.android.com/reference/java/io/File.html!, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Writes one byte long test data to the file and returns it. |
| `java-static https://developer.android.com/reference/java/io/File.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createTestFile(java.io.File,long)(file: https://developer.android.com/reference/java/io/File.html!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Writes test data with the specified length to the file and returns it. |
| `java-static https://developer.android.com/reference/java/io/File.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#createTestFile(java.io.File,java.lang.String,long)(directory: https://developer.android.com/reference/java/io/File.html!, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Writes test data with the specified length to the file and returns it. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#extractAllSamplesFromByteArray(androidx.media3.extractor.Extractor,byte[])( extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>! )` Extracts all samples from the given byte array into a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#extractAllSamplesFromFile(androidx.media3.extractor.Extractor,android.content.Context,java.lang.String)( extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!, context: https://developer.android.com/reference/android/content/Context.html!, fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html! )` Extracts all samples from the given file into a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#extractAllSamplesFromFilePath(androidx.media3.extractor.Extractor,java.lang.String)(extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!, filePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Extracts all samples from the given file into a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#extractSeekMap(androidx.media3.extractor.Extractor,androidx.media3.test.utils.FakeExtractorOutput,androidx.media3.datasource.DataSource,android.net.Uri)( extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!, output: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!, dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, uri: https://developer.android.com/reference/android/net/Uri.html! )` Reads from the given input using the given `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor`, until it can produce the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap` and all of the track formats have been identified, or until the extractor encounters EOF. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#generateFloatInRange(java.util.Random,com.google.common.collect.Range<java.lang.Float>)(random: https://developer.android.com/reference/java/util/Random.html!, range: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/Range.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html!>!)` Returns a randomly generated float within the specified range, using `random` as random number generator. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#generateLong(java.util.Random,long,long)(random: https://developer.android.com/reference/java/util/Random.html!, origin: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, bound: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns a long between `origin` (inclusive) and `bound` (exclusive), given ` random`. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getByteArray(android.content.Context,java.lang.String)(context: https://developer.android.com/reference/android/content/Context.html!, fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the bytes of an asset file. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getByteArrayFromFilePath(java.lang.String)(filePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns the bytes of a file using its file path. |
| `java-static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getCommandsAsList(androidx.media3.common.Player.Commands)(commands: https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands!)` Returns an `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html` with the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` contained in `commands`. |
| `java-static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getEventsAsList(androidx.media3.common.Player.Events)(events: https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Events!)` Returns an `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html` with the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Event` contained in ` events`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getExtractorInputFromPosition(androidx.media3.datasource.DataSource,long,android.net.Uri)( dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, uri: https://developer.android.com/reference/android/net/Uri.html! )` Returns an `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput` to read from the given input at given position. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/database/DatabaseProvider!` | `[getInMemoryDatabaseProvider](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getInMemoryDatabaseProvider())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/InMemoryDatabaseRule`. <br /> |
| `java-static https://developer.android.com/reference/java/lang/Class.html<*>?` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getInnerClass(java.lang.Class<?>,java.lang.String)(clazz: https://developer.android.com/reference/java/lang/Class.html<*>!, className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns an inner class of `clazz` called `className` if it exists, otherwise null. |
| `java-static https://developer.android.com/reference/java/io/InputStream.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getInputStream(android.content.Context,java.lang.String)(context: https://developer.android.com/reference/android/content/Context.html!, fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns an `https://developer.android.com/reference/java/io/InputStream.html` for reading from an asset file. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getNonRandomByteBuffer(int,int)(frameCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, bytesPerFrame: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a non-random `https://developer.android.com/reference/java/nio/ByteBuffer.html` filled with `frameCount * bytesPerFrame` bytes. |
| `java-static https://developer.android.com/reference/java/nio/ByteBuffer.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getPeriodicSamplesBuffer(int,int)(sampleCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, period: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a `https://developer.android.com/reference/java/nio/ByteBuffer.html` filled with alternating 16-bit PCM samples as per the provided period length. |
| `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://developer.android.com/reference/java/lang/reflect/Method.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getPublicMethods(java.lang.Class<?>)(clazz: https://developer.android.com/reference/java/lang/Class.html<*>!)` Returns all the public methods of a Java class (except those defined by `https://developer.android.com/reference/java/lang/Object.html`). |
| `java-static (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-iterable/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterable/index.html<https://developer.android.com/reference/java/lang/reflect/Method.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getPublicOverridableMethods(java.lang.Class<?>)(clazz: https://developer.android.com/reference/java/lang/Class.html<*>!)` Returns all the public overridable methods of a Java class (except those defined by `https://developer.android.com/reference/java/lang/Object.html`). |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getString(android.content.Context,java.lang.String)(context: https://developer.android.com/reference/android/content/Context.html!, fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Returns a `https://developer.android.com/reference/java/lang/String.html` read from an asset file. |
| `java-static https://developer.android.com/reference/android/os/Bundle.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getThrowingBundle()()` Returns a `https://developer.android.com/reference/android/os/Bundle.html` that will throw an exception at the first attempt to read a value. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#repeatFlakyTest(int,org.junit.function.ThrowingRunnable)(maxRepetitions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, testImpl: https://junit.org/junit4/javadoc/latest/org/junit/function/ThrowingRunnable.html!)` Repeats the potentially flaky test multiple times if needed. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#retrieveTrackFormat(android.content.Context,java.lang.String,int)( context: https://developer.android.com/reference/android/content/Context.html!, fileUri: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, @https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType trackType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` for a given `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType` from a media file. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#seekToTimeUs(androidx.media3.extractor.Extractor,androidx.media3.extractor.SeekMap,long,androidx.media3.datasource.DataSource,androidx.media3.test.utils.FakeTrackOutput,android.net.Uri)( extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!, seekMap: https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap!, seekTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!, trackOutput: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput!, uri: https://developer.android.com/reference/android/net/Uri.html! )` Seeks to the given seek time of the stream from the given input, and keeps reading from the input until we can extract at least one sample following the seek position, or until end-of-input is reached. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#timelinesAreSame(androidx.media3.common.Timeline,androidx.media3.common.Timeline)(thisTimeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!, thatTimeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!)` Returns true if `thisTimeline` is equal to `thatTimeline`, ignoring `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#uid()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period#uid()` values, and shuffle order. |

## Constants

### PSNR_THRESHOLD

```
const val PSNR_THRESHOLD = 35.0f: Float
```

Luma PSNR values between 30 and 50 are considered good for lossy compression (See [Quality estimation with PSNR](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio#Quality_estimation_with_PSNR) ).

## Public functions

### assertBitmapsAreSimilar

```
java-static fun assertBitmapsAreSimilar(
    expectedBitmap: Bitmap!,
    actualBitmap: Bitmap!,
    psnrThresholdDb: Double
): Unit
```

Asserts whether actual bitmap is very similar to the expected bitmap at some quality level.

This is defined as their PSNR value is greater than or equal to the threshold. The higher the threshold, the more similar they are.

| Parameters |
|---|---|
| `expectedBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!` | The expected bitmap. |
| `actualBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!` | The actual bitmap. |
| `psnrThresholdDb: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | The PSNR threshold (in dB), at or above which bitmaps are considered very similar. |

### assertBufferInfosEqual

```
java-static fun assertBufferInfosEqual(
    expected: MediaCodec.BufferInfo!,
    actual: MediaCodec.BufferInfo!
): Unit
```

Returns whether two `https://developer.android.com/reference/android/media/MediaCodec.BufferInfo.html` are equal.

### assertDataSourceContent

```
java-static fun assertDataSourceContent(
    dataSource: DataSource!,
    dataSpec: DataSpec!,
    expectedData: ByteArray<Byte>!,
    expectKnownLength: Boolean
): Unit
```

Asserts that data read from a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` matches `expected`.

| Parameters |
|---|---|
| `dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` through which to read. |
| `dataSpec: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` to use when opening the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource`. |
| `expectedData: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The expected data. |
| `expectKnownLength: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to assert that `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource#open(androidx.media3.datasource.DataSpec)` returns the expected data length. If false then it's asserted that `https://developer.android.com/reference/kotlin/androidx/media3/common/C#LENGTH_UNSET()` is returned. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading fom the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource`. |

### assertForwardingClassForwardsAllMethods

```
java-static fun <T : Any?, F : T?> assertForwardingClassForwardsAllMethods(
    superType: Class<T!>!,
    forwardingInstanceFactory: Function<T!, F!>!
): Unit
```

Use reflection to assert that calling every non-final method declared on `superType` on an instance of `forwardingType` results in the call being forwarded to the `
superType` delegate.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/reflect/InvocationTargetException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |

### assertForwardingClassForwardsAllMethodsExcept

```
java-static fun <T : Any?, F : T?> assertForwardingClassForwardsAllMethodsExcept(
    superType: Class<T!>!,
    forwardingInstanceFactory: Function<T!, F!>!,
    excludedMethods: (Mutable)Set<String!>!
): Unit
```

Use reflection to assert that calling every non-final, non-excluded method declared on `
superType` on an instance of `forwardingType` results in the call being forwarded to the `superType` delegate.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/reflect/InvocationTargetException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |

### assertFp16BitmapsAreSimilar

```
@RequiresApi(value = 29)
java-static fun assertFp16BitmapsAreSimilar(
    expectedBitmap: Bitmap!,
    actualBitmap: Bitmap!,
    psnrThresholdDb: Double
): Unit
```

Asserts whether actual FP16 bitmap is very similar to the expected FP16 bitmap at some quality level.

This is defined as their PSNR value is greater than or equal to the threshold. The higher the threshold, the more similar they are.

| Parameters |
|---|---|
| `expectedBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!` | The expected FP16 bitmap. |
| `actualBitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!` | The actual FP16 bitmap. |
| `psnrThresholdDb: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html` | The PSNR threshold (in dB), at or above which bitmaps are considered very similar. |

### assertSubclassOverridesAllMethods

```
java-static fun <T> assertSubclassOverridesAllMethods(
    superType: Class<T!>!,
    subType: Class<T!>!
): Unit
```

Use reflection to assert that every non-final method declared on `superType` is overridden by `subType`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NoSuchMethodException.html` |   |

### assertSubclassOverridesAllMethodsExcept

```
java-static fun <T> assertSubclassOverridesAllMethodsExcept(
    superType: Class<T!>!,
    subType: Class<T!>!,
    excludedMethods: (Mutable)Set<String!>!
): Unit
```

Use reflection to assert that every non-final, non-excluded method declared on `
superType` is overridden by `subType`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NoSuchMethodException.html` |   |

### assertTimelinesSame

```
java-static fun assertTimelinesSame(
    actualTimelines: (Mutable)List<Timeline!>!,
    expectedTimelines: (Mutable)List<Timeline!>!
): Unit
```

Asserts that the actual timelines are the same to the expected timelines. This assert differs from testing equality by not comparing:

- Period IDs, which may be different due to ID mapping of child source period IDs.
- Shuffle order, which by default is random and non-deterministic.

| Parameters |
|---|---|
| `actualTimelines: (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://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!>!` | A list of actual `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |
| `expectedTimelines: (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://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!>!` | A list of expected `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |

### buildAssetUri

```
java-static fun buildAssetUri(assetPath: String!): Uri!
```

Returns the `https://developer.android.com/reference/android/net/Uri.html` for the given asset path.

### buildDoubleTestSamples

```
java-static fun buildDoubleTestSamples(length: Int, random: Random!): Array<Double>!
```

Returns an array of random doubles between `[-1; 1]` with the specified length.

### buildFloatTestSamples

```
java-static fun buildFloatTestSamples(length: Int, random: Random!): Array<Float>!
```

Returns an array of random floats between `[-1; 1]` with the specified length.

### buildFullyCustomizedMediaItem

```
java-static fun buildFullyCustomizedMediaItem(): MediaItem!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` that has all fields set to non-default values.

### buildTestData

```
java-static fun buildTestData(length: Int): Array<Byte>!
```

Equivalent to `buildTestData(length, length)`.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the array. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The generated array. |

### buildTestData

```
java-static fun buildTestData(length: Int, random: Random!): Array<Byte>!
```

Generates an array of random bytes with the specified length.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the array. |
| `random: https://developer.android.com/reference/java/util/Random.html!` | A source of randomness. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The generated array. |

### buildTestData

```
java-static fun buildTestData(length: Int, seed: Int): Array<Byte>!
```

Generates an array of random bytes with the specified length.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the array. |
| `seed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A seed for an internally created `https://developer.android.com/reference/java/util/Random.html`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The generated array. |

### buildTestString

```
java-static fun buildTestString(length: Int, random: Random!): String!
```

Generates a random string with the specified length.

| Parameters |
|---|---|
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The length of the string. |
| `random: https://developer.android.com/reference/java/util/Random.html!` | A source of randomness. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The generated string. |

### createByteArray

```
java-static fun createByteArray(byteBuffer: ByteBuffer!): Array<Byte>!
```

Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `byte[]`.

### createByteArray

```
java-static fun createByteArray(bytes: IntArray<Int>!): Array<Byte>!
```

Converts an array of integers in the range \[0, 255\] into an equivalent byte array.

| Parameters |
|---|---|
| `bytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | An array of integers, all of which must be in the range \[0, 255\]. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The equivalent byte array. |

### createByteBuffer

```
java-static fun createByteBuffer(data: FloatArray<Float>!): ByteBuffer!
```

Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`.

### createByteBuffer

```
java-static fun createByteBuffer(data: DoubleArray<Double>!): ByteBuffer!
```

Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`.

### createByteBuffer

```
java-static fun createByteBuffer(data: IntArray<Int>!): ByteBuffer!
```

Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`.

### createByteBuffer

```
java-static fun createByteBuffer(data: LongArray<Long>!): ByteBuffer!
```

Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`.

### createByteBuffer

```
java-static fun createByteBuffer(data: ShortArray<Short>!): ByteBuffer!
```

Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`.

### createByteBuffer

```
java-static fun createByteBuffer(data: ByteArray<Byte>!): ByteBuffer!
```

Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` containing the `data`.

### createByteCountingAudioProcessor

```
java-static fun createByteCountingAudioProcessor(byteCount: AtomicInteger!): AudioProcessor!
```

Returns an `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessor` that counts the number of bytes input to it.

### createByteList

```
java-static fun createByteList(bytes: IntArray<Int>!): ImmutableList<Byte!>!
```

Converts an array of integers in the range \[0, 255\] into an equivalent byte list.

| Parameters |
|---|---|
| `bytes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | An array of integers, all of which must be in the range \[0, 255\]. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html!>!` | The equivalent byte list. |

### createFloatArray

```
java-static fun createFloatArray(byteBuffer: ByteBuffer!): Array<Float>!
```

Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `float[]`.

### createInt24Array

```
java-static fun createInt24Array(byteBuffer: ByteBuffer!): Array<Int>!
```

Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as 24-bit integer values in `int[]`.

### createInt24ByteBuffer

```
java-static fun createInt24ByteBuffer(data: IntArray<Int>!): ByteBuffer!
```

Creates a `https://developer.android.com/reference/java/nio/ByteBuffer.html` with the contents of `data` as 24-bit integers.

### createIntArray

```
java-static fun createIntArray(byteBuffer: ByteBuffer!): Array<Int>!
```

Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `int[]`.

### createInternalCacheFile

```
java-static fun createInternalCacheFile(context: Context!, fileName: String!): File!
```

Creates a `https://developer.android.com/reference/java/io/File.html``fileName` within the `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`.

If a file of that name already exists, it is overwritten.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html!` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The filename to save to the cache. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### createInternalCacheFile

```
java-static fun createInternalCacheFile(
    context: Context!,
    directoryName: String!,
    fileName: String!
): File!
```

Creates a `https://developer.android.com/reference/java/io/File.html``fileName` in a directory `directoryName` within the `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`.

If a file of that name already exists, it is overwritten.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html!` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `directoryName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The directory name within the internal cache to save the file in. |
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The filename to save to the cache. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### createMetadataInputBuffer

```
java-static fun createMetadataInputBuffer(data: ByteArray<Byte>!): MetadataInputBuffer!
```

Create a new `https://developer.android.com/reference/kotlin/androidx/media3/extractor/metadata/MetadataInputBuffer` and copy `data` into the backing `https://developer.android.com/reference/java/nio/ByteBuffer.html`.

### createShortArray

```
java-static fun createShortArray(byteBuffer: ByteBuffer!): Array<Short>!
```

Gets the underlying data of the `https://developer.android.com/reference/java/nio/ByteBuffer.html` as a `short[]`.

### createSurfaceView

```
java-static fun createSurfaceView(context: Context!): SurfaceView!
```

Creates a `https://developer.android.com/reference/android/view/SurfaceView.html` for tests where the creation is moved to the main thread if run on a non-Looper thread. This is needed on API \<26 where `https://developer.android.com/reference/android/view/SurfaceView.html` cannot be created on a non-Looper thread.

### createTestFile

```
java-static fun createTestFile(directory: File!, name: String!): File!
```

Writes one byte long test data to the file and returns it.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### createTestFile

```
java-static fun createTestFile(file: File!, length: Long): File!
```

Writes test data with the specified length to the file and returns it.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### createTestFile

```
java-static fun createTestFile(directory: File!, name: String!, length: Long): File!
```

Writes test data with the specified length to the file and returns it.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### extractAllSamplesFromByteArray

```
java-static fun extractAllSamplesFromByteArray(
    extractor: Extractor!,
    data: ByteArray<Byte>!
): FakeExtractorOutput!
```

Extracts all samples from the given byte array into a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput`.

| Parameters |
|---|---|
| `extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` to be used. |
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The byte array data. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput` containing the extracted samples. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the input, or if the extractor finishes reading from input without extracting any `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap`. |

### extractAllSamplesFromFile

```
java-static fun extractAllSamplesFromFile(
    extractor: Extractor!,
    context: Context!,
    fileName: String!
): FakeExtractorOutput!
```

Extracts all samples from the given file into a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput`.

| Parameters |
|---|---|
| `extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` to be used. |
| `context: https://developer.android.com/reference/android/content/Context.html!` | A `https://developer.android.com/reference/android/content/Context.html`. |
| `fileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The name of the input file. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput` containing the extracted samples. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the input, or if the extractor finishes reading from input without extracting any `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap`. |

### extractAllSamplesFromFilePath

```
java-static fun extractAllSamplesFromFilePath(extractor: Extractor!, filePath: String!): FakeExtractorOutput!
```

Extracts all samples from the given file into a `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput`.

| Parameters |
|---|---|
| `extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` to be used. |
| `filePath: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The file path. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput` containing the extracted samples. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the input, or if the extractor finishes reading from input without extracting any `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap`. |

### extractSeekMap

```
java-static fun extractSeekMap(
    extractor: Extractor!,
    output: FakeExtractorOutput!,
    dataSource: DataSource!,
    uri: Uri!
): SeekMap!
```

Reads from the given input using the given `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor`, until it can produce the `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap` and all of the track formats have been identified, or until the extractor encounters EOF.

| Parameters |
|---|---|
| `extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` to extractor from input. |
| `output: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeExtractorOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput` to store the extracted `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap` and track. |
| `dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` that will be used to read from the input. |
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | The Uri of the input. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap!` | The extracted `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from the input, or if the extractor finishes reading from input without extracting any `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap`. |

### generateFloatInRange

```
java-static fun generateFloatInRange(random: Random!, range: Range<Float!>!): Float
```

Returns a randomly generated float within the specified range, using `random` as random number generator.

`range` must be a bounded range.

### generateLong

```
java-static fun generateLong(random: Random!, origin: Long, bound: Long): Long
```

Returns a long between `origin` (inclusive) and `bound` (exclusive), given `
random`.

### getByteArray

```
java-static fun getByteArray(context: Context!, fileName: String!): Array<Byte>!
```

Returns the bytes of an asset file.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### getByteArrayFromFilePath

```
java-static fun getByteArrayFromFilePath(filePath: String!): Array<Byte>!
```

Returns the bytes of a file using its file path.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### getCommandsAsList

```
java-static fun getCommandsAsList(commands: Player.Commands!): ImmutableList<Int!>!
```

Returns an `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html` with the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` contained in `commands`. The contents of the list are in matching order with the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Command` returned by `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Commands#get(int)`.

### getEventsAsList

```
java-static fun getEventsAsList(events: Player.Events!): ImmutableList<Int!>!
```

Returns an `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html` with the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Event` contained in `
events`. The contents of the list are in matching order with the `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Event` returned by `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Events#get(int)`.

### getExtractorInputFromPosition

```
java-static fun getExtractorInputFromPosition(
    dataSource: DataSource!,
    position: Long,
    uri: Uri!
): ExtractorInput!
```

Returns an `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput` to read from the given input at given position.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### getInMemoryDatabaseProvider

```
java-static fun [getInMemoryDatabaseProvider](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestUtil#getInMemoryDatabaseProvider())(): DatabaseProvider!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/InMemoryDatabaseRule`.

### getInnerClass

```
java-static fun getInnerClass(clazz: Class<*>!, className: String!): Class<*>?
```

Returns an inner class of `clazz` called `className` if it exists, otherwise null.

### getInputStream

```
java-static fun getInputStream(context: Context!, fileName: String!): InputStream!
```

Returns an `https://developer.android.com/reference/java/io/InputStream.html` for reading from an asset file.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### getNonRandomByteBuffer

```
java-static fun getNonRandomByteBuffer(frameCount: Int, bytesPerFrame: Int): ByteBuffer!
```

Returns a non-random `https://developer.android.com/reference/java/nio/ByteBuffer.html` filled with `frameCount * bytesPerFrame` bytes.

### getPeriodicSamplesBuffer

```
java-static fun getPeriodicSamplesBuffer(sampleCount: Int, period: Int): ByteBuffer!
```

Returns a `https://developer.android.com/reference/java/nio/ByteBuffer.html` filled with alternating 16-bit PCM samples as per the provided period length.

The generated samples alternate between `https://developer.android.com/reference/java/lang/Short.html#MAX_VALUE` and `https://developer.android.com/reference/java/lang/Short.html#MIN_VALUE` every `period / 2` samples.

| Parameters |
|---|---|
| `sampleCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Number of total PCM samples (not frames) to generate. |
| `period: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Length in PCM samples of one full cycle. |

### getPublicMethods

```
java-static fun getPublicMethods(clazz: Class<*>!): (Mutable)List<Method!>!
```

Returns all the public methods of a Java class (except those defined by `https://developer.android.com/reference/java/lang/Object.html`).

### getPublicOverridableMethods

```
java-static fun getPublicOverridableMethods(clazz: Class<*>!): (Mutable)Iterable<Method!>!
```

Returns all the public overridable methods of a Java class (except those defined by `https://developer.android.com/reference/java/lang/Object.html`).

### getString

```
java-static fun getString(context: Context!, fileName: String!): String!
```

Returns a `https://developer.android.com/reference/java/lang/String.html` read from an asset file.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### getThrowingBundle

```
java-static fun getThrowingBundle(): Bundle!
```

Returns a `https://developer.android.com/reference/android/os/Bundle.html` that will throw an exception at the first attempt to read a value.

### repeatFlakyTest

```
java-static fun repeatFlakyTest(maxRepetitions: Int, testImpl: ThrowingRunnable!): Unit
```

Repeats the potentially flaky test multiple times if needed.

Only use this method for tests with inherent randomness or systems-under-test that are not fully controllable, and where the reason for the the flakiness can be explained. Don't use this method if the test should always pass reliably.

| Parameters |
|---|---|
| `maxRepetitions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum number of repetitions before failing the test. |
| `testImpl: https://junit.org/junit4/javadoc/latest/org/junit/function/ThrowingRunnable.html!` | The test implementation. |

### retrieveTrackFormat

```
java-static fun retrieveTrackFormat(
    context: Context!,
    fileUri: String!,
    @C.TrackType trackType: Int
): Format!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` for a given `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType` from a media file.

If more than one track is present for the given `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType` then only one track's `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` is returned.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html!` | The `https://developer.android.com/reference/android/content/Context.html`; |
| `fileUri: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The media file uri. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType trackType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` for the given `https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ExecutionException.html` | If an error occurred while retrieving file's metadata. |
| `https://developer.android.com/reference/java/lang/InterruptedException.html` | If interrupted while retrieving file's metadata. |

### seekToTimeUs

```
java-static fun seekToTimeUs(
    extractor: Extractor!,
    seekMap: SeekMap!,
    seekTimeUs: Long,
    dataSource: DataSource!,
    trackOutput: FakeTrackOutput!,
    uri: Uri!
): Int
```

Seeks to the given seek time of the stream from the given input, and keeps reading from the input until we can extract at least one sample following the seek position, or until end-of-input is reached.

| Parameters |
|---|---|
| `extractor: https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/Extractor` to extract from input. |
| `seekMap: https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap!` | The `https://developer.android.com/reference/kotlin/androidx/media3/extractor/SeekMap` of the stream from the given input. |
| `seekTimeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The seek time, in micro-seconds. |
| `dataSource: https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource!` | The `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSource` that will be used to read from the input. |
| `trackOutput: https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput!` | The `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput` to store the extracted samples. |
| `uri: https://developer.android.com/reference/android/net/Uri.html!` | The Uri of the input. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the first extracted sample written to the given `trackOutput` after the seek is completed, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the seek is completed without any extracted sample. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### timelinesAreSame

```
java-static fun timelinesAreSame(thisTimeline: Timeline!, thatTimeline: Timeline!): Boolean
```

Returns true if `thisTimeline` is equal to `thatTimeline`, ignoring `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#uid()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period#uid()` values, and shuffle order.