Search in sources :

Example 61 with EventTime

use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method updateSessions_withoutMediaPeriodId_createsNewSession.

@Test
public void updateSessions_withoutMediaPeriodId_createsNewSession() {
    Timeline timeline = new FakeTimeline();
    EventTime eventTime = createEventTime(timeline, /* windowIndex= */
    0, /* mediaPeriodId */
    null);
    sessionManager.updateSessions(eventTime);
    verify(mockListener).onSessionCreated(eq(eventTime), anyString());
    verify(mockListener).onSessionActive(eq(eventTime), 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) Test(org.junit.Test)

Example 62 with EventTime

use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method positionDiscontinuity_fromContentToAd_doesNotFinishSessions.

@Test
public void positionDiscontinuity_fromContentToAd_doesNotFinishSessions() {
    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 contentEventTime = createEventTime(adTimeline, /* windowIndex= */
    0, new MediaPeriodId(adTimeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0, /* nextAdGroupIndex= */
    0));
    sessionManager.updateSessionsWithTimelineChange(contentEventTime);
    sessionManager.updateSessions(adEventTime1);
    sessionManager.updateSessions(adEventTime2);
    sessionManager.updateSessionsWithDiscontinuity(adEventTime1, Player.DISCONTINUITY_REASON_AUTO_TRANSITION);
    verify(mockListener, never()).onSessionFinished(any(), anyString(), anyBoolean());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) AdPlaybackState(com.google.android.exoplayer2.source.ads.AdPlaybackState) 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) Test(org.junit.Test)

Example 63 with EventTime

use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method updateSessions_ofSameWindow_withoutMediaPeriodId_afterMediaPeriodId_doesNotCreateNewSession.

@Test
public void updateSessions_ofSameWindow_withoutMediaPeriodId_afterMediaPeriodId_doesNotCreateNewSession() {
    Timeline timeline = new FakeTimeline();
    MediaPeriodId mediaPeriodId = new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0);
    EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
    0, mediaPeriodId);
    EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
    0, /* mediaPeriodId= */
    null);
    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, mediaPeriodId)).isEqualTo(sessionId.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 64 with EventTime

use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method positionDiscontinuity_toNewWindow_withSeekTransitionReason_finishesSession.

@Test
public void positionDiscontinuity_toNewWindow_withSeekTransitionReason_finishesSession() {
    Timeline timeline = new FakeTimeline(/* windowCount= */
    2);
    EventTime eventTime1 = createEventTime(timeline, /* windowIndex= */
    0, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0));
    EventTime eventTime2 = createEventTime(timeline, /* windowIndex= */
    1, new MediaPeriodId(timeline.getUidOfPeriod(/* periodIndex= */
    1), /* windowSequenceNumber= */
    1));
    sessionManager.updateSessionsWithTimelineChange(eventTime1);
    sessionManager.updateSessions(eventTime2);
    String sessionId1 = sessionManager.getSessionForMediaPeriodId(timeline, eventTime1.mediaPeriodId);
    String sessionId2 = sessionManager.getSessionForMediaPeriodId(timeline, eventTime2.mediaPeriodId);
    sessionManager.updateSessionsWithDiscontinuity(eventTime2, Player.DISCONTINUITY_REASON_SEEK);
    verify(mockListener).onSessionCreated(eventTime1, sessionId1);
    verify(mockListener).onSessionActive(eventTime1, sessionId1);
    verify(mockListener).onSessionCreated(eq(eventTime2), anyString());
    verify(mockListener).onSessionFinished(eventTime2, sessionId1, /* automaticTransitionToNextPlayback= */
    false);
    verify(mockListener).onSessionActive(eventTime2, sessionId2);
    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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 65 with EventTime

use of com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime in project ExoPlayer by google.

the class DefaultPlaybackSessionManagerTest method timelineUpdate_withContent_doesNotFinishFuturePostrollAd.

@Test
public void timelineUpdate_withContent_doesNotFinishFuturePostrollAd() {
    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=... */
    C.TIME_END_OF_SOURCE).withAdCount(/* adGroupIndex= */
    0, /* adCount= */
    1)));
    EventTime adEventTime = createEventTime(adTimeline, /* windowIndex= */
    0, new MediaPeriodId(adTimeline.getUidOfPeriod(/* periodIndex= */
    0), /* adGroupIndex= */
    0, /* adIndexInAdGroup= */
    0, /* windowSequenceNumber= */
    0));
    EventTime contentEventTime = createEventTime(adTimeline, /* windowIndex= */
    0, new MediaPeriodId(adTimeline.getUidOfPeriod(/* periodIndex= */
    0), /* windowSequenceNumber= */
    0, /* nextAdGroupIndex= */
    0));
    sessionManager.updateSessions(contentEventTime);
    sessionManager.updateSessions(adEventTime);
    sessionManager.updateSessionsWithTimelineChange(contentEventTime);
    verify(mockListener, never()).onSessionFinished(any(), anyString(), anyBoolean());
}
Also used : Timeline(com.google.android.exoplayer2.Timeline) FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) AdPlaybackState(com.google.android.exoplayer2.source.ads.AdPlaybackState) 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) Test(org.junit.Test)

Aggregations

EventTime (com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)103 Test (org.junit.Test)41 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)38 Timeline (com.google.android.exoplayer2.Timeline)37 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)34 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)26 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)14 Nullable (androidx.annotation.Nullable)9 AdPlaybackState (com.google.android.exoplayer2.source.ads.AdPlaybackState)6 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)6 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)5 InOrder (org.mockito.InOrder)5 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)4 ApplicationProvider (androidx.test.core.app.ApplicationProvider)3 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)3 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)3 MediaItem (com.google.android.exoplayer2.MediaItem)3 PlaybackException (com.google.android.exoplayer2.PlaybackException)3 PlaybackParameters (com.google.android.exoplayer2.PlaybackParameters)3 Player (com.google.android.exoplayer2.Player)3