use of com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition in project ExoPlayer by google.
the class MediaPeriodQueueTest method getNextMediaPeriodInfo_inMultiPeriodWindow_returnsCorrectMediaPeriodInfos.
@Test
public void getNextMediaPeriodInfo_inMultiPeriodWindow_returnsCorrectMediaPeriodInfos() {
setupTimeline(new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
2, /* id= */
new Object(), /* isSeekable= */
false, /* isDynamic= */
false, /* durationUs= */
2 * CONTENT_DURATION_US)));
assertGetNextMediaPeriodInfoReturnsContentMediaPeriod(/* periodUid= */
playbackInfo.timeline.getUidOfPeriod(/* periodIndex= */
0), /* startPositionUs= */
0, /* requestedContentPositionUs= */
C.TIME_UNSET, /* endPositionUs= */
C.TIME_UNSET, /* durationUs= */
CONTENT_DURATION_US + DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US, /* isFollowedByTransitionToSameStream= */
false, /* isLastInPeriod= */
true, /* isLastInWindow= */
false, /* nextAdGroupIndex= */
C.INDEX_UNSET);
advance();
assertGetNextMediaPeriodInfoReturnsContentMediaPeriod(/* periodUid= */
playbackInfo.timeline.getUidOfPeriod(/* periodIndex= */
1), /* startPositionUs= */
0, /* requestedContentPositionUs= */
0, /* endPositionUs= */
C.TIME_UNSET, /* durationUs= */
CONTENT_DURATION_US, /* isFollowedByTransitionToSameStream= */
false, /* isLastInPeriod= */
true, /* isLastInWindow= */
true, /* nextAdGroupIndex= */
C.INDEX_UNSET);
}
use of com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition in project ExoPlayer by google.
the class DefaultPlaybackSessionManagerTest method updateSessions_withNewAd_afterDiscontinuitiesFromContentToAdAndBack_doesNotActivateNewAd.
@Test
public void updateSessions_withNewAd_afterDiscontinuitiesFromContentToAdAndBack_doesNotActivateNewAd() {
Timeline adTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
0, /* isSeekable= */
true, /* isDynamic= */
false, /* durationUs= */
10 * C.MICROS_PER_SECOND, new AdPlaybackState(/* adsId= */
new Object(), /* adGroupTimesUs=... */
2 * C.MICROS_PER_SECOND, 5 * C.MICROS_PER_SECOND).withAdCount(/* adGroupIndex= */
0, /* adCount= */
1).withAdCount(/* adGroupIndex= */
1, /* adCount= */
1)));
EventTime adEventTime1 = createEventTime(adTimeline, /* windowIndex= */
0, new MediaPeriodId(adTimeline.getUidOfPeriod(/* periodIndex= */
0), /* adGroupIndex= */
0, /* adIndexInAdGroup= */
0, /* windowSequenceNumber= */
0));
EventTime adEventTime2 = createEventTime(adTimeline, /* windowIndex= */
0, new MediaPeriodId(adTimeline.getUidOfPeriod(/* periodIndex= */
0), /* adGroupIndex= */
1, /* adIndexInAdGroup= */
0, /* windowSequenceNumber= */
0));
EventTime contentEventTime1 = createEventTime(adTimeline, /* windowIndex= */
0, new MediaPeriodId(adTimeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0, /* nextAdGroupIndex= */
0));
EventTime contentEventTime2 = createEventTime(adTimeline, /* windowIndex= */
0, new MediaPeriodId(adTimeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0, /* nextAdGroupIndex= */
1));
sessionManager.updateSessionsWithTimelineChange(contentEventTime1);
sessionManager.updateSessions(adEventTime1);
sessionManager.updateSessionsWithDiscontinuity(adEventTime1, Player.DISCONTINUITY_REASON_AUTO_TRANSITION);
sessionManager.updateSessionsWithDiscontinuity(contentEventTime2, Player.DISCONTINUITY_REASON_AUTO_TRANSITION);
String adSessionId2 = sessionManager.getSessionForMediaPeriodId(adTimeline, adEventTime2.mediaPeriodId);
sessionManager.updateSessions(adEventTime2);
verify(mockListener, never()).onSessionActive(any(), eq(adSessionId2));
}
use of com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition in project ExoPlayer by google.
the class DefaultPlaybackSessionManagerTest method timelineUpdate_resolvesWindowIndices.
@Test
public void timelineUpdate_resolvesWindowIndices() {
Timeline initialTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
2, /* id= */
100), new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
200), new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
300));
EventTime eventForInitialTimelineId100 = createEventTime(initialTimeline, /* windowIndex= */
0, new MediaPeriodId(initialTimeline.getUidOfPeriod(/* periodIndex= */
1), /* windowSequenceNumber= */
0));
EventTime eventForInitialTimelineId200 = createEventTime(initialTimeline, /* windowIndex= */
1, new MediaPeriodId(initialTimeline.getUidOfPeriod(/* periodIndex= */
2), /* windowSequenceNumber= */
1));
EventTime eventForInitialTimelineId300 = createEventTime(initialTimeline, /* windowIndex= */
2, new MediaPeriodId(initialTimeline.getUidOfPeriod(/* periodIndex= */
3), /* windowSequenceNumber= */
2));
sessionManager.updateSessionsWithTimelineChange(eventForInitialTimelineId100);
sessionManager.updateSessions(eventForInitialTimelineId200);
sessionManager.updateSessions(eventForInitialTimelineId300);
String sessionId100 = sessionManager.getSessionForMediaPeriodId(initialTimeline, eventForInitialTimelineId100.mediaPeriodId);
String sessionId200 = sessionManager.getSessionForMediaPeriodId(initialTimeline, eventForInitialTimelineId200.mediaPeriodId);
String sessionId300 = sessionManager.getSessionForMediaPeriodId(initialTimeline, eventForInitialTimelineId300.mediaPeriodId);
Timeline timelineUpdate = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
300), new TimelineWindowDefinition(/* periodCount= */
1, /* id= */
100));
EventTime eventForTimelineUpdateId100 = createEventTime(timelineUpdate, /* windowIndex= */
1, new MediaPeriodId(timelineUpdate.getUidOfPeriod(/* periodIndex= */
1), /* windowSequenceNumber= */
0));
EventTime eventForTimelineUpdateId300 = createEventTime(timelineUpdate, /* windowIndex= */
0, new MediaPeriodId(timelineUpdate.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
2));
sessionManager.updateSessionsWithTimelineChange(eventForTimelineUpdateId100);
String updatedSessionId100 = sessionManager.getSessionForMediaPeriodId(timelineUpdate, eventForTimelineUpdateId100.mediaPeriodId);
String updatedSessionId300 = sessionManager.getSessionForMediaPeriodId(timelineUpdate, eventForTimelineUpdateId300.mediaPeriodId);
verify(mockListener).onSessionCreated(eventForInitialTimelineId100, sessionId100);
verify(mockListener).onSessionActive(eventForInitialTimelineId100, sessionId100);
verify(mockListener).onSessionCreated(eventForInitialTimelineId200, sessionId200);
verify(mockListener).onSessionCreated(eventForInitialTimelineId300, sessionId300);
verify(mockListener).onSessionFinished(eventForTimelineUpdateId100, sessionId200, /* automaticTransitionToNextPlayback= */
false);
verifyNoMoreInteractions(mockListener);
assertThat(updatedSessionId100).isEqualTo(sessionId100);
assertThat(updatedSessionId300).isEqualTo(sessionId300);
}
use of com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition in project ExoPlayer by google.
the class DefaultPlaybackSessionManagerTest method positionDiscontinuity_withinWindow_doesNotFinishSession.
@Test
public void positionDiscontinuity_withinWindow_doesNotFinishSession() {
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
2, /* id= */
100));
EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
0, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0));
EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
0, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
1), /* windowSequenceNumber= */
0));
sessionManager.updateSessionsWithTimelineChange(eventTime1);
sessionManager.updateSessions(eventTime2);
sessionManager.updateSessionsWithDiscontinuity(eventTime2, Player.DISCONTINUITY_REASON_AUTO_TRANSITION);
verify(mockListener).onSessionCreated(eq(eventTime1), anyString());
verify(mockListener).onSessionActive(eq(eventTime1), anyString());
verifyNoMoreInteractions(mockListener);
}
use of com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition in project ExoPlayer by google.
the class DefaultPlaybackSessionManagerTest method updateSessions_withOtherMediaPeriodId_ofSameWindow_doesNotCreateNewSession.
@Test
public void updateSessions_withOtherMediaPeriodId_ofSameWindow_doesNotCreateNewSession() {
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
2, /* id= */
0));
MediaPeriodId mediaPeriodId1 = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
0), /* windowSequenceNumber= */
0);
MediaPeriodId mediaPeriodId2 = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
1), /* windowSequenceNumber= */
0);
EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
0, mediaPeriodId1);
EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
0, mediaPeriodId2);
sessionManager.updateSessions(eventTime1);
sessionManager.updateSessions(eventTime2);
ArgumentCaptor<String> sessionId = ArgumentCaptor.forClass(String.class);
verify(mockListener).onSessionCreated(eq(eventTime1), sessionId.capture());
verify(mockListener).onSessionActive(eventTime1, sessionId.getValue());
verifyNoMoreInteractions(mockListener);
assertThat(sessionManager.getSessionForMediaPeriodId(timeline, mediaPeriodId1)).isEqualTo(sessionId.getValue());
assertThat(sessionManager.getSessionForMediaPeriodId(timeline, mediaPeriodId2)).isEqualTo(sessionId.getValue());
}
Aggregations