mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +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 {
|
||||
val player = PlayerWithListeners(TestExoPlayerBuilder(context).build())
|
||||
val exceptionFromListen = async {
|
||||
try {
|
||||
player.listen { events ->
|
||||
if (Player.EVENT_VOLUME_CHANGED in events) {
|
||||
throw IllegalStateException("Volume event!")
|
||||
runCatching {
|
||||
player.listen { events ->
|
||||
if (Player.EVENT_VOLUME_CHANGED in events) {
|
||||
throw IllegalStateException("Volume event!")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (expected: IllegalStateException) {
|
||||
expected
|
||||
}
|
||||
.exceptionOrNull()
|
||||
}
|
||||
// Wait for the Player.Listener to be registered inside player.listen
|
||||
testScheduler.runCurrent()
|
||||
|
|
|
|||
Loading…
Reference in a new issue