Class TestPlayerRunHelper
- java.lang.Object
-
- com.google.android.exoplayer2.robolectric.TestPlayerRunHelper
-
public class TestPlayerRunHelper extends Object
Helper methods to block the calling thread until the providedSimpleExoPlayer
instance reaches a particular state.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
playUntilPosition(ExoPlayer player, int windowIndex, long positionMs)
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified position and then pauses theplayer
.static void
playUntilStartOfWindow(ExoPlayer player, int windowIndex)
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified window and then pauses theplayer
.static ExoPlaybackException
runUntilError(Player player)
Runs tasks of the mainLooper
until a player error occurred.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, int expectedState)
Runs tasks of the mainLooper
untilPlayer.getPlaybackState()
matches the expected state.static void
runUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady)
Runs tasks of the mainLooper
untilPlayer.getPlayWhenReady()
matches the expected value.static void
runUntilPositionDiscontinuity(Player player, int expectedReason)
Runs tasks of the mainLooper
until aPlayer.EventListener.onPositionDiscontinuity(int)
callback with the specifiedPlayer.DiscontinuityReason
occurred.static boolean
runUntilReceiveOffloadSchedulingEnabledNewState(Player player)
Runs tasks of the mainLooper
until aPlayer.EventListener.onExperimentalOffloadSchedulingEnabledChanged(boolean)
callback occurred.static void
runUntilRenderedFirstFrame(SimpleExoPlayer player)
Runs tasks of the mainLooper
until theVideoListener.onRenderedFirstFrame()
callback has been called.static void
runUntilSleepingForOffload(Player player, boolean expectedSleepForOffload)
Runs tasks of the mainLooper
until aPlayer.EventListener.onExperimentalSleepingForOffloadChanged(boolean)
callback occurred.static Timeline
runUntilTimelineChanged(Player player)
Runs tasks of the mainLooper
until a timeline change occurred.static void
runUntilTimelineChanged(Player player, Timeline expectedTimeline)
Runs tasks of the mainLooper
untilPlayer.getCurrentTimeline()
matches the expected timeline.
-
-
-
Method Detail
-
runUntilPlaybackState
public static void runUntilPlaybackState(Player player, @State int expectedState) throws TimeoutException
Runs tasks of the mainLooper
untilPlayer.getPlaybackState()
matches the expected state.- 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.- Parameters:
player
- ThePlayer
.expectedPlayWhenReady
- The expected value forPlayer.getPlayWhenReady()
.- 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.- 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 occurred.- Parameters:
player
- ThePlayer
.- Returns:
- The new
Timeline
. - Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilPositionDiscontinuity
public static void runUntilPositionDiscontinuity(Player player, @DiscontinuityReason int expectedReason) throws TimeoutException
Runs tasks of the mainLooper
until aPlayer.EventListener.onPositionDiscontinuity(int)
callback with the specifiedPlayer.DiscontinuityReason
occurred.- Parameters:
player
- ThePlayer
.expectedReason
- The expectedPlayer.DiscontinuityReason
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilError
public static ExoPlaybackException runUntilError(Player player) throws TimeoutException
Runs tasks of the mainLooper
until a player error occurred.- Parameters:
player
- ThePlayer
.- Returns:
- The raised
ExoPlaybackException
. - Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilReceiveOffloadSchedulingEnabledNewState
public static boolean runUntilReceiveOffloadSchedulingEnabledNewState(Player player) throws TimeoutException
Runs tasks of the mainLooper
until aPlayer.EventListener.onExperimentalOffloadSchedulingEnabledChanged(boolean)
callback occurred.- Parameters:
player
- ThePlayer
.- Returns:
- The new offloadSchedulingEnabled state.
- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilSleepingForOffload
public static void runUntilSleepingForOffload(Player player, boolean expectedSleepForOffload) throws TimeoutException
Runs tasks of the mainLooper
until aPlayer.EventListener.onExperimentalSleepingForOffloadChanged(boolean)
callback occurred.- Parameters:
player
- ThePlayer
.expectedSleepForOffload
- The expected sleep of offload state.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
runUntilRenderedFirstFrame
public static void runUntilRenderedFirstFrame(SimpleExoPlayer player) throws TimeoutException
Runs tasks of the mainLooper
until theVideoListener.onRenderedFirstFrame()
callback has been called.- Parameters:
player
- ThePlayer
.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
playUntilPosition
public static void playUntilPosition(ExoPlayer player, int windowIndex, long positionMs) throws TimeoutException
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified position and then pauses theplayer
.- Parameters:
player
- ThePlayer
.windowIndex
- The window.positionMs
- The position within the window, in milliseconds.- Throws:
TimeoutException
- If thedefault timeout
is exceeded.
-
playUntilStartOfWindow
public static void playUntilStartOfWindow(ExoPlayer player, int windowIndex) throws TimeoutException
CallsPlayer.play()
, runs tasks of the mainLooper
until theplayer
reaches the specified window and then pauses theplayer
.- Parameters:
player
- ThePlayer
.windowIndex
- The window.- 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.
-
-