Search in sources :

Example 1 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class PrebidWebViewBannerTest method loadHTMLTest.

@Test
public void loadHTMLTest() throws IOException {
    HTMLCreative mockCreative = mock(HTMLCreative.class);
    CreativeModel mockCreativeModel = mock(CreativeModel.class);
    when(mockCreative.getCreativeModel()).thenReturn(mockCreativeModel);
    when(mockCreativeModel.getHtml()).thenReturn(ResourceUtils.convertResourceToString("ad_contains_iframe"));
    when(mockCreativeModel.getAdConfiguration()).thenReturn(new AdConfiguration());
    mBanner.mCreative = mockCreative;
    mBanner.loadHTML(mAdHTML, 100, 200);
    assertNotNull(mBanner.mWebView);
    assertEquals("1part", mBanner.mWebView.mMRAIDBridgeName);
}
Also used : CreativeModel(org.prebid.mobile.rendering.models.CreativeModel) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) HTMLCreative(org.prebid.mobile.rendering.models.HTMLCreative) Test(org.junit.Test)

Example 2 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class AdViewManagerTest method creativeDidCompleteTest.

@Test
public void creativeDidCompleteTest() throws Exception {
    VideoCreative mockVideoCreative = mock(VideoCreative.class);
    when(mockVideoCreative.getCreativeModel()).thenReturn(new VideoCreativeModel(mock(TrackingManager.class), mock(OmEventTracker.class), new AdConfiguration()));
    when(mockVideoCreative.isVideo()).thenReturn(true);
    Transaction mockTransaction = mock(Transaction.class);
    ArrayList<CreativeFactory> creativeFactories = new ArrayList<>();
    TransactionManager mockTransactionManager = mock(TransactionManager.class);
    when(mockTransactionManager.getCurrentTransaction()).thenReturn(mockTransaction);
    when(mockTransaction.getCreativeFactories()).thenReturn(creativeFactories);
    WhiteBox.field(AdViewManager.class, "mTransactionManager").set(mAdViewManager, mockTransactionManager);
    WhiteBox.field(AdViewManager.class, "mAdView").set(mAdViewManager, mockAdView);
    mAdViewManager.creativeDidComplete(mockVideoCreative);
    verify(mockAdView).closeInterstitialVideo();
    verify(mMockAdViewListener, times(1)).adCompleted();
    mAdViewManager.creativeDidComplete(mockVideoCreative);
    verify(mMockAdViewListener, times(2)).adCompleted();
}
Also used : VideoCreative(org.prebid.mobile.rendering.video.VideoCreative) Transaction(org.prebid.mobile.rendering.loading.Transaction) TransactionManager(org.prebid.mobile.rendering.loading.TransactionManager) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) ArrayList(java.util.ArrayList) CreativeFactory(org.prebid.mobile.rendering.loading.CreativeFactory) VideoCreativeModel(org.prebid.mobile.rendering.video.VideoCreativeModel) Test(org.junit.Test)

Example 3 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class VideoCreativeTest method loadTest.

@Test
public void loadTest() throws Exception {
    VideoCreativeModel mockModel = mock(VideoCreativeModel.class);
    when(mockModel.getMediaUrl()).thenReturn("/video.mp4");
    AdConfiguration mockAdConfig = mock(AdConfiguration.class);
    when(mockModel.getAdConfiguration()).thenReturn(mockAdConfig);
    WhiteBox.field(VideoCreative.class, "mModel").set(mVideoCreative, mockModel);
    mVideoCreative.load();
    assertNotNull(WhiteBox.getInternalState(mVideoCreative, "mVideoDownloadTask"));
}
Also used : AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) Test(org.junit.Test)

Example 4 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class BaseAdViewTest method setUp.

