Commit 2e84360a by bachinger Committed by Marc Baechinger

Make period durations of FakeMultiPeriodLiveTimeline configurable

PiperOrigin-RevId: 522046876
parent ff1cd017
......@@ -15,6 +15,8 @@
*/
package com.google.android.exoplayer2;
import static com.google.android.exoplayer2.testutil.FakeMultiPeriodLiveTimeline.AD_PERIOD_DURATION_MS;
import static com.google.android.exoplayer2.testutil.FakeMultiPeriodLiveTimeline.PERIOD_DURATION_MS;
import static com.google.common.truth.Truth.assertThat;
import android.os.Bundle;
......@@ -437,10 +439,13 @@ public class TimelineTest {
public void periodIsLivePostrollPlaceholder_recognizesLivePostrollPlaceholder() {
FakeMultiPeriodLiveTimeline timeline =
new FakeMultiPeriodLiveTimeline(
/* availabilityStartTimeUs= */ 0,
/* availabilityStartTimeMs= */ 0,
/* liveWindowDurationUs= */ 60_000_000,
/* nowUs= */ 60_000_000,
/* adSequencePattern= */ new boolean[] {false, true, true},
/* periodDurationMsPattern= */ new long[] {
PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS
},
/* isContentTimeline= */ false,
/* populateAds= */ true,
/* playedAds= */ false);
......
......@@ -17,8 +17,11 @@ package com.google.android.exoplayer2;
import static com.google.android.exoplayer2.testutil.ExoPlayerTestRunner.AUDIO_FORMAT;
import static com.google.android.exoplayer2.testutil.ExoPlayerTestRunner.VIDEO_FORMAT;
import static com.google.android.exoplayer2.testutil.FakeMultiPeriodLiveTimeline.AD_PERIOD_DURATION_MS;
import static com.google.android.exoplayer2.testutil.FakeMultiPeriodLiveTimeline.PERIOD_DURATION_MS;
import static com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US;
import static com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US;
import static com.google.android.exoplayer2.util.Util.msToUs;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.fail;
......@@ -424,15 +427,18 @@ public final class MediaPeriodQueueTest {
@Test
@SuppressWarnings("unchecked")
public void getNextMediaPeriodInfo_multiPeriodTimelineWithNoAdsAndNoPostrollPlaceholder() {
long contentPeriodDurationUs = FakeMultiPeriodLiveTimeline.PERIOD_DURATION_US;
long adPeriodDurationUs = FakeMultiPeriodLiveTimeline.AD_PERIOD_DURATION_US;
long contentPeriodDurationUs = msToUs(PERIOD_DURATION_MS);
long adPeriodDurationUs = msToUs(AD_PERIOD_DURATION_MS);
// Multi period timeline without ad playback state.
FakeMultiPeriodLiveTimeline multiPeriodLiveTimeline =
new FakeMultiPeriodLiveTimeline(
/* availabilityStartTimeUs= */ 0,
/* availabilityStartTimeMs= */ 0,
/* liveWindowDurationUs= */ 60_000_000,
/* nowUs= */ 110_000_000,
new boolean[] {false, true, true},
/* adSequencePattern= */ new boolean[] {false, true, true},
/* periodDurationMsPattern= */ new long[] {
PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS
},
/* isContentTimeline= */ true,
/* populateAds= */ false,
/* playedAds= */ false);
......@@ -491,15 +497,18 @@ public final class MediaPeriodQueueTest {
@Test
@SuppressWarnings("unchecked")
public void getNextMediaPeriodInfo_multiPeriodTimelineWithPostrollPlaceHolder() {
long contentPeriodDurationUs = FakeMultiPeriodLiveTimeline.PERIOD_DURATION_US;
long adPeriodDurationUs = FakeMultiPeriodLiveTimeline.AD_PERIOD_DURATION_US;
long contentPeriodDurationUs = msToUs(PERIOD_DURATION_MS);
long adPeriodDurationUs = msToUs(AD_PERIOD_DURATION_MS);
// Multi period timeline without ad playback state.
FakeMultiPeriodLiveTimeline multiPeriodLiveTimeline =
new FakeMultiPeriodLiveTimeline(
/* availabilityStartTimeUs= */ 0,
/* availabilityStartTimeMs= */ 0,
/* liveWindowDurationUs= */ 60_000_000,
/* nowUs= */ 110_000_000,
new boolean[] {false, true, true},
/* adSequencePattern= */ new boolean[] {false, true, true},
/* periodDurationMsPattern= */ new long[] {
PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS
},
/* isContentTimeline= */ false,
/* populateAds= */ false,
/* playedAds= */ false);
......@@ -558,14 +567,17 @@ public final class MediaPeriodQueueTest {
@Test
@SuppressWarnings("unchecked")
public void getNextMediaPeriodInfo_multiPeriodTimelineWithAdsAndWithPostRollPlaceHolder() {
long contentPeriodDurationUs = FakeMultiPeriodLiveTimeline.PERIOD_DURATION_US;
long adPeriodDurationUs = FakeMultiPeriodLiveTimeline.AD_PERIOD_DURATION_US;
long contentPeriodDurationUs = msToUs(PERIOD_DURATION_MS);
long adPeriodDurationUs = msToUs(AD_PERIOD_DURATION_MS);
FakeMultiPeriodLiveTimeline multiPeriodLiveTimeline =
new FakeMultiPeriodLiveTimeline(
/* availabilityStartTimeUs= */ 0,
/* availabilityStartTimeMs= */ 0,
/* liveWindowDurationUs= */ 60_000_000,
/* nowUs= */ 110_000_000,
new boolean[] {false, true, true},
/* adSequencePattern= */ new boolean[] {false, true, true},
/* periodDurationMsPattern= */ new long[] {
PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS
},
/* isContentTimeline= */ false,
/* populateAds= */ true,
/* playedAds= */ false);
......@@ -640,13 +652,16 @@ public final class MediaPeriodQueueTest {
@Test
@SuppressWarnings("unchecked")
public void getNextMediaPeriodInfo_multiPeriodTimelineWithPlayedAdsAndWithPostRollPlaceHolder() {
long contentPeriodDurationUs = FakeMultiPeriodLiveTimeline.PERIOD_DURATION_US;
long contentPeriodDurationUs = msToUs(PERIOD_DURATION_MS);
FakeMultiPeriodLiveTimeline multiPeriodLiveTimeline =
new FakeMultiPeriodLiveTimeline(
/* availabilityStartTimeUs= */ 0,
/* availabilityStartTimeMs= */ 0,
/* liveWindowDurationUs= */ 60_000_000,
/* nowUs= */ 110_000_000,
new boolean[] {false, true, true},
/* adSequencePattern= */ new boolean[] {false, true, true},
/* periodDurationMsPattern= */ new long[] {
PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS, AD_PERIOD_DURATION_MS
},
/* isContentTimeline= */ false,
/* populateAds= */ true,
/* playedAds= */ true);
......
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