Don't always wait for action schedule in ExoPlayerTestRunner.
Unconditionally waiting for the action schedule to finish in ExoPlayerTestRunner doesn't work if the action schedule is not intended to be finished. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=177024139
This commit is contained in:
parent
ee26da682c
commit
95de9c96fe
@ -65,7 +65,7 @@ public final class ExoPlayerTest extends TestCase {
|
||||
.build();
|
||||
ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder()
|
||||
.setTimeline(timeline).setRenderers(renderer).setActionSchedule(actionSchedule)
|
||||
.build().start().blockUntilEnded(TIMEOUT_MS);
|
||||
.build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
|
||||
testRunner.assertNoPositionDiscontinuities();
|
||||
testRunner.assertTimelinesEqual(timeline);
|
||||
assertEquals(0, renderer.formatReadCount);
|
||||
|
@ -17,7 +17,6 @@ package com.google.android.exoplayer2.testutil;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.SystemClock;
|
||||
import android.support.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.DefaultLoadControl;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
@ -405,9 +404,9 @@ public final class ExoPlayerTestRunner extends Player.DefaultEventListener
|
||||
|
||||
/**
|
||||
* Blocks the current thread until the test runner finishes. A test is deemed to be finished when
|
||||
* the action schedule finished and the playback state transitioned to {@link Player#STATE_ENDED}
|
||||
* or {@link Player#STATE_IDLE} for the specified number of times. The test also finishes when an
|
||||
* {@link ExoPlaybackException} is thrown.
|
||||
* the playback state transitioned to {@link Player#STATE_ENDED} or {@link Player#STATE_IDLE} for
|
||||
* the specified number of times. The test also finishes when an {@link ExoPlaybackException} is
|
||||
* thrown.
|
||||
*
|
||||
* @param timeoutMs The maximum time to wait for the test runner to finish. If this time elapsed
|
||||
* the method will throw a {@link TimeoutException}.
|
||||
@ -415,13 +414,6 @@ public final class ExoPlayerTestRunner extends Player.DefaultEventListener
|
||||
* @throws Exception If any exception occurred during playback, release, or due to a timeout.
|
||||
*/
|
||||
public ExoPlayerTestRunner blockUntilEnded(long timeoutMs) throws Exception {
|
||||
long deadlineMs = SystemClock.elapsedRealtime() + timeoutMs;
|
||||
try {
|
||||
blockUntilActionScheduleFinished(timeoutMs);
|
||||
} catch (TimeoutException error) {
|
||||
exception = error;
|
||||
}
|
||||
timeoutMs = Math.max(0, deadlineMs - SystemClock.elapsedRealtime());
|
||||
if (!endedCountDownLatch.await(timeoutMs, TimeUnit.MILLISECONDS)) {
|
||||
exception = new TimeoutException("Test playback timed out waiting for playback to end.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user