Search in sources :

Example 1 with MoPubBannerMediationUtils

use of com.mopub.mediation.MoPubBannerMediationUtils in project prebid-mobile-android by prebid.

the class KeywordsSetupTest method handleMoPubKeywordsUpdateWithBanner_KeyWordsShouldMatchExpected.

@Test
public void handleMoPubKeywordsUpdateWithBanner_KeyWordsShouldMatchExpected() {
    MoPubView adView = new MoPubView(mActivity);
    MoPubBannerMediationUtils mediationUtils = new MoPubBannerMediationUtils(adView);
    adView.setKeywords("key1:value1,key2:value2");
    HashMap<String, String> bids = new HashMap<>();
    bids.put("hb_pb", "0.50");
    bids.put("hb_cache_id", "123456");
    mediationUtils.handleKeywordsUpdate(bids);
    String adViewKeywords = adView.getKeywords();
    assertEquals("hb_pb:0.50,hb_cache_id:123456,key1:value1,key2:value2", adViewKeywords);
    mediationUtils.handleKeywordsUpdate(null);
    assertEquals("key1:value1,key2:value2", adView.getKeywords());
}
Also used : HashMap(java.util.HashMap) MoPubBannerMediationUtils(com.mopub.mediation.MoPubBannerMediationUtils) MoPubView(com.mopub.mobileads.MoPubView) Test(org.junit.Test)

Example 2 with MoPubBannerMediationUtils

use of com.mopub.mediation.MoPubBannerMediationUtils in project prebid-mobile-android by prebid.

the class MoPubMediationUtilsWithAdUnitsTest method whenOnResponseReceived_UpdateMoPubAndSuccessResult.

@Test
public void whenOnResponseReceived_UpdateMoPubAndSuccessResult() {
    String testConfigId = "configId";
    String responseString = TestResponse.getResponse();
    HashMap<String, String> keywordsMap = TestResponse.getKeywordsMap();
    BidResponse bidResponse = new BidResponse(responseString);
    OnFetchCompleteListener mockListener = mock(OnFetchCompleteListener.class);
    MoPubBannerMediationUtils bannerUtils = mock(MoPubBannerMediationUtils.class);
    OpenMediationBaseAdUnit adUnit = new OpenMediationBaseAdUnit(context, testConfigId, mockAdSize, bannerUtils);
    WhiteBox.setInternalState(adUnit, "mBidLoader", mMockBidLoader);
    adUnit.fetchDemand(mockListener);
    adUnit.onResponseReceived(bidResponse);
    verify(mockListener).onComplete(FetchDemandResult.SUCCESS);
    verify(bannerUtils).setResponseToLocalExtras(bidResponse);
    verify(bannerUtils).handleKeywordsUpdate(keywordsMap);
    assertNotNull(BidResponseCache.getInstance().popBidResponse(bidResponse.getId()));
}
Also used : OnFetchCompleteListener(org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener) BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) MoPubBannerMediationUtils(com.mopub.mediation.MoPubBannerMediationUtils) OpenMediationBaseAdUnit(org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit) Test(org.junit.Test)

Example 3 with MoPubBannerMediationUtils

use of com.mopub.mediation.MoPubBannerMediationUtils in project prebid-mobile-android by prebid.

the class MoPubMediationUtilsMethodsTest method setup.

