Search in sources :

Example 6 with CreativeViewListener

use of org.prebid.mobile.rendering.listeners.CreativeViewListener in project prebid-mobile-android by prebid.

the class VideoCreativeTest method trackAdVideoEventTest.

@Test
public void trackAdVideoEventTest() throws Exception {
    CreativeViewListener mockCreativeViewListener = mock(CreativeViewListener.class);
    VideoPlayerView mockView = mock(VideoPlayerView.class);
    mVideoCreative.setCreativeViewListener(mockCreativeViewListener);
    when(mockView.getDuration()).thenReturn(0);
    when(mockView.getVolume()).thenReturn(0f);
    when(mMockVideoCreativeView.hasVideoStarted()).thenReturn(true);
    when(mMockVideoCreativeView.isPlaying()).thenReturn(true);
    when(mMockVideoCreativeView.getVideoPlayerView()).thenReturn(mockView);
    mVideoCreative.complete();
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_COMPLETE);
    mockCreativeViewListener.creativeDidComplete(mVideoCreative);
    mVideoCreative.onVolumeChanged(1);
    verify(mMockOmAdSessionManager).trackVolumeChange(1);
    mVideoCreative.onPlayerStateChanged(InternalPlayerState.NORMAL);
    verify(mMockModel).trackPlayerStateChange(InternalPlayerState.NORMAL);
    mVideoCreative.skip();
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_SKIP);
    mockCreativeViewListener.creativeDidComplete(mVideoCreative);
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_RESUME);
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_RESUME);
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_PAUSE);
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_PAUSE);
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_UNMUTE);
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_UNMUTE);
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_MUTE);
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_MUTE);
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_FULLSCREEN);
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_FULLSCREEN);
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_EXITFULLSCREEN);
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_EXITFULLSCREEN);
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_START);
    verify(mMockModel).trackVideoEvent(VideoAdEvent.Event.AD_START);
    mVideoCreative.mVideoCreativeView = null;
    mVideoCreative.onEvent(VideoAdEvent.Event.AD_START);
    verify(mMockModel, atLeastOnce()).trackVideoEvent(VideoAdEvent.Event.AD_START);
}
Also used : CreativeViewListener(org.prebid.mobile.rendering.listeners.CreativeViewListener) Test(org.junit.Test)

Example 7 with CreativeViewListener

use of org.prebid.mobile.rendering.listeners.CreativeViewListener in project prebid-mobile-android by prebid.

the class VideoCreativeTest method whenOnVideoInterstitialClosed_DestroyCreativeViewAndCallCreativeDidComplete.

@Test
public void whenOnVideoInterstitialClosed_DestroyCreativeViewAndCallCreativeDidComplete() {
    CreativeViewListener mockListener = mock(CreativeViewListener.class);
    mVideoCreative.setCreativeViewListener(mockListener);
    mVideoCreative.onVideoInterstitialClosed();
    verify(mMockVideoCreativeView).destroy();
    verify(mockListener).creativeDidComplete(any(AbstractCreative.class));
}
Also used : AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) CreativeViewListener(org.prebid.mobile.rendering.listeners.CreativeViewListener) Test(org.junit.Test)

Aggregations

CreativeViewListener (org.prebid.mobile.rendering.listeners.CreativeViewListener)7 Test (org.junit.Test)6 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)2 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)2 View (android.view.View)1 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)1 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)1