TestPlayerRunHelper.PlayerRunResult


class TestPlayerRunHelper.PlayerRunResult

Known direct subclasses
TestPlayerRunHelper.CompositionPlayerRunResult

A CompositionPlayer specific subclass of PlayerRunResult, giving access to conditions that only make sense for CompositionPlayer.

TestPlayerRunHelper.ExoPlayerRunResult

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


Intermediate type that allows callers to run the main Looper until certain conditions are met.

If an error occurs while a untilXXX(...) method is waiting for the condition to become true, most methods will throw that error (exceptions to this are documented on specific methods below). Use ignoringNonFatalErrors to ignore non-fatal errors and only fail on fatal playback errors.

Instances of this class should only be used for a single untilXXX() invocation and not be re-used.

Summary

Public functions

TestPlayerRunHelper.PlayerRunResult!

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

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

Runs tasks of the main looper until all pending tasks in targetLooper have been handled and have propagated any updates to the main looper.

Unit
untilPlayWhenReadyIs(expectedPlayWhenReady: Boolean)

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

PlaybackException!

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

Unit
untilPlayingAdIs(expectedIsPlayingAd: Boolean)

Runs tasks of the main Looper until isPlayingAd ()} 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.

TestPlayerRunHelper.PlayerRunResult!
withTimeoutMs(timeoutMs: Long)

Returns a new instance where the untilXXX(...) methods use the given timeout.

Protected functions

Unit
runUntil(predicate: Supplier<Boolean!>!)

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

Public functions

ignoringNonFatalErrors

fun ignoringNonFatalErrors(): TestPlayerRunHelper.PlayerRunResult!

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).

untilFirstFrameIsRendered

fun untilFirstFrameIsRendered(): Unit

Runs tasks of the main Looper until onRenderedFirstFrame is called 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilLoadingIs

fun untilLoadingIs(expectedIsLoading: Boolean): Unit

Runs tasks of the main Looper until isLoading 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilPendingCommandsAreFullyHandled

fun untilPendingCommandsAreFullyHandled(clock: Clock!, targetLooper: Looper!): Unit

Runs tasks of the main looper until all pending tasks in targetLooper have been handled and have propagated any updates to the main looper.

Both fatal and non-fatal errors are always ignored.

Parameters
clock: Clock!

The player's Clock.

targetLooper: Looper!

The looper whose pending tasks to handle.

Throws
java.util.concurrent.TimeoutException

If the timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilPlayWhenReadyIs

fun untilPlayWhenReadyIs(expectedPlayWhenReady: Boolean): Unit

Runs tasks of the main Looper until getPlayWhenReady 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilPlayerError

fun untilPlayerError(): PlaybackException!

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

Non-fatal errors are always ignored.

Returns
PlaybackException!

The raised PlaybackException.

Throws
java.util.concurrent.TimeoutException

If the timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilPlayingAdIs

fun untilPlayingAdIs(expectedIsPlayingAd: Boolean): Unit

Runs tasks of the main Looper until isPlayingAd ()} 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilPositionDiscontinuityWithReason

fun untilPositionDiscontinuityWithReason(
    @Player.DiscontinuityReason expectedReason: Int
): Unit

Runs tasks of the main Looper until onPositionDiscontinuity is called with the specified Player.DiscontinuityReason 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilState

fun untilState(@Player.State expectedState: Int): Unit

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

Throws
androidx.media3.common.PlaybackException

If a fatal 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilTimelineChanges

fun untilTimelineChanges(): Timeline!

Runs tasks of the main Looper until a timeline change 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

untilTimelineChangesTo

fun untilTimelineChangesTo(expectedTimeline: Timeline!): Unit

Runs tasks of the main Looper until getCurrentTimeline matches the expected timeline 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 timeout is exceeded. The timeout is DEFAULT_TIMEOUT_MS by default, or a specific value if this instance is created via withTimeoutMs.

withTimeoutMs

fun withTimeoutMs(timeoutMs: Long): TestPlayerRunHelper.PlayerRunResult!

Returns a new instance where the untilXXX(...) methods use the given timeout.

If not set, the default timeout is DEFAULT_TIMEOUT_MS.

Parameters
timeoutMs: Long

The timeout in milliseconds.

Protected functions

runUntil

protected fun runUntil(predicate: Supplier<Boolean!>!): Unit

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

Protected properties

hasBeenUsed

protected val hasBeenUsedBoolean

playBeforeWaiting

protected val playBeforeWaitingBoolean

player

protected val playerPlayer!

throwNonFatalErrors

protected val throwNonFatalErrorsBoolean

timeoutMs

protected val timeoutMsLong