@Override public void prepareTest(Object test) { AdFetcherFactory.setInstance(new TestAdFetcherFactory()); HttpClientFactory.setInstance(new TestHttpClientFactory()); DateAndTime.setInstance(new TestDateAndTime()); CustomEventBannerFactory.setInstance(new TestCustomEventBannerFactory()); CustomEventInterstitialFactory.setInstance(new TestCustomEventInterstitialFactory()); CustomEventBannerAdapterFactory.setInstance(new TestCustomEventBannerAdapterFactory()); MraidViewFactory.setInstance(new TestMraidViewFactory()); MoPubViewFactory.setInstance(new TestMoPubViewFactory()); CustomEventInterstitialAdapterFactory.setInstance( new TestCustomEventInterstitialAdapterFactory()); HtmlBannerWebViewFactory.setInstance(new TestHtmlBannerWebViewFactory()); HtmlInterstitialWebViewFactory.setInstance(new TestHtmlInterstitialWebViewFactory()); AdViewControllerFactory.setInstance(new TestAdViewControllerFactory()); ViewGestureDetectorFactory.setInstance(new TestViewGestureDetectorFactory()); VastManagerFactory.setInstance(new TestVastManagerFactory()); VastVideoDownloadTaskFactory.setInstance(new TestVastVideoDownloadTaskFactory()); MethodBuilderFactory.setInstance(new TestMethodBuilderFactory()); CustomEventNativeFactory.setInstance(new TestCustomEventNativeFactory()); ShadowAsyncTasks.reset(); MoPubEvents.setEventDispatcher(mock(MoPubEvents.EventDispatcher.class)); MoPub.setLocationAwareness(LocationAwareness.NORMAL); MoPub.setLocationPrecision(6); MockitoAnnotations.initMocks(test); AsyncTasks.setExecutor(new RobolectricBackgroundExecutorService()); }
public MoPubView(Context context, AttributeSet attrs) { super(context, attrs); ManifestUtils.checkWebViewActivitiesDeclared(context); mContext = context; mScreenVisibility = getVisibility(); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); // There is a rare bug in Froyo/2.2 where creation of a WebView causes a // NullPointerException. (http://code.google.com/p/android/issues/detail?id=10789) // It happens when the WebView can't access the local file store to make a cache file. // Here, we'll work around it by trying to create a file store and then just go inert // if it's not accessible. if (WebViewDatabase.getInstance(context) == null) { MoPubLog.e( "Disabling MoPub. Local cache file is inaccessible so MoPub will " + "fail if we try to create a WebView. Details of this Android bug found at:" + "http://code.google.com/p/android/issues/detail?id=10789"); return; } mAdViewController = AdViewControllerFactory.create(context, this); registerScreenStateBroadcastReceiver(); }
@Override public void prepareTest(Object test) { ClientMetadata.clearForTesting(); DateAndTime.setInstance(new TestDateAndTime()); CustomEventBannerFactory.setInstance(new TestCustomEventBannerFactory()); CustomEventInterstitialFactory.setInstance(new TestCustomEventInterstitialFactory()); CustomEventBannerAdapterFactory.setInstance(new TestCustomEventBannerAdapterFactory()); MoPubViewFactory.setInstance(new TestMoPubViewFactory()); CustomEventInterstitialAdapterFactory.setInstance( new TestCustomEventInterstitialAdapterFactory()); HtmlBannerWebViewFactory.setInstance(new TestHtmlBannerWebViewFactory()); HtmlInterstitialWebViewFactory.setInstance(new TestHtmlInterstitialWebViewFactory()); AdViewControllerFactory.setInstance(new TestAdViewControllerFactory()); VastManagerFactory.setInstance(new TestVastManagerFactory()); MethodBuilderFactory.setInstance(new TestMethodBuilderFactory()); CustomEventNativeFactory.setInstance(new TestCustomEventNativeFactory()); MraidControllerFactory.setInstance(new TestMraidControllerFactory()); ShadowAsyncTasks.reset(); ShadowMoPubHttpUrlConnection.reset(); MoPubEvents.setEventDispatcher(mock(EventDispatcher.class)); MoPub.setLocationAwareness(LocationAwareness.NORMAL); MoPub.setLocationPrecision(6); MockitoAnnotations.initMocks(test); AsyncTasks.setExecutor(new RoboExecutorService()); CacheService.clearAndNullCaches(); }