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 {
105
105
player.currentPosition >= position.inWholeMilliseconds
106
106
}
107
107
}
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
- }
140
108
}
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ import android.os.Looper
9
9
import androidx.media3.common.MediaItem
10
10
import androidx.media3.common.Player
11
11
import androidx.media3.test.utils.FakeClock
12
+ import androidx.media3.test.utils.robolectric.TestPlayerRunHelper
12
13
import androidx.test.core.app.ApplicationProvider
13
- import ch.srgssr.pillarbox.player.test.utils.TestPillarboxRunHelper
14
14
import org.junit.runner.RunWith
15
15
import org.robolectric.ParameterizedRobolectricTestRunner
16
16
import org.robolectric.ParameterizedRobolectricTestRunner.Parameters
@@ -54,7 +54,7 @@ class IsPlayingAllTypeOfContentTest(
54
54
player.prepare()
55
55
player.play()
56
56
57
- TestPillarboxRunHelper .runUntilIsPlaying (player, isPlaying = true )
57
+ TestPlayerRunHelper .play (player).untilBackgroundThreadCondition { player. isPlaying }
58
58
59
59
assertEquals(Player .STATE_READY , player.playbackState)
60
60
assertTrue(player.isPlaying)
You can’t perform that action at this time.
0 commit comments