TestPlayerRunHelper.ExoPlayerRunResult


class TestPlayerRunHelper.ExoPlayerRunResult : TestPlayerRunHelper.PlayerRunResult


An ExoPlayer specific subclass of PlayerRunResult, giving access to conditions that only make sense for the ExoPlayer interface.

Summary

Public functions

TestPlayerRunHelper.ExoPlayerRunResult!

Returns a new instance where the untilXXX(...) methods ignore non-fatal errors.

Unit
untilBackgroundThreadCondition(
    backgroundThreadCondition: Supplier<Boolean!>!
)

Runs tasks of the main Looper until the specified condition becomes true independent of a message on the main Looper.

Unit

Runs tasks of the main Looper until the player has fully buffered its entire playlist and stopped reporting isLoading.

Unit
untilMediaItemIndex(mediaItemIndex: Int)

Runs tasks of the main Looper until getCurrentMediaItemIndex equals the specified index or an error occurs.

Unit

Runs tasks of the main Looper until the player completely handled all previously issued commands on the internal playback thread.

ExoPlaybackException!

Runs tasks of the main Looper until a player error occurs.

Unit
untilPosition(mediaItemIndex: Int, positionMs: Long)

Runs tasks of the main Looper until the internal playback thread reaches the specified position or an error occurs.

Unit

Runs tasks of the main Looper until getContentPosition reaches at least the specified position in the current media item, or an error occurs.

Unit
untilPositionAtLeast(mediaItemIndex: Int, positionMs: Long)

Runs tasks of the main Looper until getCurrentMediaItemIndex equals the specified index and getContentPosition reaches at least the specified position, or an error occurs.

Unit
untilSleepingForOffloadBecomes(expectedSleepingForOffload: Boolean)

Runs tasks of the main Looper until isSleepingForOffload matches the expected value, or an error occurs.

Unit
untilStartOfMediaItem(mediaItemIndex: Int)

Runs tasks of the main Looper until the internal playback thread reaches the start of the specified media item or a playback error occurs.

Inherited functions

From androidx.media3.test.utils.robolectric.TestPlayerRunHelper.PlayerRunResult
Unit
runUntil(predicate: Supplier<Boolean!>!)

Runs the main Looper until predicate returns true or an error occurs.

Unit

Runs tasks of the main Looper until onRenderedFirstFrame is called or an error occurs.

Unit
untilLoadingIs(expectedIsLoading: Boolean)

Runs tasks of the main Looper until isLoading matches the expected value or an error occurs.

Unit
untilPlayWhenReadyIs(expectedPlayWhenReady: Boolean)

Runs tasks of the main Looper until getPlayWhenReady matches the expected value or an error occurs.

Unit

Runs tasks of the main Looper until onPositionDiscontinuity is called with the specified Player.DiscontinuityReason or an error occurs.

Unit
untilState(@Player.State expectedState: Int)

Runs tasks of the main Looper until getPlaybackState matches the expected state or an error occurs.

Timeline!

Runs tasks of the main Looper until a timeline change or an error occurs.

Unit
untilTimelineChangesTo(expectedTimeline: Timeline!)

Runs tasks of the main Looper until getCurrentTimeline matches the expected timeline or an error occurs.

Public functions

ignoringNonFatalErrors

fun ignoringNonFatalErrors(): TestPlayerRunHelper.ExoPlayerRunResult!

Returns a new instance where the untilXXX(...) methods ignore non-fatal errors.

A fatal error is defined as an error that is passed to onPlayerError and results in the player transitioning to STATE_IDLE. A non-fatal error is defined as an error that is passed to any other callback (e.g. onLoadError).

untilBackgroundThreadCondition

fun untilBackgroundThreadCondition(
    backgroundThreadCondition: Supplier<Boolean!>!
): Unit

Runs tasks of the main Looper until the specified condition becomes true independent of a message on the main Looper.

This method is useful for cases where the condition may change outside of a main message, for example because it's checking a volatile variable or shared synchronized state that is updated on a background thread, or because checking the condition itself may cause it to become true.

This method ensures the condition is checked within artificially created main messages. When using a androidx.media3.test.utils.FakeClock, this guarantees the remainder of the test method is not executed in parallel with other background thread messages.

Parameters
backgroundThreadCondition: Supplier<Boolean!>!

The condition to wait for.

Throws
androidx.media3.common.PlaybackException

If a playback error occurs.

java.lang.IllegalStateException

If non-fatal playback errors occur, and aren't ignored (the non-fatal exceptions will be attached with addSuppressed).

java.util.concurrent.TimeoutException

If the default timeout is exceeded.

untilFullyBuffered

fun untilFullyBuffered(): Unit

Runs tasks of the main Looper until the player has fully buffered its entire playlist and stopped reporting isLoading.

