use of com.google.ads.interactivemedia.v3.api.AdEvent in project ExoPlayer by google.
the class ImaAdsLoaderTest method playback_withMidrollFetchError_marksAdAsInErrorState.
@Test
public void playback_withMidrollFetchError_marksAdAsInErrorState() {
AdEvent mockMidrollFetchErrorAdEvent = mock(AdEvent.class);
when(mockMidrollFetchErrorAdEvent.getType()).thenReturn(AdEventType.AD_BREAK_FETCH_ERROR);
when(mockMidrollFetchErrorAdEvent.getAdData()).thenReturn(ImmutableMap.of("adBreakTime", "20.5"));
when(mockAdsManager.getAdCuePoints()).thenReturn(ImmutableList.of(20.5f));
// Simulate loading an empty midroll ad.
imaAdsLoader.start(adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
adEventListener.onAdEvent(mockMidrollFetchErrorAdEvent);
assertThat(getAdPlaybackState(/* periodIndex= */
0)).isEqualTo(new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */
20_500_000).withContentDurationUs(CONTENT_PERIOD_DURATION_US).withAdDurationsUs(new long[][] { { TEST_AD_DURATION_US } }).withAdCount(/* adGroupIndex= */
0, /* adCount= */
1).withAdLoadError(/* adGroupIndex= */
0, /* adIndexInAdGroup= */
0));
}
use of com.google.ads.interactivemedia.v3.api.AdEvent in project ExoPlayer by google.
the class ImaAdsLoaderTest method playback_withPostrollFetchError_marksAdAsInErrorState.
@Test
public void playback_withPostrollFetchError_marksAdAsInErrorState() {
AdEvent mockPostrollFetchErrorAdEvent = mock(AdEvent.class);
when(mockPostrollFetchErrorAdEvent.getType()).thenReturn(AdEventType.AD_BREAK_FETCH_ERROR);
when(mockPostrollFetchErrorAdEvent.getAdData()).thenReturn(ImmutableMap.of("adBreakTime", "-1"));
when(mockAdsManager.getAdCuePoints()).thenReturn(ImmutableList.of(-1f));
// Simulate loading an empty postroll ad.
imaAdsLoader.start(adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
adEventListener.onAdEvent(mockPostrollFetchErrorAdEvent);
assertThat(getAdPlaybackState(/* periodIndex= */
0)).isEqualTo(new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */
C.TIME_END_OF_SOURCE).withContentDurationUs(CONTENT_PERIOD_DURATION_US).withAdDurationsUs(new long[][] { { TEST_AD_DURATION_US } }).withAdCount(/* adGroupIndex= */
0, /* adCount= */
1).withAdLoadError(/* adGroupIndex= */
0, /* adIndexInAdGroup= */
0));
}
use of com.google.ads.interactivemedia.v3.api.AdEvent in project ExoPlayer by google.
the class ImaAdsLoaderTest method playback_withMidrollFetchError_updatesContentProgress.
@Test
public void playback_withMidrollFetchError_updatesContentProgress() {
AdEvent mockMidrollFetchErrorAdEvent = mock(AdEvent.class);
when(mockMidrollFetchErrorAdEvent.getType()).thenReturn(AdEventType.AD_BREAK_FETCH_ERROR);
when(mockMidrollFetchErrorAdEvent.getAdData()).thenReturn(ImmutableMap.of("adBreakTime", "5.5"));
when(mockAdsManager.getAdCuePoints()).thenReturn(ImmutableList.of(5.5f));
// Simulate loading an empty midroll ad and advancing the player position.
imaAdsLoader.start(adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
adEventListener.onAdEvent(mockMidrollFetchErrorAdEvent);
long playerPositionUs = CONTENT_DURATION_US - C.MICROS_PER_SECOND;
long playerPositionInPeriodUs = playerPositionUs + TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US;
long periodDurationUs = CONTENT_TIMELINE.getPeriod(/* periodIndex= */
0, new Period()).durationUs;
fakePlayer.setPlayingContentPosition(/* periodIndex= */
0, Util.usToMs(playerPositionUs));
// Verify the content progress is updated to reflect the new player position.
assertThat(contentProgressProvider.getContentProgress()).isEqualTo(new VideoProgressUpdate(Util.usToMs(playerPositionInPeriodUs), Util.usToMs(periodDurationUs)));
}
Aggregations