@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()); }
static String reflectedGetAdvertisingId(final Object adInfo, final String defaultValue) { try { return (String) MethodBuilderFactory.create(adInfo, "getId").execute(); } catch (Exception exception) { return defaultValue; } }
@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(); }
static boolean reflectedIsLimitAdTrackingEnabled( final Object adInfo, final boolean defaultValue) { try { Boolean result = (Boolean) MethodBuilderFactory.create(adInfo, "isLimitAdTrackingEnabled").execute(); return (result != null) ? result : defaultValue; } catch (Exception exception) { return defaultValue; } }
static boolean isGpsAvailable(final Context context) { try { MethodBuilder methodBuilder = MethodBuilderFactory.create(null, "isGooglePlayServicesAvailable") .setStatic(Class.forName(sPlayServicesUtilClassName)) .addParam(Context.class, context); Object result = methodBuilder.execute(); return (result != null && (Integer) result == GOOGLE_PLAY_SUCCESS_CODE); } catch (Exception exception) { return false; } }