From d32181e4e9538d65b061edb3e3f60a7df13e895f Mon Sep 17 00:00:00 2001 From: tonihei Date: Mon, 29 Jan 2018 04:30:55 -0800 Subject: [PATCH] Use more realistic timeline window duration for playback unit tests. 100ms is unrealistically short and, for example, causes the player to buffer many periods ahead when looping. Previously this was not feasible, because ExoPlayerTest as instrumentation test actually needed to wait for the realtime playback duration. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183646772 --- .../java/com/google/android/exoplayer2/ExoPlayerTest.java | 6 +++++- .../google/android/exoplayer2/testutil/FakeTimeline.java | 6 ++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java index 0146f036f2..3855d5ed2a 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java @@ -165,7 +165,11 @@ public final class ExoPlayerTest { */ @Test public void testReadAheadToEndDoesNotResetRenderer() throws Exception { - Timeline timeline = new FakeTimeline(/* windowCount= */ 3); + // Use sufficiently short periods to ensure the player attempts to read all at once. + TimelineWindowDefinition windowDefinition = + new TimelineWindowDefinition( + /* isSeekable= */ false, /* isDynamic= */ false, /* durationUs= */ 100_000); + Timeline timeline = new FakeTimeline(windowDefinition, windowDefinition, windowDefinition); final FakeRenderer videoRenderer = new FakeRenderer(Builder.VIDEO_FORMAT); FakeMediaClockRenderer audioRenderer = new FakeMediaClockRenderer(Builder.AUDIO_FORMAT) { diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java index 797c09d6b6..0557a138e1 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java @@ -31,10 +31,8 @@ public final class FakeTimeline extends Timeline { */ public static final class TimelineWindowDefinition { - /** - * Default test window duration in microseconds. - */ - public static final int DEFAULT_WINDOW_DURATION_US = 100_000; + /** Default test window duration in microseconds. */ + public static final long DEFAULT_WINDOW_DURATION_US = 10 * C.MICROS_PER_SECOND; public final int periodCount; public final Object id;