mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Use runCatching instead of try/catch in PlayerExtensionsTest
PiperOrigin-RevId: 661992546
This commit is contained in:
parent
a76ff16179
commit
ef6cb5d913
1 changed files with 6 additions and 7 deletions
|
|
@ -113,15 +113,14 @@ class PlayerExtensionsTest {
|
||||||
fun playerListen_onEventsThrowsException_bubblesOutAndUnregistersListener() = runTest {
|
fun playerListen_onEventsThrowsException_bubblesOutAndUnregistersListener() = runTest {
|
||||||
val player = PlayerWithListeners(TestExoPlayerBuilder(context).build())
|
val player = PlayerWithListeners(TestExoPlayerBuilder(context).build())
|
||||||
val exceptionFromListen = async {
|
val exceptionFromListen = async {
|
||||||
try {
|
runCatching {
|
||||||
player.listen { events ->
|
player.listen { events ->
|
||||||
if (Player.EVENT_VOLUME_CHANGED in events) {
|
if (Player.EVENT_VOLUME_CHANGED in events) {
|
||||||
throw IllegalStateException("Volume event!")
|
throw IllegalStateException("Volume event!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (expected: IllegalStateException) {
|
.exceptionOrNull()
|
||||||
expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Wait for the Player.Listener to be registered inside player.listen
|
// Wait for the Player.Listener to be registered inside player.listen
|
||||||
testScheduler.runCurrent()
|
testScheduler.runCurrent()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue