use of org.robolectric.shadows.ShadowNetworkInfo 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);
}
Aggregations