TestPlayerRunHelper.CompositionPlayerRunResult


class TestPlayerRunHelper.CompositionPlayerRunResult : TestPlayerRunHelper.PlayerRunResult


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

Summary

Public functions

TestPlayerRunHelper.CompositionPlayerRunResult!

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 completely handled all previously issued commands on the internal playback thread.

TestPlayerRunHelper.CompositionPlayerRunResult!
withTimeoutMs(timeoutMs: Long)

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

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
untilAdCompleted(adGroupIndex: Int, adIndexInAdGroup: Int)

Runs tasks of the main Looper until the specified ad finishes playing and transitions with DISCONTINUITY_REASON_AUTO_TRANSITION, or an error occurs.

Unit
untilAdGroupEnded(adGroupIndex: Int)

Runs tasks of the main Looper until playback exits the specified adGroupIndex back to content (newPosition.adGroupIndex == C.INDEX_UNSET), or an error occurs.

Unit
untilBackgroundThreadCondition(
    clock: Clock!,
    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 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
untilPlayingAd(adGroupIndex: Int, adIndexInAdGroup: Int)

Runs tasks of the main Looper until isPlayingAd is true for the specified adGroupIndex and adIndexInAdGroup, or an 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.

Public functions

ignoringNonFatalErrors

fun ignoringNonFatalErrors(): TestPlayerRunHelper.CompositionPlayerRunResult!

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 Looper 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 Looper 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 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(): 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.

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.

withTimeoutMs

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

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.