TestPlayerRunHelper.PlayerRunResult


public class TestPlayerRunHelper.PlayerRunResult

Known direct subclasses
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

Protected fields

boolean
final boolean

Public methods

TestPlayerRunHelper.PlayerRunResult

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

void

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

final void
untilLoadingIs(boolean expectedIsLoading)

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

final void
untilPlayWhenReadyIs(boolean expectedPlayWhenReady)

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.

final void

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

final void
untilState(@Player.State int expectedState)

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

final Timeline

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

final void
untilTimelineChangesTo(Timeline expectedTimeline)

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

Protected methods

final void

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

Protected fields

hasBeenUsed

protected boolean hasBeenUsed

playBeforeWaiting

protected final boolean playBeforeWaiting

Public methods

ignoringNonFatalErrors

public TestPlayerRunHelper.PlayerRunResult ignoringNonFatalErrors()

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

public void untilFirstFrameIsRendered()

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 default timeout is exceeded.

untilLoadingIs

public final void untilLoadingIs(boolean expectedIsLoading)

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 default timeout is exceeded.

untilPlayWhenReadyIs

public final void untilPlayWhenReadyIs(boolean expectedPlayWhenReady)

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 default timeout is exceeded.

untilPlayerError

public PlaybackException untilPlayerError()

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

Non-fatal errors are always ignored.

Returns
PlaybackException

The raised PlaybackException.

untilPositionDiscontinuityWithReason

public final void untilPositionDiscontinuityWithReason(
    @Player.DiscontinuityReason int expectedReason
)

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 default timeout is exceeded.

untilState

public final void untilState(@Player.State int expectedState)

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 default timeout is exceeded.

untilTimelineChanges

public final Timeline untilTimelineChanges()

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 default timeout is exceeded.

untilTimelineChangesTo

public final void untilTimelineChangesTo(Timeline expectedTimeline)

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 default timeout is exceeded.

Protected methods

runUntil

protected final void runUntil(Supplier<Boolean> predicate)

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