Search in sources :

Example 56 with FakeTimeline

use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method positionDiscontinuity_toSameWindow_withoutMediaPeriodId_doesNotFinishSession.

@Test
public void positionDiscontinuity_toSameWindow_withoutMediaPeriodId_doesNotFinishSession() {
    Timeline timeline = new FakeTimeline();
    EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
    0, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0));
    EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
    0, /* mediaPeriodId= */
    null);
    sessionManager.updateSessionsWithTimelineChange(eventTime1);
    sessionManager.updateSessions(eventTime2);
    sessionManager.updateSessionsWithDiscontinuity(eventTime2, Player.DISCONTINUITY_REASON_SEEK);
    verify(mockListener, never()).onSessionFinished(any(), anyString(), anyBoolean());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 57 with FakeTimeline

use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method updateSessions_withAd_ofSameWindow_createsNewSession.

@Test
public void updateSessions_withAd_ofSameWindow_createsNewSession() {
    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= */
    0), /* adGroupIndex= */
    0, /* adIndexInAdGroup= */
    0, /* windowSequenceNumber= */
    0);
    EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodId1);
    EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodId2);
    sessionManager.updateSessions(eventTime1);
    sessionManager.updateSessions(eventTime2);
    ArgumentCaptor<String> contentSessionId = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> adSessionId = ArgumentCaptor.forClass(String.class);
    verify(mockListener).onSessionCreated(eq(eventTime1), contentSessionId.capture());
    verify(mockListener).onSessionActive(eventTime1, contentSessionId.getValue());
    verify(mockListener).onSessionCreated(eq(eventTime2), adSessionId.capture());
    verifyNoMoreInteractions(mockListener);
    assertThat(contentSessionId).isNotEqualTo(adSessionId);
    assertThat(sessionManager.getSessionForMediaPeriodId(timeline, mediaPeriodId1)).isEqualTo(contentSessionId.getValue());
    assertThat(sessionManager.getSessionForMediaPeriodId(timeline, mediaPeriodId2)).isEqualTo(adSessionId.getValue());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 58 with FakeTimeline

use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method updateSessions_ofSameWindow_withoutMediaPeriodId_afterAd_doesNotCreateNewSession.

@Test
public void updateSessions_ofSameWindow_withoutMediaPeriodId_afterAd_doesNotCreateNewSession() {
    Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
    1, /* id= */
    new Object(), /* isSeekable= */
    true, /* isDynamic= */
    false, /* durationUs= */
    10_000_000, FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */
    1, /* adGroupTimesUs... */
    0)));
    MediaPeriodId adMediaPeriodId = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* adGroupIndex= */
    0, /* adIndexInAdGroup= */
    0, /* windowSequenceNumber= */
    0);
    MediaPeriodId contentMediaPeriodIdDuringAd = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0, /* nextAdGroupIndex= */
    0);
    EventTime adEventTime = createEventTime(timeline, /* windowIndex= */
    0, adMediaPeriodId);
    EventTime contentEventTimeDuringAd = createEventTime(timeline, /* windowIndex= */
    0, contentMediaPeriodIdDuringAd, adMediaPeriodId);
    EventTime contentEventTimeWithoutMediaPeriodId = createEventTime(timeline, /* windowIndex= */
    0, /* mediaPeriodId= */
    null);
    sessionManager.updateSessions(adEventTime);
    sessionManager.updateSessions(contentEventTimeWithoutMediaPeriodId);
    verify(mockListener).onSessionCreated(eq(contentEventTimeDuringAd), anyString());
    ArgumentCaptor<String> adSessionId = ArgumentCaptor.forClass(String.class);
    verify(mockListener).onSessionCreated(eq(adEventTime), adSessionId.capture());
    verify(mockListener).onSessionActive(adEventTime, adSessionId.getValue());
    verifyNoMoreInteractions(mockListener);
    assertThat(sessionManager.getSessionForMediaPeriodId(timeline, adMediaPeriodId)).isEqualTo(adSessionId.getValue());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 59 with FakeTimeline

use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method updateSessions_ofSameWindow_withNewWindowSequenceNumber_createsNewSession.

@Test
public void updateSessions_ofSameWindow_withNewWindowSequenceNumber_createsNewSession() {
    Timeline timeline = new FakeTimeline();
    MediaPeriodId mediaPeriodId1 = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0);
    MediaPeriodId mediaPeriodId2 = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    1);
    EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodId1);
    EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodId2);
    sessionManager.updateSessions(eventTime1);
    sessionManager.updateSessions(eventTime2);
    ArgumentCaptor<String> sessionId1 = ArgumentCaptor.forClass(String.class);
    ArgumentCaptor<String> sessionId2 = ArgumentCaptor.forClass(String.class);
    verify(mockListener).onSessionCreated(eq(eventTime1), sessionId1.capture());
    verify(mockListener).onSessionActive(eventTime1, sessionId1.getValue());
    verify(mockListener).onSessionCreated(eq(eventTime2), sessionId2.capture());
    verifyNoMoreInteractions(mockListener);
    assertThat(sessionId1).isNotEqualTo(sessionId2);
    assertThat(sessionManager.getSessionForMediaPeriodId(timeline, mediaPeriodId1)).isEqualTo(sessionId1.getValue());
    assertThat(sessionManager.getSessionForMediaPeriodId(timeline, mediaPeriodId2)).isEqualTo(sessionId2.getValue());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 60 with FakeTimeline

use of com.google.android.exoplayer2.testutil.FakeTimeline in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method updateSessions_withoutMediaPeriodId_andPreviouslyCreatedSessions_doesNotCreateNewSession.

@Test
public void updateSessions_withoutMediaPeriodId_andPreviouslyCreatedSessions_doesNotCreateNewSession() {
    Timeline timeline = new FakeTimeline();
    MediaPeriodId mediaPeriodId1 = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0);
    MediaPeriodId mediaPeriodId2 = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    1);
    MediaPeriodId mediaPeriodIdWithAd = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* adGroupIndex= */
    0, /* adIndexInAdGroup= */
    0, /* windowSequenceNumber= */
    0);
    EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodId1);
    EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodId2);
    EventTime eventTime3 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodIdWithAd);
    EventTime eventTime4 = createEventTime(timeline, /* windowIndex= */
    0, /* mediaPeriodId= */
    null);
    sessionManager.updateSessions(eventTime1);
    sessionManager.updateSessions(eventTime2);
    sessionManager.updateSessions(eventTime3);
    sessionManager.updateSessions(eventTime4);
    verify(mockListener).onSessionCreated(eq(eventTime1), anyString());
    verify(mockListener).onSessionActive(eq(eventTime1), anyString());
    verify(mockListener).onSessionCreated(eq(eventTime2), anyString());
    verify(mockListener).onSessionCreated(eq(eventTime3), anyString());
    verifyNoMoreInteractions(mockListener);
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) EventTime(com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Aggregations

FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)242 Test (org.junit.Test)240 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)159 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)136 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)118 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)117 NoUidTimeline (com.google.android.exoplayer2.testutil.NoUidTimeline)117 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)98 ExoPlayerTestRunner (com.google.android.exoplayer2.testutil.ExoPlayerTestRunner)87 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)69 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)62 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)62 MediaSource (com.google.android.exoplayer2.source.MediaSource)60 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)60 Timeline (com.google.android.exoplayer2.Timeline)53 ServerSideAdInsertionMediaSource (com.google.android.exoplayer2.source.ads.ServerSideAdInsertionMediaSource)50 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)49 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)49 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)49 FakeAdaptiveMediaSource (com.google.android.exoplayer2.testutil.FakeAdaptiveMediaSource)49