void start() { Clog.d("BannerAdView", getAdType().name()); /* * To check if it does not triggers AUTO_REFRESH * for video Ads (rendered using BannerAdView) */ if (getAdType() != AdType.VIDEO) { Clog.d(Clog.publicFunctionsLogTag, Clog.getString(R.string.start)); mAdFetcher.start(); loadAdHasBeenCalled = true; } }
@Test public void testgetAdTypeUnKnown() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blankBanner())); // First queue a regular HTML banner response assertTrue(bannerAdView.getAdType() == AdType.UNKNOWN); // First tests if ad_type is UNKNOWN initially executeBannerRequest(); assertTrue(bannerAdView.getAdType() == AdType.UNKNOWN); // If a HTML banner is served then BANNER }
@Test public void testgetAdTypeBanner() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.banner())); // First queue a regular HTML banner response assertTrue(bannerAdView.getAdType() == AdType.UNKNOWN); // First tests if ad_type is UNKNOW initially executeBannerRequest(); assertTrue(bannerAdView.getAdType() == AdType.BANNER); // If a HTML banner is served then BANNER }
@Test public void testgetAdTypeVideo() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.rtbVASTVideo())); // First queue a regular HTML banner response assertTrue(bannerAdView.getAdType() == AdType.UNKNOWN); // First tests if ad_type is UNKNOW initially executeBannerRequest(); assertTrue(bannerAdView.getAdType() == AdType.VIDEO); // If a VAST Video is served then VIDEO }
@Test public void testgetAdTypeBannerNative() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.anNativeVideo())); // First queue a regular HTML banner response assertTrue(bannerAdView.getAdType() == AdType.UNKNOWN); // First tests if ad_type is UNKNOWN initially executeBannerRequest(); assertTrue(bannerAdView.getAdType() == AdType.NATIVE); // If a Native Ad is served then NATIVE assertTrue(nativeAdResponse.getCreativeId().equalsIgnoreCase("47772560")); assertTrue(nativeAdResponse.getIconUrl().equalsIgnoreCase("http://path_to_icon.com")); assertTrue(nativeAdResponse.getIcon() == null); assertTrue(nativeAdResponse.getImage() == null); assertTrue(nativeAdResponse.getImageUrl().equalsIgnoreCase("http://path_to_main.com")); assertTrue(nativeAdResponse.getTitle().equalsIgnoreCase("test title")); assertTrue(nativeAdResponse.getDescription().equalsIgnoreCase("test description")); assertTrue(nativeAdResponse.getAdditionalDescription().equalsIgnoreCase("additional test description")); assertTrue(nativeAdResponse.getImageSize().getHeight() == 200); assertTrue(nativeAdResponse.getImageSize().getWidth() == 300); assertTrue(nativeAdResponse.getIconSize().getHeight() == 150); assertTrue(nativeAdResponse.getIconSize().getWidth() == 100); assertEquals("<VAST>content</VAST>",nativeAdResponse.getVastXml()); assertEquals("http://ib.adnxs.com/privacy...",nativeAdResponse.getPrivacyLink()); }
@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); }