use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class UtilTest method testApplyBidsToMoPubAdobject.
@Test
public void testApplyBidsToMoPubAdobject() throws Exception {
MoPubView adView = new MoPubView(activity);
adView.setKeywords("key1:value1,key2:value2");
HashMap<String, String> bids = new HashMap<>();
bids.put("hb_pb", "0.50");
bids.put("hb_cache_id", "123456");
Util.apply(bids, adView);
String adViewKeywords = adView.getKeywords();
assertEquals("hb_pb:0.50,hb_cache_id:123456,key1:value1,key2:value2", adViewKeywords);
Util.apply(null, adView);
assertEquals("key1:value1,key2:value2", adView.getKeywords());
MoPubInterstitial instl = new MoPubInterstitial(activity, "123456");
instl.setKeywords("key1:value1,key2:value2");
Util.apply(bids, instl);
assertEquals("hb_pb:0.50,hb_cache_id:123456,key1:value1,key2:value2", instl.getKeywords());
Util.apply(null, instl);
assertEquals("key1:value1,key2:value2", instl.getKeywords());
}
use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class ExtraTests method testAppNexusKeyValueTargeting.
@Test
public void testAppNexusKeyValueTargeting() throws Exception {
PrebidMobile.setApplicationContext(m.getActivity().getApplicationContext());
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0");
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
adObject.setAdUnitId(Constants.MOPUB_BANNER_ADUNIT_ID_300x250_APPNEXUS);
adObject.setMinimumHeight(250);
adObject.setMinimumWidth(300);
BannerAdUnit adUnit = new BannerAdUnit("67bac530-9832-4f78-8c94-fbf88ac7bd14", 300, 250);
OnCompleteListener l = new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
FrameLayout adFrame = m.getActivity().findViewById(R.id.adFrame);
adFrame.addView(adObject);
adObject.loadAd();
}
};
listener[0] = spy(l);
adUnit.fetchDemand(adObject, listener[0]);
}
});
Thread.sleep(10000);
verify(listener[0], times(1)).onComplete(ResultCode.SUCCESS);
onView(withId(R.id.adFrame)).check(matches(isDisplayed()));
onWebView().check(webMatches(getCurrentUrl(), containsString("ads.mopub.com")));
onWebView().check(webContent(containingTextInBody("ucTag.renderAd")));
}
use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class ExtraTests method testEmptyInvalidPrebidServerAccountId.
@Test
public void testEmptyInvalidPrebidServerAccountId() throws Exception {
PrebidMobile.setApplicationContext(m.getActivity().getApplicationContext());
PrebidMobile.setPrebidServerAccountId("");
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
adObject.setAdUnitId(Constants.MOPUB_BANNER_ADUNIT_ID_300x250_APPNEXUS);
adObject.setMinimumHeight(250);
adObject.setMinimumWidth(300);
BannerAdUnit adUnit = new BannerAdUnit("67bac530-9832-4f78-8c94-fbf88ac7bd14", 300, 250);
OnCompleteListener l = new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
FrameLayout adFrame = m.getActivity().findViewById(R.id.adFrame);
adFrame.addView(adObject);
adObject.loadAd();
}
};
listener[0] = spy(l);
adUnit.fetchDemand(adObject, listener[0]);
}
});
Thread.sleep(1000);
verify(listener[0], times(1)).onComplete(ResultCode.INVALID_ACCOUNT_ID);
}
use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class ExtraTests method testRubiconInvalidPrebidServerAccountId.
@Test
public void testRubiconInvalidPrebidServerAccountId() throws Exception {
PrebidMobile.setApplicationContext(m.getActivity().getApplicationContext());
PrebidMobile.setPrebidServerAccountId("1001_ERROR");
PrebidMobile.setPrebidServerHost(Host.RUBICON);
PrebidMobile.setShareGeoLocation(true);
final OnCompleteListener[] listener = new OnCompleteListener[1];
mHandler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
adObject.setAdUnitId(Constants.MOPUB_BANNER_ADUNIT_ID_300x250_RUBICON);
adObject.setMinimumHeight(250);
adObject.setMinimumWidth(300);
BannerAdUnit adUnit = new BannerAdUnit("1001-1", 300, 250);
OnCompleteListener l = new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
FrameLayout adFrame = m.getActivity().findViewById(R.id.adFrame);
adFrame.addView(adObject);
adObject.loadAd();
}
};
listener[0] = spy(l);
adUnit.fetchDemand(adObject, listener[0]);
}
});
Thread.sleep(2000);
verify(listener[0], times(1)).onComplete(ResultCode.INVALID_ACCOUNT_ID);
}
use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class ExtraTests method testMultipleDemand.
@Test
public void testMultipleDemand() throws Exception {
final ArrayList<AdUnit> adUnits = new ArrayList<AdUnit>();
final ArrayList<OnCompleteListener> spies = new ArrayList<>();
PrebidMobile.setApplicationContext(m.getActivity().getApplicationContext());
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0");
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setShareGeoLocation(true);
mHandler.post(new Runnable() {
@Override
public void run() {
final MoPubView adObject = new MoPubView(m.getActivity());
adObject.setAdUnitId(Constants.MOPUB_BANNER_ADUNIT_ID_300x250_APPNEXUS);
adObject.setMinimumWidth(300);
adObject.setMinimumHeight(250);
BannerAdUnit adUnit = new BannerAdUnit("1cfdfe39-18f2-45b9-964f-63d64cdc0399", 300, 250);
adUnits.add(adUnit);
OnCompleteListener l = new OnCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
String keywords = adObject.getKeywords();
String[] keywordsArray = keywords.split(",");
assertEquals(15, keywordsArray.length);
assertTrue(keywords.contains("hb_pb:1.20"));
assertTrue(keywords.contains("hb_pb_rubicon:1.20"));
assertTrue(keywords.contains("hb_cache_id:"));
assertTrue(keywords.contains("hb_pb_appnexus:0.50"));
assertTrue(keywords.contains("hb_cache_id_appnexus:"));
FrameLayout adFrame = m.getActivity().findViewById(R.id.adFrame);
adFrame.addView(adObject);
adObject.loadAd();
}
};
l = spy(l);
spies.add(l);
adUnit.fetchDemand(adObject, l);
}
});
Thread.sleep(10000);
verify(spies.get(0), times(1)).onComplete(ResultCode.SUCCESS);
onWebView().check(webContent(containingTextInBody("ucTag.renderAd")));
}
Aggregations