@Test public void testBannerNativeSwitchingAdTypes() { bannerAdView.setAutoRefreshInterval(15000); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.banner())); Assert.assertEquals(AdType.UNKNOWN, bannerAdView.getAdType()); requestManager = new AdViewRequestManager(bannerAdView); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); Assert.assertEquals(15000, bannerAdView.getAutoRefreshInterval()); Assert.assertEquals(AdType.BANNER, bannerAdView.getAdType()); assertCallbacks(true); assertBannerAdResponse(true); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.anNativeWithoutImages())); bannerAdView.setAllowNativeDemand(true, 127); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); Assert.assertEquals(15000, bannerAdView.getAutoRefreshInterval()); Assert.assertEquals(AdType.NATIVE, bannerAdView.getAdType()); Assert.assertEquals(127, bannerAdView.getRendererId()); assertCallbacks(true); assertBannerAdResponse(false); }
@Test public void testBannerNativeAdLoaded() { bannerAdView.setAutoRefreshInterval(30000); bannerAdView.setLoadsInBackground(false); bannerAdView.setOpensNativeBrowser(false); bannerAdView.setClickThroughAction(ANClickThroughAction.RETURN_URL); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.anNativeWithoutImages())); Assert.assertEquals(AdType.UNKNOWN, bannerAdView.getAdType()); requestManager = new AdViewRequestManager(bannerAdView); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); Assert.assertEquals(30000, bannerAdView.getAutoRefreshInterval()); Assert.assertEquals(AdType.NATIVE, bannerAdView.getAdType()); assertCallbacks(true); assertOpensInNativeBrowser(); assertLoadsInBackground(); assertClickThroughAction(); assertClickThroughAction(ANClickThroughAction.RETURN_URL); }