Note that this method won't succeed if the player is configured with a that prevents loading the playlist fully before playback resumes.

If a Player.RepeatMode setting results in an endless playlist, this method only waits until all items have been buffered at least once.

untilMediaItemIndex

fun untilMediaItemIndex(mediaItemIndex: Int): Unit

Runs tasks of the main Looper until getCurrentMediaItemIndex equals the specified index or an error occurs.

Use untilStartOfMediaItem instead if the test needs to advance the player until the internal playback thread reaches the start of the media item exactly.

Throws
androidx.media3.common.PlaybackException

If a playback error occurs.

java.lang.IllegalStateException

If non-fatal playback errors occur, and aren't ignored (the non-fatal exceptions will be attached with addSuppressed).

java.util.concurrent.TimeoutException

If the default timeout is exceeded.

untilPendingCommandsAreFullyHandled

fun untilPendingCommandsAreFullyHandled(): Unit

Runs tasks of the main Looper until the player completely handled all previously issued commands on the internal playback thread.

Both fatal and non-fatal errors are always ignored.

untilPlayerError

fun untilPlayerError(): ExoPlaybackException!

Runs tasks of the main Looper until a player error occurs.

Non-fatal errors are always ignored.

untilPosition

fun untilPosition(mediaItemIndex: Int, positionMs: Long): Unit

Runs tasks of the main Looper until the internal playback thread reaches the specified position or an error occurs.

Use untilPositionAtLeast instead if the test needs to advance the player until the publicly visible position reaches a specified value.

The playback thread is automatically blocked from making further progress after reaching this position and will only be unblocked by other run()/play().untilXXX(...) method chains, custom runMainLooperUntil conditions, or an explicit unblockThreadsWaitingForProgressOnCurrentLooper on the main thread.

Throws
androidx.media3.common.PlaybackException

If a playback error occurs.

java.lang.IllegalStateException

If non-fatal playback errors occur, and aren't ignored (the non-fatal exceptions will be attached with addSuppressed).

java.util.concurrent.TimeoutException

If the default timeout is exceeded.

untilPositionAtLeast

fun untilPositionAtLeast(positionMs: Long): Unit

Runs tasks of the main Looper until getContentPosition reaches at least the specified position in the current media item, or an error occurs.

Use untilPosition instead if the test needs to advance the player until the internal playback thread reaches a specific position exactly.

Throws
androidx.media3.common.PlaybackException

If a playback error occurs.

java.lang.IllegalStateException

If non-fatal playback errors occur, and aren't ignored (the non-fatal exceptions will be attached with addSuppressed).

java.util.concurrent.TimeoutException

If the default timeout is exceeded.

untilPositionAtLeast

fun untilPositionAtLeast(mediaItemIndex: Int, positionMs: Long): Unit

Runs tasks of the main Looper until getCurrentMediaItemIndex equals the specified index and getContentPosition reaches at least the specified position, or an error occurs.

Use untilPosition instead if the test needs to advance the player until the internal playback thread reaches a specific position exactly.

Throws
androidx.media3.common.PlaybackException

If a playback error occurs.

java.lang.IllegalStateException

If non-fatal playback errors occur, and aren't ignored (the non-fatal exceptions will be attached with addSuppressed).

java.util.concurrent.TimeoutException

If the default timeout is exceeded.

untilSleepingForOffloadBecomes

fun untilSleepingForOffloadBecomes(expectedSleepingForOffload: Boolean): Unit

Runs tasks of the main Looper until isSleepingForOffload matches the expected value, or an error occurs.

Throws
androidx.media3.common.PlaybackException

If a playback error occurs.

java.lang.IllegalStateException

If non-fatal playback errors occur, and aren't ignored (the non-fatal exceptions will be attached with addSuppressed).

java.util.concurrent.TimeoutException

If the default timeout is exceeded.

untilStartOfMediaItem

fun untilStartOfMediaItem(mediaItemIndex: Int): Unit

Runs tasks of the main Looper until the internal playback thread reaches the start of the specified media item or a playback error occurs.

Use untilMediaItemIndex instead if the test needs to advance the player until the publicly visible media item index reaches a specified value.

The playback thread is automatically blocked from making further progress after reaching the media item and will only be unblocked by other run()/play().untilXXX(...) method chains, custom runMainLooperUntil conditions, or an explicit unblockThreadsWaitingForProgressOnCurrentLooper on the main thread.

Parameters
mediaItemIndex: Int

The index of the media item.

Throws
androidx.media3.common.PlaybackException

If a playback error occurs.

java.lang.IllegalStateException

If non-fatal playback errors occur, and aren't ignored (the non-fatal exceptions will be attached with addSuppressed).

java.util.concurrent.TimeoutException

If the default timeout is exceeded.