PlayerListener: do not swallow exceptions thrown before waiting

If an error occurred in the player before the test was calling one of
the waitUntilSomething() methods, a timeout exception was thrown instead
of the actual error.

PiperOrigin-RevId: 713292292
This commit is contained in:
kimvde 2025-01-08 08:00:16 -08:00 committed by Copybara-Service
parent b321c8d3bd
commit d9776e74c8

View File

@ -130,9 +130,15 @@ public final class PlayerTestListener implements Player.Listener, AnalyticsListe
private void waitOrThrow(ConditionVariable conditionVariable)
throws TimeoutException, PlaybackException {
if (!conditionVariable.block(testTimeoutMs)) {
maybeThrowPlaybackException();
boolean conditionVariableTimedOut = !conditionVariable.block(testTimeoutMs);
maybeThrowPlaybackException();
if (conditionVariableTimedOut) {
throw new TimeoutException();
}
}
private void maybeThrowPlaybackException() throws PlaybackException {
@Nullable PlaybackException playbackException = this.playbackException.get();
if (playbackException != null) {
throw playbackException;