# TestPlayerRunHelper

Artifact: [androidx.media3:media3-test-utils-robolectric](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/robolectric/TestPlayerRunHelper.java+class:androidx.media3.test.utils.robolectric.TestPlayerRunHelper)

*** ** * ** ***


```
@UnstableApi
public final class TestPlayerRunHelper
```

<br />

*** ** * ** ***

Helper methods to block the calling thread until the provided `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer` instance reaches a particular state.

This class has two usage modes:

- Fluent method chaining, e.g. `
  run(player).ignoringNonFatalErrors().untilState(STATE_ENDED)`.
- Single method call, e.g. `runUntilPlaybackState(player, STATE_ENDED)`.

New usages should prefer the fluent method chaining, and new functionality will only be added to this form. The older single methods will be kept for backwards compatibility.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult extends https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` A `https://developer.android.com/reference/androidx/media3/transformer/CompositionPlayer` specific subclass of `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult`, giving access to conditions that only make sense for `https://developer.android.com/reference/androidx/media3/transformer/CompositionPlayer`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult extends https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` An `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer` specific subclass of `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult`, giving access to conditions that only make sense for the `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer` interface. |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` Intermediate type that allows callers to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met. |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.transformer.CompositionPlayer)(https://developer.android.com/reference/androidx/media3/transformer/CompositionPlayer player)` Entry point for a fluent "wait for condition X" assertion. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player)` Entry point for a fluent "wait for condition X" assertion. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)(https://developer.android.com/reference/androidx/media3/common/Player player)` Entry point for a fluent "wait for condition X" assertion. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#play(androidx.media3.transformer.CompositionPlayer)(https://developer.android.com/reference/androidx/media3/transformer/CompositionPlayer player)` Entry point for a fluent "start playback and wait for condition X" assertion. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#play(androidx.media3.exoplayer.ExoPlayer)(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player)` Entry point for a fluent "start playback and wait for condition X" assertion. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#play(androidx.media3.common.Player)(https://developer.android.com/reference/androidx/media3/common/Player player)` Entry point for a fluent "start playback and wait for condition X" assertion. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#playUntilPosition(androidx.media3.exoplayer.ExoPlayer,int,long)(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player, int mediaItemIndex, long positionMs)` Calls `https://developer.android.com/reference/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the specified position or an error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#playUntilStartOfMediaItem(androidx.media3.exoplayer.ExoPlayer,int)(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player, int mediaItemIndex)` Calls `https://developer.android.com/reference/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the start of the specified media item or a playback error occurs. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult` | `@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper") [run](https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.exoplayer.ExoPlayer))(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` instead. <br /> |
| `static https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` | `@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper") [run](https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.common.Player))(https://developer.android.com/reference/androidx/media3/common/Player player)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` instead. <br /> |
| `static https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlaybackException` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilError(androidx.media3.exoplayer.ExoPlayer)(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a player error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilIsLoading(androidx.media3.common.Player,boolean)(https://developer.android.com/reference/androidx/media3/common/Player player, boolean expectedIsLoading)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#isLoading()` matches the expected value or an error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPendingCommandsAreFullyHandled(androidx.media3.exoplayer.ExoPlayer)(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the player completely handled all previously issued commands on the internal playback thread. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPlayWhenReady(androidx.media3.common.Player,boolean)(https://developer.android.com/reference/androidx/media3/common/Player player, boolean expectedPlayWhenReady)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#getPlayWhenReady()` matches the expected value or an error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPlaybackState(androidx.media3.common.Player,int)(https://developer.android.com/reference/androidx/media3/common/Player player, @https://developer.android.com/reference/androidx/media3/common/Player.State int expectedState)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` matches the expected state or an error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPositionDiscontinuity(androidx.media3.common.Player,int)( https://developer.android.com/reference/androidx/media3/common/Player player, @https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason int expectedReason )` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)` is called with the specified `https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason` or an error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilRenderedFirstFrame(androidx.media3.exoplayer.ExoPlayer)(https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onRenderedFirstFrame()` is called or an error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilSleepingForOffload(androidx.media3.exoplayer.ExoPlayer,boolean)( https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player, boolean expectedSleepForOffload )` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#isSleepingForOffload()` matches the expected value, or an error occurs. |
| `static https://developer.android.com/reference/androidx/media3/common/Timeline` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilTimelineChanged(androidx.media3.common.Player)(https://developer.android.com/reference/androidx/media3/common/Player player)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a timeline change or an error occurs. |
| `static void` | `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilTimelineChanged(androidx.media3.common.Player,androidx.media3.common.Timeline)(https://developer.android.com/reference/androidx/media3/common/Player player, https://developer.android.com/reference/androidx/media3/common/Timeline expectedTimeline)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` matches the expected timeline or an error occurs. |

## Public methods

### advance

```
public static TestPlayerRunHelper.CompositionPlayerRunResult advance(CompositionPlayer player)
```

Entry point for a fluent "wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

### advance

```
public static TestPlayerRunHelper.ExoPlayerRunResult advance(ExoPlayer player)
```

Entry point for a fluent "wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

### advance

```
public static TestPlayerRunHelper.PlayerRunResult advance(Player player)
```

Entry point for a fluent "wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

### play

```
public static TestPlayerRunHelper.CompositionPlayerRunResult play(CompositionPlayer player)
```

Entry point for a fluent "start playback and wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

This is the same as `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.transformer.CompositionPlayer)` but ensures `https://developer.android.com/reference/androidx/media3/common/BasePlayer#play()` is called before waiting in subsequent `untilXXX(...)` methods.

### play

```
public static TestPlayerRunHelper.ExoPlayerRunResult play(ExoPlayer player)
```

Entry point for a fluent "start playback and wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

This is the same as `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` but ensures `https://developer.android.com/reference/androidx/media3/common/Player#play()` is called before waiting in subsequent `untilXXX(...)` methods.

### play

```
public static TestPlayerRunHelper.PlayerRunResult play(Player player)
```

Entry point for a fluent "start playback and wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

This is the same as `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` but ensures `https://developer.android.com/reference/androidx/media3/common/Player#play()` is called before waiting in subsequent `untilXXX(...)` methods.

### playUntilPosition

```
public static void playUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs)
```

Calls `https://developer.android.com/reference/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the specified position or an error occurs.

Use `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilPositionAtLeast(long)` 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 `runUntil/playUntil...` methods, custom `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#runMainLooperUntil(com.google.common.base.Supplier<java.lang.Boolean>)` conditions or an explicit `https://developer.android.com/reference/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnCurrentLooper()` on the main thread.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilPosition(int,long)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `int mediaItemIndex` | The index of the media item. |
| `long positionMs` | The position within the media item, in milliseconds. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### playUntilStartOfMediaItem

```
public static void playUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex)
```

Calls `https://developer.android.com/reference/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the start of the specified media item or a playback error occurs.

Use `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilMediaItemIndex(int)` 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 `runUntil/playUntil...` methods, custom `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#runMainLooperUntil(com.google.common.base.Supplier<java.lang.Boolean>)` conditions or an explicit `https://developer.android.com/reference/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnCurrentLooper()` on the main thread.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilStartOfMediaItem(int)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `int mediaItemIndex` | The index of the media item. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### run

```
@InlineMe(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper")
public static TestPlayerRunHelper.ExoPlayerRunResult [run](https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.exoplayer.ExoPlayer))(ExoPlayer player)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` instead.

### run

```
@InlineMe(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper")
public static TestPlayerRunHelper.PlayerRunResult [run](https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.common.Player))(Player player)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` instead.

### runUntilError

```
public static ExoPlaybackException runUntilError(ExoPlayer player)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a player error occurs.

Non-fatal errors are ignored.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilPlayerError()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlaybackException` | The raised `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlaybackException`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilIsLoading

```
public static void runUntilIsLoading(Player player, boolean expectedIsLoading)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#isLoading()` matches the expected value or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilLoadingIs(boolean)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `boolean expectedIsLoading` | The expected value for `https://developer.android.com/reference/androidx/media3/common/Player#isLoading()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPendingCommandsAreFullyHandled

```
public static void runUntilPendingCommandsAreFullyHandled(ExoPlayer player)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the player completely handled all previously issued commands on the internal playback thread.

Both fatal and non-fatal errors are ignored.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player` | The `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPlayWhenReady

```
public static void runUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#getPlayWhenReady()` matches the expected value or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilPlayWhenReadyIs(boolean)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `boolean expectedPlayWhenReady` | The expected value for `https://developer.android.com/reference/androidx/media3/common/Player#getPlayWhenReady()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPlaybackState

```
public static void runUntilPlaybackState(Player player, @Player.State int expectedState)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackState()` matches the expected state or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilState(int)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `@https://developer.android.com/reference/androidx/media3/common/Player.State int expectedState` | The expected `https://developer.android.com/reference/androidx/media3/common/Player.State`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPositionDiscontinuity

```
public static void runUntilPositionDiscontinuity(
    Player player,
    @Player.DiscontinuityReason int expectedReason
)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)` is called with the specified `https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason` or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilPositionDiscontinuityWithReason(int)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `@https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason int expectedReason` | The expected `https://developer.android.com/reference/androidx/media3/common/Player.DiscontinuityReason`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilRenderedFirstFrame

```
public static void runUntilRenderedFirstFrame(ExoPlayer player)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onRenderedFirstFrame()` is called or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilFirstFrameIsRendered()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilSleepingForOffload

```
public static void runUntilSleepingForOffload(
    ExoPlayer player,
    boolean expectedSleepForOffload
)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#isSleepingForOffload()` matches the expected value, or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilSleepingForOffloadBecomes(boolean)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `boolean expectedSleepForOffload` | The expected sleep of offload state. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilTimelineChanged

```
public static Timeline runUntilTimelineChanged(Player player)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a timeline change or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilTimelineChanges()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline` | The new `https://developer.android.com/reference/androidx/media3/common/Timeline`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilTimelineChanged

```
public static void runUntilTimelineChanged(Player player, Timeline expectedTimeline)
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/androidx/media3/common/Player#getCurrentTimeline()` matches the expected timeline or an error occurs.

If a fatal `https://developer.android.com/reference/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilTimelineChangesTo(androidx.media3.common.Timeline)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `https://developer.android.com/reference/androidx/media3/common/Timeline expectedTimeline` | The expected `https://developer.android.com/reference/androidx/media3/common/Timeline`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |