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; } }
setupBroadcast(); Clog.d(Clog.baseLogTag, Clog.getString(R.string.unhidden)); && !isMRAIDExpanded() && (mAdFetcher != null) && !loadedOffscreen) { start(); if (getChildAt(0) instanceof WebView) { WebView webView = (WebView) getChildAt(0); WebviewUtil.onResume(webView); dismantleBroadcast(); Clog.d(Clog.baseLogTag, Clog.getString(R.string.hidden)); if (mAdFetcher != null && loadAdHasBeenCalled) { stop(); if (getChildAt(0) instanceof WebView) { WebView webView = (WebView) getChildAt(0); WebviewUtil.onPause(webView);
/** * Loads a new ad, if the ad space is visible, and sets the * placement ID, ad width, and ad height attributes of the AdView. * * @param placementID The placement ID to use in this view. * @param width The width of the ad. * @param height The height of the ad. * @return <code>true</code> if the ad will begin loading, * <code>false</code> otherwise. */ public boolean loadAd(String placementID, int width, int height) { setAdSize(width, height); this.setPlacementID(placementID); return loadAd(); }
@Override public void run() { if (getChildAt(0) instanceof AdWebView) { AdWebView adWebView = (AdWebView) getChildAt(0); resizeWebViewToFitContainer(adWebView.getCreativeWidth(), adWebView.getCreativeHeight(), adWebView); adWebView.requestLayout(); } } });
setDefaultsBeforeXML(); int attr = a.getIndex(i); if (attr == R.styleable.BannerAdView_placement_id) { setPlacementID(a.getString(attr)); Clog.d(Clog.xmlLogTag, Clog.getString(R.string.placement_id, a.getString(attr))); } else if (attr == R.styleable.BannerAdView_auto_refresh_interval) { int period = a.getInt(attr, Settings.DEFAULT_REFRESH); setAutoRefreshInterval(period); if (period <= 0) { autoRefreshOffInXML = true; a.getInt(attr, -1))); } else if (attr == R.styleable.BannerAdView_should_reload_on_resume) { setShouldReloadOnResume(a.getBoolean(attr, false)); Clog.d(Clog.xmlLogTag, Clog.getString( R.string.xml_set_should_reload, shouldReloadOnResume)); } else if (attr == R.styleable.BannerAdView_opens_native_browser) { setOpensNativeBrowser(a.getBoolean(attr, false)); Clog.d(Clog.xmlLogTag, Clog.getString( R.string.xml_set_opens_native_browser, getOpensNativeBrowser())); } else if (attr == R.styleable.BannerAdView_expands_to_fit_screen_width) { setExpandsToFitScreenWidth(a.getBoolean(attr, false)); Clog.d(Clog.xmlLogTag, Clog.getString( R.string.xml_set_expands_to_full_screen_width, ));
@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); }
@Override public void setup() { super.setup(); bannerAdView = new BannerAdView(activity); bannerAdView.setPlacementID("0"); bannerAdView.setAdListener(this); bannerAdView.setAdSize(320, 50); bannerAdView.setAutoRefreshInterval(-1); interstitialAdView = new InterstitialAdView(activity); interstitialAdView.setPlacementID("0"); interstitialAdView.setAdListener(this); adLoaded = false; adFailed = false; adExpanded = false; adCollapsed = false; adClicked = false; adClickedWithUrl = false; }
@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); }
private void executeBannerRequest(){ bannerAdView.setAutoRefreshInterval(30); bannerAdView.loadAd(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); }
private void executeBannerRequest() { bannerAdView.setAutoRefreshInterval(15); bannerAdView.loadAdOffscreen(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); }
@Test public void testClickThroughDependencyOnOpensNativeFalse() { bannerAdView.setClickThroughAction(ANClickThroughAction.RETURN_URL); bannerAdView.setOpensNativeBrowser(false); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.anNativeWithoutImages())); requestManager = new AdViewRequestManager(bannerAdView); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertClickThroughAction(); assertClickThroughAction(ANClickThroughAction.OPEN_SDK_BROWSER); }
@Override public void setup() { super.setup(); bannerAdView = new BannerAdView(activity); requestParameters = bannerAdView.requestParameters; // This would later be over-ridden by test specific values bannerAdView.setAdSize(320,50); }
/** * Set the size of the ad to request. * Use only one out of setMaxSize(maxW,maxH) or setAdSize(w,h) or setAdSizes(ArrayList<AdSizes>). Using one will override the value set by other. * * @param w The width of the ad, in pixels. * @param h The height of the ad, in pixels. */ public void setAdSize(int w, int h) { Clog.d(Clog.baseLogTag, Clog.getString(R.string.set_size, w, h)); ArrayList<AdSize> adSizeArrayList = new ArrayList(); adSizeArrayList.add(new AdSize(w, h)); setAdSizes(adSizeArrayList); }
private void loadMraidBanner(String testName) { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.mraidBanner(testName))); requestManager = new AdViewRequestManager(bannerAdView); requestManager.execute(); // let AdFetcher queue AdRequest waitForTasks(); // Flush AAID tasks before AdRequest tasks twice to make sure AdRequest gets executed Robolectric.flushForegroundThreadScheduler(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertTrue(bannerAdView.getChildAt(0) instanceof WebView); webView = (WebView) bannerAdView.getChildAt(0); }
private void setAdSize(){ bannerAdView.setAdSize(720,90); }
/** * Creates a new BannerAdView in which to load and show ads. * * @param context The context of the {@link ViewGroup} to which * the BannerAdView is being added. * @param refresh_interval The desired refresh rate, in * milliseconds. The default value is 30 * seconds; minimum is 15. A value of 0 * turns auto-refreshing off. */ public BannerAdView(Context context, int refresh_interval) { super(context); this.setAutoRefreshInterval(refresh_interval); }
public void assertLoadsInBackground() { assertEquals(bannerAdView.getLoadsInBackground(), ((ANNativeAdResponse) nativeAdResponse).getLoadsInBackground()); }
public void assertOpensInNativeBrowser() { assertEquals(bannerAdView.getOpensNativeBrowser(), ((ANNativeAdResponse) nativeAdResponse).isOpenNativeBrowser()); }
private void executeBannerRequest() { bannerAdView.loadAd(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); }
private void executeBannerRequest() { bannerAdView.setAutoRefreshInterval(15); bannerAdView.loadAdOffscreen(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); }