use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class ResultCodeTest method testNetworkError.
@Test
public void testNetworkError() {
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
PrebidMobile.setPrebidServerAccountId("123456");
ConnectivityManager connectivityManager = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
ShadowNetworkInfo shadowOfActiveNetworkInfo = shadowOf(connectivityManager.getActiveNetworkInfo());
shadowOfActiveNetworkInfo.setConnectionStatus(false);
BannerAdUnit adUnit = new BannerAdUnit("123456", 300, 250);
MoPubView testView = new MoPubView(activity);
OnCompleteListener mockListener = mock(OnCompleteListener.class);
adUnit.fetchDemand(testView, mockListener);
verify(mockListener).onComplete(ResultCode.NETWORK_ERROR);
}
use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class ResultCodeTest method testInvalidContext.
@Test
public void testInvalidContext() throws Exception {
HttpUrl httpUrl = server.url("/");
Host.CUSTOM.setHostUrl(httpUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setPrebidServerAccountId("123456");
PrebidMobile.setApplicationContext(null);
server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.oneBidFromAppNexus()));
InterstitialAdUnit adUnit = new InterstitialAdUnit("123456");
MoPubView testView = new MoPubView(activity);
OnCompleteListener mockListener = mock(OnCompleteListener.class);
adUnit.fetchDemand(testView, mockListener);
verify(mockListener).onComplete(ResultCode.INVALID_CONTEXT);
}
use of com.mopub.mobileads.MoPubView in project prebid-mobile-android by prebid.
the class UtilTest method testSupportedAdObject.
@Test
public void testSupportedAdObject() throws Exception {
MoPubView testView = new MoPubView(activity);
assertTrue(Util.supportedAdObject(testView));
assertFalse(Util.supportedAdObject(null));
MoPubInterstitial interstitial = new MoPubInterstitial(activity, "");
assertTrue(Util.supportedAdObject(interstitial));
AdManagerAdRequest request = new AdManagerAdRequest.Builder().build();
assertTrue(Util.supportedAdObject(request));
AdManagerAdRequest.Builder requestBuilder = new AdManagerAdRequest.Builder();
assertTrue(Util.supportedAdObject(requestBuilder));
Object object = new Object();
assertFalse(Util.supportedAdObject(object));
}
Aggregations