/** * Create an {@link InstrumentationConfiguration} suitable for the provided {@link FrameworkMethod}. * * Custom TestRunner subclasses may wish to override this method to provide alternate configuration. * * @return an {@link InstrumentationConfiguration} */ private InstrumentationConfiguration createClassLoaderConfig(Config config) { InstrumentationConfiguration.Builder builder = InstrumentationConfiguration.newBuilder() .doNotAcquirePackage("java.") .doNotAcquirePackage("sun.") .doNotAcquirePackage("org.robolectric.annotation.") .doNotAcquirePackage("org.robolectric.internal.") .doNotAcquirePackage("org.robolectric.util.") .doNotAcquirePackage("org.junit."); for (Class<?> shadowClass : getExtraShadows()) { ShadowMap.ShadowInfo shadowInfo = ShadowMap.getShadowInfo(shadowClass); builder.addInstrumentedClass(shadowInfo.getShadowedClassName()); } addInstrumentedPackages(builder); AndroidConfigurer.configure(builder, getInterceptors()); AndroidConfigurer.withConfig(builder, config); return builder.build(); }
private ShadowMap createShadowMap() { return ShadowMap.EMPTY; }
private ClassHandler createClassHandler(ShadowMap shadowMap, SdkEnvironment sdkEnvironment) { return new ShadowWrangler(shadowMap, sdkEnvironment.getSdkConfig().getApiLevel(), interceptors); }
@Override protected ShadowMap createShadowMap() { return super.createShadowMap() .newBuilder() .build(); }
private void configureShadows(SdkEnvironment sdkEnvironment) { ShadowMap.Builder builder = createShadowMap().newBuilder(); // Configure shadows *BEFORE* setting the ClassLoader. This is necessary because // creating the ShadowMap loads all ShadowProvider s via ServiceLoader and this is // not available once we install the Robolectric class loader. ShadowMap shadowMap = builder.build(); sdkEnvironment.replaceShadowMap(shadowMap); sdkEnvironment.configure(createClassHandler(shadowMap, sdkEnvironment), getInterceptors()); }