@Before
public void setUp() throws Exception {
    mMockContext = spy(Robolectric.buildActivity(Activity.class).create().get());
    mBaseAdView = new BaseAdView(mMockContext) {

        @Override
        protected void notifyErrorListeners(AdException adException) {
        }
    };
    mMockAdViewManager = Mockito.mock(AdViewManager.class);
    when(mMockAdViewManager.getAdConfiguration()).thenReturn(new AdConfiguration());
    Field field = WhiteBox.field(BaseAdView.class, "mAdViewManager");
    field.set(mBaseAdView, mMockAdViewManager);
}
Also used : Field(java.lang.reflect.Field) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) AdException(org.prebid.mobile.rendering.errors.AdException) AdViewManager(org.prebid.mobile.rendering.views.AdViewManager) Before(org.junit.Before)

Example 5 with AdConfiguration

use of org.prebid.mobile.rendering.models.AdConfiguration in project prebid-mobile-android by prebid.

the class InterstitialVideoTest method whenRemainingTimePresent_UseRemainingTime.

@Test
public void whenRemainingTimePresent_UseRemainingTime() throws Exception {
    Context context = mock(Context.class);
    AdViewManager adViewManager = new AdViewManager(context, mock(AdViewManagerListener.class), mMockAdView, mock(InterstitialManager.class));
    AdConfiguration adConfiguration = adViewManager.getAdConfiguration();
    adConfiguration.setVideoSkipOffset(10);
    AbstractCreative mockCreative = mock(AbstractCreative.class);
    VideoCreativeModel mockModel = mock(VideoCreativeModel.class);
    when(mockModel.getSkipOffset()).thenReturn(20L);
    when(mockCreative.getCreativeModel()).thenReturn(mockModel);
    WhiteBox.field(AdViewManager.class, "mCurrentCreative").set(adViewManager, mockCreative);
    when(mMockAdView.getMediaOffset()).thenReturn(adViewManager.getSkipOffset());
    mSpyInterstitialVideo.setRemainingTimeInMs(3000);
    mSpyInterstitialVideo.scheduleShowCloseBtnTask(mMockAdView, 3000);
    verify(mSpyInterstitialVideo).scheduleTimer(3L * 1000);
}
Also used : Context(android.content.Context) AbstractCreative(org.prebid.mobile.rendering.models.AbstractCreative) AdConfiguration(org.prebid.mobile.rendering.models.AdConfiguration) AdViewManager(org.prebid.mobile.rendering.views.AdViewManager) AdViewManagerListener(org.prebid.mobile.rendering.views.AdViewManagerListener) VideoCreativeModel(org.prebid.mobile.rendering.video.VideoCreativeModel) Test(org.junit.Test)

Aggregations

AdConfiguration (org.prebid.mobile.rendering.models.AdConfiguration)57 Test (org.junit.Test)38 BasicParameterBuilder (org.prebid.mobile.rendering.networking.parameters.BasicParameterBuilder)15 AdSize (org.prebid.mobile.rendering.bidding.data.AdSize)13 BidRequest (org.prebid.mobile.rendering.models.openrtb.BidRequest)11 Before (org.junit.Before)8 Imp (org.prebid.mobile.rendering.models.openrtb.bidRequests.Imp)8 Context (android.content.Context)6 JSONObject (org.json.JSONObject)6 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)6 Activity (android.app.Activity)5 AdException (org.prebid.mobile.rendering.errors.AdException)5 AbstractCreative (org.prebid.mobile.rendering.models.AbstractCreative)5 VideoCreativeModel (org.prebid.mobile.rendering.video.VideoCreativeModel)5 AdViewManager (org.prebid.mobile.rendering.views.AdViewManager)5 Handler (android.os.Handler)3 JSONArray (org.json.JSONArray)3 HTMLCreative (org.prebid.mobile.rendering.models.HTMLCreative)3 Ext (org.prebid.mobile.rendering.models.openrtb.bidRequests.Ext)3 User (org.prebid.mobile.rendering.models.openrtb.bidRequests.User)3