@Before
public void setup() {
    MockitoAnnotations.openMocks(this);
    mContext = Robolectric.buildActivity(Activity.class).create().get();
    mMoPubView = mock(MoPubView.class);
    bannerUtils = new MoPubBannerMediationUtils(mMoPubView);
    mMediationBannerAdUnit = new MediationBannerAdUnit(mContext, ID, AD_SIZE, bannerUtils);
    mMoPubInterstitial = mock(MoPubInterstitial.class);
    interstitialUtils = new MoPubInterstitialMediationUtils(mMoPubInterstitial);
    mMediationInterstitialAdUnit = new MediationInterstitialAdUnit(mContext, ID, AD_SIZE, interstitialUtils);
    mMoPubNative = mock(MoPubNative.class);
    nativeUtils = new MoPubNativeMediationUtils(mMoPubNativeKeywords, mMoPubNative);
    mMediationNativeAdUnit = new MediationNativeAdUnit(ID, nativeUtils);
    rewardedUtils = new MoPubRewardedVideoMediationUtils(mMoPubRewardedKeywords);
    mMoPubRewardedAdUnit = new MediationRewardedVideoAdUnit(mContext, ID, rewardedUtils);
}
Also used : MoPubNativeMediationUtils(com.mopub.mediation.MoPubNativeMediationUtils) MediationRewardedVideoAdUnit(org.prebid.mobile.rendering.bidding.display.MediationRewardedVideoAdUnit) MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial) MoPubRewardedVideoMediationUtils(com.mopub.mediation.MoPubRewardedVideoMediationUtils) MoPubNative(com.mopub.nativeads.MoPubNative) MediationNativeAdUnit(org.prebid.mobile.rendering.bidding.display.MediationNativeAdUnit) Activity(android.app.Activity) MoPubInterstitialMediationUtils(com.mopub.mediation.MoPubInterstitialMediationUtils) MediationInterstitialAdUnit(org.prebid.mobile.rendering.bidding.display.MediationInterstitialAdUnit) MediationBannerAdUnit(org.prebid.mobile.rendering.bidding.display.MediationBannerAdUnit) MoPubBannerMediationUtils(com.mopub.mediation.MoPubBannerMediationUtils) MoPubView(com.mopub.mobileads.MoPubView) Before(org.junit.Before)

Example 4 with MoPubBannerMediationUtils

use of com.mopub.mediation.MoPubBannerMediationUtils in project prebid-mobile-android by prebid.

the class KeywordsSetupTest method setResponseToMoPubLocalExtrasWithMoPubBannerOrInterstitialView_ResponseStoredInLocalExtras.

@Test
public void setResponseToMoPubLocalExtrasWithMoPubBannerOrInterstitialView_ResponseStoredInLocalExtras() {
    MoPubView moPubView = new MoPubView(mActivity);
    MoPubBannerMediationUtils mediationUtils = new MoPubBannerMediationUtils(moPubView);
    BidResponse response = new BidResponse("{\"response\":\"test\", \"id\":\"1234\"}");
    Map<String, Object> expectedLocalExtras = Collections.singletonMap(KEY_BID_RESPONSE, response.getId());
    mediationUtils.setResponseToLocalExtras(response);
    assertEquals(expectedLocalExtras, moPubView.getLocalExtras());
}
Also used : BidResponse(org.prebid.mobile.rendering.bidding.data.bid.BidResponse) MoPubBannerMediationUtils(com.mopub.mediation.MoPubBannerMediationUtils) MoPubView(com.mopub.mobileads.MoPubView) Test(org.junit.Test)

Aggregations

MoPubBannerMediationUtils (com.mopub.mediation.MoPubBannerMediationUtils)4 MoPubView (com.mopub.mobileads.MoPubView)3 Test (org.junit.Test)3 BidResponse (org.prebid.mobile.rendering.bidding.data.bid.BidResponse)2 Activity (android.app.Activity)1 MoPubInterstitialMediationUtils (com.mopub.mediation.MoPubInterstitialMediationUtils)1 MoPubNativeMediationUtils (com.mopub.mediation.MoPubNativeMediationUtils)1 MoPubRewardedVideoMediationUtils (com.mopub.mediation.MoPubRewardedVideoMediationUtils)1 MoPubInterstitial (com.mopub.mobileads.MoPubInterstitial)1 MoPubNative (com.mopub.nativeads.MoPubNative)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 OpenMediationBaseAdUnit (org.prebid.mobile.mopub.mock.OpenMediationBaseAdUnit)1 MediationBannerAdUnit (org.prebid.mobile.rendering.bidding.display.MediationBannerAdUnit)1 MediationInterstitialAdUnit (org.prebid.mobile.rendering.bidding.display.MediationInterstitialAdUnit)1 MediationNativeAdUnit (org.prebid.mobile.rendering.bidding.display.MediationNativeAdUnit)1 MediationRewardedVideoAdUnit (org.prebid.mobile.rendering.bidding.display.MediationRewardedVideoAdUnit)1 OnFetchCompleteListener (org.prebid.mobile.rendering.bidding.listeners.OnFetchCompleteListener)1