Throw errors from WebvttPlaybackTest.stallUntilPlayerCondition

Before this change, if a playback error is thrown the test fails with a
timeout and no additional info:

```
java.util.concurrent.TimeoutException
	at androidx.media3.exoplayer.e2etest.WebvttPlaybackTest.stallPlayerUntilCondition(WebvttPlaybackTest.java:361)
```

After this change, the test failure includes a much more useful stack
trace, e.g. from 0352db9a37:

```
Caused by: java.lang.IllegalStateException: Legacy decoding is disabled, can't handle text/vtt samples (expected application/x-media3-cues).
	at androidx.media3.common.util.Assertions.checkState(Assertions.java:100)
	at androidx.media3.exoplayer.text.TextRenderer.assertLegacyDecodingEnabledIfRequired(TextRenderer.java:587)
	at androidx.media3.exoplayer.text.TextRenderer.onStreamChanged(TextRenderer.java:210)
```

PiperOrigin-RevId: 634672138
This commit is contained in:
ibaker 2024-05-17 01:31:13 -07:00 committed by Copybara-Service
parent d83e81f374
commit 282a944eb4

View File

@ -354,7 +354,9 @@ public class WebvttPlaybackTest {
private static void stallPlayerUntilCondition(ExoPlayer player, AtomicBoolean condition)
throws Exception {
long timeoutTimeMs = Clock.DEFAULT.currentTimeMillis() + RobolectricUtil.DEFAULT_TIMEOUT_MS;
while (!condition.get()) {
while (!condition.get()
&& (player.getPlaybackState() == Player.STATE_READY
|| player.getPlaybackState() == Player.STATE_BUFFERING)) {
// Trigger more work at the current time until the condition is fulfilled.
if (Clock.DEFAULT.currentTimeMillis() >= timeoutTimeMs) {
throw new TimeoutException();
@ -363,5 +365,8 @@ public class WebvttPlaybackTest {
player.play();
run(player).untilPendingCommandsAreFullyHandled();
}
if (player.getPlayerError() != null) {
throw player.getPlayerError();
}
}
}