protected void configureShadows(SdkEnvironment sdkEnvironment, Config config) { ShadowMap shadowMap = createShadowMap(); if (config != null) { Class<?>[] shadows = config.shadows(); if (shadows.length > 0) { shadowMap = shadowMap.newBuilder() .addShadowClasses(shadows) .build(); } } ClassHandler classHandler = getClassHandler(sdkEnvironment, shadowMap); injectClassHandler(sdkEnvironment.getRobolectricClassLoader(), classHandler); }
private ClassHandler getClassHandler(SdkEnvironment sdkEnvironment, ShadowMap shadowMap) { ClassHandler classHandler; synchronized (sdkEnvironment) { classHandler = sdkEnvironment.classHandlersByShadowMap.get(shadowMap); if (classHandler == null) { classHandler = createClassHandler(shadowMap, sdkEnvironment.getSdkConfig()); } sdkEnvironment.setCurrentClassHandler(classHandler); } return classHandler; }
protected ShadowMap createShadowMap() { synchronized (RobolectricTestRunner.class) { if (mainShadowMap != null) return mainShadowMap; mainShadowMap = new ShadowMap.Builder() //.addShadowClasses(RobolectricBase.DEFAULT_SHADOW_CLASSES) .build(); //mainShadowMap = new ShadowMap.Builder() // .addShadowClasses(RobolectricBase.DEFAULT_SHADOW_CLASSES) // .build(); return mainShadowMap; } }
/** * Adds custom shadow classes to Robolectric shadow map. */ @Override protected ShadowMap createShadowMap() { return super.createShadowMap() .newBuilder() .addShadowClass(ShadowMapView.class) .addShadowClass(ShadowVectorTileLayer.class) .addShadowClass(ShadowGLMatrix.class) .addShadowClass(ShadowGLShader.class) .addShadowClass(ShadowGLState.class) .addShadowClass(ShadowMint.class) .addShadowClass(ShadowSupportMenuInflater.class) .build(); }
@Override protected ShadowMap createShadowMap() { return super.createShadowMap() .newBuilder() .addShadowClass(ShadowAsyncTaskLoader.class) .build(); }
protected ClassHandler createClassHandler(ShadowMap shadowMap, SdkConfig sdkConfig) { return new ShadowWrangler(shadowMap, sdkConfig); }
@Override protected ShadowMap createShadowMap() { // Don't do any class binding except the bare minimum, because that's what we're trying to test here. return new ShadowMap.Builder() .addShadowClass(ShadowSystemProperties.class) .build(); }
@Override protected ShadowMap createShadowMap() { // Don't do any class binding, because that's what we're trying to test here. return ShadowMap.EMPTY; }