Commit 95de9c96 by tonihei Committed by Oliver Woodman

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
parent ee26da68
...@@ -65,7 +65,7 @@ public final class ExoPlayerTest extends TestCase { ...@@ -65,7 +65,7 @@ public final class ExoPlayerTest extends TestCase {
.build(); .build();
ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder() ExoPlayerTestRunner testRunner = new ExoPlayerTestRunner.Builder()
.setTimeline(timeline).setRenderers(renderer).setActionSchedule(actionSchedule) .setTimeline(timeline).setRenderers(renderer).setActionSchedule(actionSchedule)
.build().start().blockUntilEnded(TIMEOUT_MS); .build().start().blockUntilActionScheduleFinished(TIMEOUT_MS).blockUntilEnded(TIMEOUT_MS);
testRunner.assertNoPositionDiscontinuities(); testRunner.assertNoPositionDiscontinuities();
testRunner.assertTimelinesEqual(timeline); testRunner.assertTimelinesEqual(timeline);
assertEquals(0, renderer.formatReadCount); assertEquals(0, renderer.formatReadCount);
......
...@@ -17,7 +17,6 @@ package com.google.android.exoplayer2.testutil; ...@@ -17,7 +17,6 @@ package com.google.android.exoplayer2.testutil;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.os.SystemClock;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
...@@ -405,9 +404,9 @@ public final class ExoPlayerTestRunner extends Player.DefaultEventListener ...@@ -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 * 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} * the playback state transitioned to {@link Player#STATE_ENDED} or {@link Player#STATE_IDLE} for
* or {@link Player#STATE_IDLE} for the specified number of times. The test also finishes when an * the specified number of times. The test also finishes when an {@link ExoPlaybackException} is
* {@link ExoPlaybackException} is thrown. * thrown.
* *
* @param timeoutMs The maximum time to wait for the test runner to finish. If this time elapsed * @param timeoutMs The maximum time to wait for the test runner to finish. If this time elapsed
* the method will throw a {@link TimeoutException}. * the method will throw a {@link TimeoutException}.
...@@ -415,13 +414,6 @@ public final class ExoPlayerTestRunner extends Player.DefaultEventListener ...@@ -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. * @throws Exception If any exception occurred during playback, release, or due to a timeout.
*/ */
public ExoPlayerTestRunner blockUntilEnded(long timeoutMs) throws Exception { 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)) { if (!endedCountDownLatch.await(timeoutMs, TimeUnit.MILLISECONDS)) {
exception = new TimeoutException("Test playback timed out waiting for playback to end."); exception = new TimeoutException("Test playback timed out waiting for playback to end.");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment