androidx.media3.test.utils
Interfaces
Classes
Action |
Base class for actions to perform during playback tests. |
Action.AddMediaItems |
Calls |
Action.ClearMediaItems |
Calls |
Action.ClearVideoSurface |
Calls |
Action.ExecuteRunnable |
Calls |
Action.MoveMediaItem |
Calls |
Action.PlayUntilPosition |
Schedules a play action to be executed, waits until the player reaches the specified position, and pauses the player again. |
Action.Prepare |
Calls |
Action.RemoveMediaItem |
Calls |
Action.RemoveMediaItems |
Calls |
Action.Seek |
|
Action.SendMessages |
Calls |
Action.SetAudioAttributes |
Calls |
Action.SetMediaItems |
Calls |
Action.SetMediaItemsResetPosition |
Calls |
Action.SetPlayWhenReady |
Calls |
Action.SetPlaybackParameters |
Calls |
Action.SetRendererDisabled |
Updates the |
Action.SetRepeatMode |
Calls |
Action.SetShuffleModeEnabled |
Calls |
Action.SetShuffleOrder |
Calls |
Action.SetVideoSurface |
Calls |
Action.Stop |
Calls |
Action.ThrowPlaybackException |
Throws a playback exception on the playback thread. |
Action.WaitForIsLoading |
Waits for a specified loading state, returning either immediately or after a call to |
Action.WaitForMessage |
Waits for a player message to arrive. |
Action.WaitForPendingPlayerCommands |
Waits until the player acknowledged all pending player commands. |
Action.WaitForPlayWhenReady |
Waits for a specified playWhenReady value, returning either immediately or after a call to |
Action.WaitForPlaybackState |
Waits for a specified playback state, returning either immediately or after a call to |
Action.WaitForPositionDiscontinuity |
Waits for |
Action.WaitForTimelineChanged |
Waits for |
ActionSchedule |
Schedules a sequence of |
ActionSchedule.Builder |
A builder for |
ActionSchedule.PlayerRunnable |
Provides a wrapper for a |
ActionSchedule.PlayerTarget |
Provides a wrapper for a |
AdditionalFailureInfo |
A JUnit |
AssetContentProvider |
A |
AssetInfo |
Information about a test asset. |
BinderStressCreator |
A utility for creating artificial stress on the system process binder. |
BitmapPixelTestUtil |
Utilities for pixel tests. |
BitmapPixelTestUtil.ImageBuffer |
Represents a |
CacheAsserts |
Assertion methods for |
CacheAsserts.RequestSet |
Defines a set of data requests. |
CapturingAudioSink |
An |
CapturingAudioSink.InterceptingBufferSink |
|
CapturingAudioSink.SampleInterceptingBufferSink |
|
CapturingImageOutput |
A |
CompositionAssetInfo |
Test assets that describe various |
DataSourceContractTest |
A collection of contract tests for |
DataSourceContractTest.FakeTransferListener |
A |
DataSourceContractTest.TestResource |
Information about a resource that can be used to test the |
DataSourceContractTest.TestResource.Builder |
Builder for |
DecodeOneFrameUtil |
Utilities for decoding a video frame for tests. |
DecoderCountersUtil |
Assertions for |
DefaultRenderersFactoryAsserts |
Assertions for |
DownloadBuilder |
Builder for |
DummyMainThread |
Helper class to simulate main/UI thread in tests. |
DumpFileAsserts |
Helper class to enable assertions based on golden-data dump files. |
DumpableFormat |
Wraps a |
DumpableMp4Box |
Wraps an Mp4 box to allow dumping it. |
Dumper |
Helper utility to dump field values. |
EditedMediaItemAssetInfo |
Information about an |
EmptyMediaSource |
MediaSource producing an empty |
ExoHostedTest |
A |
ExoPlayerTestRunner |
Helper class to run an ExoPlayer test. |
ExoPlayerTestRunner.Builder |
Builder to set-up an |
ExtractorAsserts |
Assertion methods for |
ExtractorAsserts.AssertionConfig |
A config for the assertions made (e.g. dump file location). |
ExtractorAsserts.AssertionConfig.Builder |
Builder for |
ExtractorAsserts.ConfigProvider |
A |
ExtractorAsserts.SimulationConfig |
A config of different environments to simulate and extractor behaviours to test. |
FailOnCloseDataSink |
A |
FailOnCloseDataSink.Factory |
Factory to create a |
FakeAdaptiveDataSet |
Fake data set emulating the data of an adaptive media source. |
FakeAdaptiveDataSet.Factory |
Factory for |
FakeAdaptiveDataSet.Iterator |
|
FakeAdaptiveMediaPeriod |
Fake |
FakeAdaptiveMediaSource |
Fake |
FakeAdsLoader |
A fake implementation of |
FakeAudioRenderer |
A |
FakeChunkSource |
Fake |
FakeChunkSource.Factory |
Factory for a |
FakeClock |
Fake |
FakeClock.Builder |
A builder for |
FakeClock.HandlerMessage |
Message data saved to send messages or execute runnables at a later time on a Handler. |
FakeCryptoConfig |
Fake |
FakeDataSet |
Collection of |
FakeDataSet.FakeData |
Container of fake data to be served by a |
FakeDataSet.FakeData.Segment |
A segment of |
FakeDataSource |
A fake |
FakeDataSource.Factory |
Factory to create a |
FakeExoMediaDrm |
A fake implementation of |
FakeExoMediaDrm.Builder |
Builder for |
FakeExoMediaDrm.LicenseServer |
An license server implementation to interact with |
FakeExoMediaDrm.LicenseServer.Builder |
Builder for |
FakeExtractorInput |
A fake |
FakeExtractorInput.Builder |
Builder of |
FakeExtractorOutput |
A fake |
FakeFrameProcessor |
A no-op |
FakeFrameProcessor.EosEvent |
Marker class representing a |
FakeFrameProcessor.Factory |
A factory for |
FakeFrameProcessor.FramesEvent |
Holds the frames queued in a |
FakeHardwareBufferNativeHelpers |
Fake class to simulate |
FakeMediaChunk |
Fake |
FakeMediaChunkIterator |
Fake |
FakeMediaClockRenderer |
Fake abstract |
FakeMediaPeriod |
Fake |
FakeMediaSource |
Fake |
FakeMediaSource.Builder |
A builder for |
FakeMediaSource.InitialTimeline |
A forwarding timeline to provide an initial timeline for fake multi window sources. |
FakeMediaSourceFactory |
Fake |
FakeMetadataEntry |
A fake |
FakeMultiPeriodLiveTimeline |
A fake |
FakePlayer |
A fake |
FakeRenderer |
Fake |
FakeSampleStream |
Fake |
FakeSampleStream.FakeSampleStreamItem |
Item to customize a return value of |
FakeShuffleOrder |
Fake |
FakeTimeline |
Fake |
FakeTimeline.TimelineWindowDefinition |
Definition used to define a |
FakeTimeline.TimelineWindowDefinition.Builder |
A builder to build instances of |
FakeTrackOutput |
A fake |
FakeTrackSelection |
A fake |
FakeTrackSelector |
A fake |
FakeTrackSelector.FakeTrackSelectionFactory |
A factory for the |
FakeVideoRenderer |
A |
FormatSupportAssumptions |
Utility methods for checking and assuming format support in instrumentation tests. |
HdrCapabilitiesUtil |
Utility class for checking HDR capabilities. |
HostActivity |
A host activity for performing playback tests. |
HttpDataSourceTestEnv |
A JUnit |
ImageReaderSurfaceHolder |
An implementation of |
ImmutableByteArray |
|
ImmutableByteArray.Builder |
Builder for |
InMemoryDatabaseRule |
A JUnit |
MalformedParcelable |
A |
MediaPeriodAsserts |
Assertion methods for |
MediaSourceTestRunner |
A runner for |
MediaSourceTestRunner.MediaSourceListener |
|
MssimCalculator |
Image comparison tool that calculates the Mean Structural Similarity (MSSIM) of two images, developed by Wang, Bovik, Sheikh, and Simoncelli. |
OggFileAudioBufferSink |
A sink for audio buffers that writes output audio as .ogg files with a given path prefix. |
PassthroughAudioProcessor |
A |
PlayerFence |
A Java-compatible fluent API for waiting for certain |
RecordingHardwareBufferEffectsPipeline |
Wraps a |
RecordingPacketConsumer |
A |
ReleaseListener |
A shared |
SequenceAssetInfo |
Test assets that describe various |
SsimHelper |
A helper for calculating SSIM score for transcoded videos. |
StubExoPlayer |
An abstract |
StubPlayer |
An abstract |
TestExoPlayerBuilder |
A builder of |
TestSpeedProvider |
|
TestSummaryLogger |
Utilities for logging test summaries in instrumentation tests. |
TestTransformerBuilder |
A builder of |
TestUtil |
Utility methods for tests. |
TextureBitmapReader |
Reads from an OpenGL texture. |
ThreadTestUtil |
Static utility to coordinate threads in testing environments. |
ThrowingSubtitleParserFactory |
A |
TimelineAsserts |
Assertion methods for |
VideoDecodingWrapper |
A wrapper for decoding a video using |
VideoFrameProcessorTestRunner |
A test runner for |
VideoFrameProcessorTestRunner.Builder |
A builder for |
VideoFrameProcessorTestRunner.SurfaceBitmapReader |
Reads from a |
WebServerDispatcher |
A Dispatcher for okhttp3.mockwebserver.MockWebServer that allows per-path customisation of the static data served. |
WebServerDispatcher.Resource |
A resource served by |
WebServerDispatcher.Resource.Builder |
Builder for |
Exceptions
FakeExtractorInput.SimulatedIOException |
Thrown when simulating an |
Top-level functions summary
Unit |
@UnstableApiRuns the given |
Extension functions summary
suspend Unit |
@UnstableApiSuspends until the content position reaches (or passes) |
suspend Unit |
@UnstableApiSuspends until |
suspend Unit |
@UnstableApiSuspends until the player's |
suspend Unit |
@UnstableApiSuspends until the player enters the provided |
Top-level functions
doBlocking
@UnstableApi
fun doBlocking(
context: CoroutineContext = EmptyCoroutineContext,
block: suspend CoroutineScope.() -> Unit
): Unit
Runs the given block using runBlocking on the current thread for side effect.
Using this function is like runBlocking with default context (which runs the given block on the calling thread) but forces the return type to be Unit, which is helpful when implementing suspending tests as expression functions:
@Test
fun myTest() = doBlocking {...}
Extension functions
Player.awaitContentPositionAtLeast
@UnstableApi
suspend fun Player.awaitContentPositionAtLeast(
targetPositionMs: Long,
failOnNonFatalErrors: Boolean = true,
timeout: Duration? = null
): Unit
Suspends until the content position reaches (or passes) targetPositionMs in the current media item.
This makes some assumptions:
-
The condition completes immediately if
Player.getContentPositionis already at leasttargetPositionMs. -
Seeking past the target position satisfies the condition.
-
If playback ends, or the media item changes, before the target position is reached, an exception is thrown.
Must be called on the player's application looper thread.
| Parameters | |
|---|---|
targetPositionMs: Long |
The |
failOnNonFatalErrors: Boolean = true |
Whether non-fatal errors (such as those from |
timeout: Duration? = null |
The max time to wait for, or |
| Throws | |
|---|---|
IllegalStateException |
if not called on the player's application looper thread. |
Player.awaitFirstFrameRendered
@UnstableApi
suspend fun Player.awaitFirstFrameRendered(
failOnNonFatalErrors: Boolean = true,
timeout: Duration? = null
): Unit
Suspends until Player.Listener.onRenderedFirstFrame is invoked.
This should be called before the callback has been invoked (e.g. before calling Player.prepare), otherwise it risks awaiting forever.
Must be called on the player's application looper thread.
| Parameters | |
|---|---|
failOnNonFatalErrors: Boolean = true |
Whether non-fatal errors (such as those from |
timeout: Duration? = null |
The max time to wait for, or |
| Throws | |
|---|---|
IllegalStateException |
if not called on the player's application looper thread. |
Player.awaitIsPlaying
@UnstableApi
suspend fun Player.awaitIsPlaying(
targetIsPlaying: Boolean,
failOnNonFatalErrors: Boolean = true,
timeout: Duration? = null
): Unit
Suspends until the player's Player.isPlaying value matches targetIsPlaying.
If the player's Player.isPlaying value is already targetIsPlaying this returns immediately.
Must be called on the player's application looper thread.
| Parameters | |
|---|---|
targetIsPlaying: Boolean |
The value of |
failOnNonFatalErrors: Boolean = true |
Whether non-fatal errors (such as those from |
timeout: Duration? = null |
The max time to wait for, or |
| Throws | |
|---|---|
IllegalStateException |
if not called on the player's application looper thread. |
Player.awaitPlaybackState
@UnstableApi
suspend fun Player.awaitPlaybackState(
targetState: @Player.State Int,
failOnNonFatalErrors: Boolean = true,
timeout: Duration? = null
): Unit
Suspends until the player enters the provided targetState.
If the player is already in the provided targetState this returns immediately.
Must be called on the player's application looper thread.
| Parameters | |
|---|---|
targetState: @Player.State Int |
The playback |
failOnNonFatalErrors: Boolean = true |
Whether non-fatal errors (such as those from |
timeout: Duration? = null |
The max time to wait for, or |
| Throws | |
|---|---|
IllegalStateException |
if not called on the player's application looper thread. |