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 voidplayUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs)CallsPlayer.play(), runs tasks of the mainLooperuntil theplayerreaches the specified position or a playback error occurs, and then pauses theplayer.static voidplayUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex)CallsPlayer.play(), runs tasks of the mainLooperuntil theplayerreaches the specified media item or a playback error occurs, and then pauses theplayer.static ExoPlaybackExceptionrunUntilError(ExoPlayer player)Runs tasks of the mainLooperuntil a player error occurs.static voidrunUntilIsLoading(Player player, boolean expectedIsLoading)Runs tasks of the mainLooperuntilPlayer.isLoading()matches the expected value or a playback error occurs.static voidrunUntilPendingCommandsAreFullyHandled(ExoPlayer player)Runs tasks of the mainLooperuntil the player completely handled all previously issued commands on the internal playback thread.static voidrunUntilPlaybackState(Player player, @com.google.android.exoplayer2.Player.State int expectedState)Runs tasks of the mainLooperuntilPlayer.getPlaybackState()matches the expected state or a playback error occurs.static voidrunUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady)Runs tasks of the mainLooperuntilPlayer.getPlayWhenReady()matches the expected value or a playback error occurs.static voidrunUntilPositionDiscontinuity(Player player, @com.google.android.exoplayer2.Player.DiscontinuityReason int expectedReason)Runs tasks of the mainLooperuntilPlayer.Listener.onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)is called with the specifiedPlayer.DiscontinuityReasonor a playback error occurs.static voidrunUntilRenderedFirstFrame(ExoPlayer player)Runs tasks of the mainLooperuntil thePlayer.Listener.onRenderedFirstFrame()callback is called or a playback error occurs.static voidrunUntilSleepingForOffload(ExoPlayer player, boolean expectedSleepForOffload)Runs tasks of the mainLooperuntilExoPlayer.AudioOffloadListener.onExperimentalSleepingForOffloadChanged(boolean)is called or a playback error occurs.static TimelinerunUntilTimelineChanged(Player player)Runs tasks of the mainLooperuntil a timeline change or a playback error occurs.static voidrunUntilTimelineChanged(Player player, Timeline expectedTimeline)Runs tasks of the mainLooperuntilPlayer.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 mainLooperuntilPlayer.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 timeoutis exceeded.
-
runUntilPlayWhenReady
public static void runUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady) throws TimeoutException
Runs tasks of the mainLooperuntilPlayer.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 timeoutis exceeded.
-
runUntilIsLoading
public static void runUntilIsLoading(Player player, boolean expectedIsLoading) throws TimeoutException
Runs tasks of the mainLooperuntilPlayer.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 timeoutis exceeded.
-
runUntilTimelineChanged
public static void runUntilTimelineChanged(Player player, Timeline expectedTimeline) throws TimeoutException
Runs tasks of the mainLooperuntilPlayer.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 timeoutis exceeded.
-
runUntilTimelineChanged
public static Timeline runUntilTimelineChanged(Player player) throws TimeoutException
Runs tasks of the mainLooperuntil 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 timeoutis exceeded.
-
runUntilPositionDiscontinuity
public static void runUntilPositionDiscontinuity(Player player, @DiscontinuityReason @com.google.android.exoplayer2.Player.DiscontinuityReason int expectedReason) throws TimeoutException
Runs tasks of the mainLooperuntilPlayer.Listener.onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)is called with the specifiedPlayer.DiscontinuityReasonor 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 timeoutis exceeded.
-
runUntilError
public static ExoPlaybackException runUntilError(ExoPlayer player) throws TimeoutException
Runs tasks of the mainLooperuntil a player error occurs.- Parameters:
player- ThePlayer.- Returns:
- The raised
ExoPlaybackException. - Throws:
TimeoutException- If thedefault timeoutis exceeded.
-
runUntilSleepingForOffload
public static void runUntilSleepingForOffload(ExoPlayer player, boolean expectedSleepForOffload) throws TimeoutException
Runs tasks of the mainLooperuntilExoPlayer.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 timeoutis exceeded.
-
runUntilRenderedFirstFrame
public static void runUntilRenderedFirstFrame(ExoPlayer player) throws TimeoutException
Runs tasks of the mainLooperuntil 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 timeoutis exceeded.
-
playUntilPosition
public static void playUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs) throws TimeoutException
CallsPlayer.play(), runs tasks of the mainLooperuntil theplayerreaches 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 timeoutis exceeded.
-
playUntilStartOfMediaItem
public static void playUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex) throws TimeoutException
CallsPlayer.play(), runs tasks of the mainLooperuntil theplayerreaches 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 timeoutis exceeded.
-
runUntilPendingCommandsAreFullyHandled
public static void runUntilPendingCommandsAreFullyHandled(ExoPlayer player) throws TimeoutException
Runs tasks of the mainLooperuntil the player completely handled all previously issued commands on the internal playback thread.- Parameters:
player- ThePlayer.- Throws:
TimeoutException- If thedefault timeoutis exceeded.
-
-