File tree Expand file tree Collapse file tree 2 files changed +2
-34
lines changed
pillarbox-player-testutils/src/main/java/ch/srgssr/pillarbox/player/test/utils
pillarbox-player/src/test/java/ch/srgssr/pillarbox/player Expand file tree Collapse file tree 2 files changed +2
-34
lines changed Original file line number Diff line number Diff line change @@ -105,36 +105,4 @@ object TestPillarboxRunHelper {
105105 player.currentPosition >= position.inWholeMilliseconds
106106 }
107107 }
108-
109- /* *
110- * Run and wait until [Player.isPlaying] is [isPlaying].
111-
112- * If a playback error occurs, it will be thrown wrapped in an [IllegalStateException].
113- *
114- * @param player The [Player].
115- * @param isPlaying The expected value of [Player.isPlaying].
116-
117- * @throws TimeoutException If the [RobolectricUtil.DEFAULT_TIMEOUT_MS] is exceeded.
118- */
119- @Throws(TimeoutException ::class )
120- fun runUntilIsPlaying (player : Player , isPlaying : Boolean ) {
121- verifyMainTestThread(player)
122- if (player is ExoPlayer ) {
123- verifyPlaybackThreadIsAlive(player)
124- }
125- val receivedCallback = AtomicBoolean (false )
126- val listener = object : Player .Listener {
127- override fun onIsPlayingChanged (actual : Boolean ) {
128- if (actual == isPlaying) {
129- receivedCallback.set(true )
130- }
131- }
132- }
133- player.addListener(listener)
134- RobolectricUtil .runMainLooperUntil { receivedCallback.get() || player.playerError != null }
135- player.removeListener(listener)
136- if (player.playerError != null ) {
137- throw IllegalStateException (player.playerError)
138- }
139- }
140108}
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ import android.os.Looper
99import androidx.media3.common.MediaItem
1010import androidx.media3.common.Player
1111import androidx.media3.test.utils.FakeClock
12+ import androidx.media3.test.utils.robolectric.TestPlayerRunHelper
1213import androidx.test.core.app.ApplicationProvider
13- import ch.srgssr.pillarbox.player.test.utils.TestPillarboxRunHelper
1414import org.junit.runner.RunWith
1515import org.robolectric.ParameterizedRobolectricTestRunner
1616import org.robolectric.ParameterizedRobolectricTestRunner.Parameters
@@ -54,7 +54,7 @@ class IsPlayingAllTypeOfContentTest(
5454 player.prepare()
5555 player.play()
5656
57- TestPillarboxRunHelper .runUntilIsPlaying (player, isPlaying = true )
57+ TestPlayerRunHelper .play (player).untilBackgroundThreadCondition { player. isPlaying }
5858
5959 assertEquals(Player .STATE_READY , player.playbackState)
6060 assertTrue(player.isPlaying)
You can’t perform that action at this time.
0 commit comments