Class TestPlayerRunHelper
- java.lang.Object
-
- com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
playUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs)
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified position or a playback error occurs, and then pauses theplayer
.static void
playUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex)
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified media item or a playback error occurs, and then pauses theplayer
.static ExoPlaybackException
runUntilError(ExoPlayer player)
Runs tasks of the mainLooper
until a player error occurs.static void
runUntilIsLoading(Player player, boolean expectedIsLoading)
Runs tasks of the mainLooper
untilPlayer.isLoading()
matches the expected value or a playback error occurs.static void
runUntilPendingCommandsAreFullyHandled(ExoPlayer player)
Runs tasks of the mainLooper
until the player completely handled all previously issued commands on the internal playback thread.static void
runUntilPlaybackState(Player player, @com.google.android.exoplayer2.Player.State int expectedState)
Runs tasks of the mainLooper
untilPlayer.getPlaybackState()
matches the expected state or a playback error occurs.static void
runUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady)
Runs tasks of the mainLooper
untilPlayer.getPlayWhenReady()
matches the expected value or a playback error occurs.static void
runUntilPositionDiscontinuity(Player player, @com.google.android.exoplayer2.Player.DiscontinuityReason int expectedReason)
Runs tasks of the mainLooper
untilPlayer.Listener.onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)
is called with the specifiedPlayer.DiscontinuityReason
or a playback error occurs.static void
runUntilRenderedFirstFrame(ExoPlayer player)
Runs tasks of the mainLooper
until thePlayer.Listener.onRenderedFirstFrame()
callback is called or a playback error occurs.static void
runUntilSleepingForOffload(ExoPlayer player, boolean expectedSleepForOffload)
Runs tasks of the mainLooper
untilExoPlayer.AudioOffloadListener.onExperimentalSleepingForOffloadChanged(boolean)
is called or a playback error occurs.static Timeline
runUntilTimelineChanged(Player player)
Runs tasks of the mainLooper
until a timeline change or a playback error occurs.static void
runUntilTimelineChanged(Player player, Timeline expectedTimeline)
Runs tasks of the mainLooper
untilPlayer.getCurrentTimeline()
matches the expected timeline or a playback error occurs.
-
-
-
Method Detail
-
runUntilPlaybackState
public static void runUntilPlaybackState(Player player, @State @com.google.android.exoplayer2.Player.State int expectedState) throws TimeoutException
Runs tasks of the mainLooper
untilPlayer.getPlaybackState()
matches the expected state or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.expectedState
- The expectedPlayer.State
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilPlayWhenReady
public static void runUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady) throws TimeoutException
Runs tasks of the mainLooper
untilPlayer.getPlayWhenReady()
matches the expected value or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.expectedPlayWhenReady
- The expected value forPlayer.getPlayWhenReady()
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilIsLoading
public static void runUntilIsLoading(Player player, boolean expectedIsLoading) throws TimeoutException
Runs tasks of the mainLooper
untilPlayer.isLoading()
matches the expected value or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.expectedIsLoading
- The expected value forPlayer.isLoading()
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilTimelineChanged
public static void runUntilTimelineChanged(Player player, Timeline expectedTimeline) throws TimeoutException
Runs tasks of the mainLooper
untilPlayer.getCurrentTimeline()
matches the expected timeline or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.expectedTimeline
- The expectedTimeline
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilTimelineChanged
public static Timeline runUntilTimelineChanged(Player player) throws TimeoutException
Runs tasks of the mainLooper
until a timeline change or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.- Returns:
- The new
Timeline
. - Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilPositionDiscontinuity
public static void runUntilPositionDiscontinuity(Player player, @DiscontinuityReason @com.google.android.exoplayer2.Player.DiscontinuityReason int expectedReason) throws TimeoutException
Runs tasks of the mainLooper
untilPlayer.Listener.onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)
is called with the specifiedPlayer.DiscontinuityReason
or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.expectedReason
- The expectedPlayer.DiscontinuityReason
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilError
public static ExoPlaybackException runUntilError(ExoPlayer player) throws TimeoutException
Runs tasks of the mainLooper
until a player error occurs.- Parameters:
player
- ThePlayer
.- Returns:
- The raised
ExoPlaybackException
. - Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilSleepingForOffload
public static void runUntilSleepingForOffload(ExoPlayer player, boolean expectedSleepForOffload) throws TimeoutException
Runs tasks of the mainLooper
untilExoPlayer.AudioOffloadListener.onExperimentalSleepingForOffloadChanged(boolean)
is called or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.expectedSleepForOffload
- The expected sleep of offload state.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilRenderedFirstFrame
public static void runUntilRenderedFirstFrame(ExoPlayer player) throws TimeoutException
Runs tasks of the mainLooper
until thePlayer.Listener.onRenderedFirstFrame()
callback is called or a playback error occurs.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
..- Parameters:
player
- ThePlayer
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
playUntilPosition
public static void playUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs) throws TimeoutException
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified position or a playback error occurs, and then pauses theplayer
.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.mediaItemIndex
- The index of the media item.positionMs
- The position within the media item, in milliseconds.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
playUntilStartOfMediaItem
public static void playUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex) throws TimeoutException
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified media item or a playback error occurs, and then pauses theplayer
.If a playback error occurs it will be thrown wrapped in an
IllegalStateException
.- Parameters:
player
- ThePlayer
.mediaItemIndex
- The index of the media item.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilPendingCommandsAreFullyHandled
public static void runUntilPendingCommandsAreFullyHandled(ExoPlayer player) throws TimeoutException
Runs tasks of the mainLooper
until the player completely handled all previously issued commands on the internal playback thread.- Parameters:
player
- ThePlayer
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
-