Test: Fix missed latch exceptions.

Catch timeouts, and general errors in the case of an InterupptedException.

PiperOrigin-RevId: 545219647
This commit is contained in:
huangdarwin 2023-07-03 14:41:58 +00:00 committed by microkatz
parent 5e96d355e1
commit 1fce0cfd4d

View File

@ -306,6 +306,7 @@ public final class VideoFrameProcessorTestRunner {
@Override @Override
public void onError(VideoFrameProcessingException exception) { public void onError(VideoFrameProcessingException exception) {
videoFrameProcessingException.set(exception); videoFrameProcessingException.set(exception);
checkNotNull(videoFrameProcessingEndedLatch).countDown();
} }
@Override @Override
@ -376,15 +377,18 @@ public final class VideoFrameProcessorTestRunner {
public void endFrameProcessing(long videoFrameProcessingWaitTimeMs) throws InterruptedException { public void endFrameProcessing(long videoFrameProcessingWaitTimeMs) throws InterruptedException {
videoFrameProcessor.signalEndOfInput(); videoFrameProcessor.signalEndOfInput();
@Nullable Exception endFrameProcessingException = null;
try { try {
checkNotNull(videoFrameProcessingEndedLatch) if (!checkNotNull(videoFrameProcessingEndedLatch)
.await(videoFrameProcessingWaitTimeMs, MILLISECONDS); .await(videoFrameProcessingWaitTimeMs, MILLISECONDS)) {
} catch (InterruptedException e) { endFrameProcessingException =
// Report videoFrameProcessingException before potentially reporting a timeout new IllegalStateException("Video frame processing timed out.");
// InterruptedException.
assertThat(videoFrameProcessingException.get()).isNull();
throw e;
} }
} catch (InterruptedException e) {
endFrameProcessingException = e;
}
assertThat(videoFrameProcessingException.get()).isNull();
assertThat(endFrameProcessingException).isNull();
} }
/** /**