public OleasterRobolectricRunner( Class<?> testClass, SdkEnvironment sandbox, Config config, AndroidManifest androidManifest) throws InitializationError { super(testClass); this.sandbox = sandbox; this.config = config; this.androidManifest = androidManifest; }
protected void beforeTest(Sandbox sandbox, Spec spec) throws Throwable { SdkEnvironment sdkEnvironment = (SdkEnvironment) sandbox; RoboSpec roboSpec = (RoboSpec) spec; roboSpec.parallelUniverseInterface = getHooksInterface(sdkEnvironment); Class<TestLifecycle> cl = sdkEnvironment.bootstrappedClass(getTestLifecycleClass()); roboSpec.testLifecycle = ReflectionHelpers.newInstance(cl); final Config config = roboSpec.config; final AndroidManifest appManifest = roboSpec.getAppManifest(); roboSpec.parallelUniverseInterface.setSdkConfig((sdkEnvironment).getSdkConfig()); roboSpec.parallelUniverseInterface.resetStaticState(config); SdkConfig sdkConfig = roboSpec.sdkConfig; Class<?> androidBuildVersionClass = (sdkEnvironment).bootstrappedClass(Build.VERSION.class); ReflectionHelpers.setStaticField(androidBuildVersionClass, "SDK_INT", sdkConfig.getApiLevel()); ReflectionHelpers.setStaticField(androidBuildVersionClass, "RELEASE", sdkConfig.getAndroidVersion()); ReflectionHelpers.setStaticField(androidBuildVersionClass, "CODENAME", sdkConfig.getAndroidCodeName()); PackageResourceTable systemResourceTable = sdkEnvironment.getSystemResourceTable(getJarResolver()); PackageResourceTable appResourceTable = getAppResourceTable(appManifest); // This will always be non empty since every class has basic methods like toString. Method randomMethod = getTestClass().getJavaClass().getMethods()[0]; roboSpec.parallelUniverseInterface.setUpApplicationState( randomMethod, roboSpec.testLifecycle, appManifest, config, new RoutingResourceTable(getCompiletimeSdkResourceTable(), appResourceTable), new RoutingResourceTable(systemResourceTable, appResourceTable), new RoutingResourceTable(systemResourceTable)); roboSpec.testLifecycle.beforeTest(null); }
@Override protected void configureShadows(SdkEnvironment sdkEnvironment, Config config) { super.configureShadows(sdkEnvironment, config); }