Java 类org.robolectric.internal.SdkEnvironment 实例源码

项目:Oleaster    文件:OleasterRobolectricRunner.java   
public OleasterRobolectricRunner(
        Class<?> testClass,
        SdkEnvironment sandbox,
        Config config,
        AndroidManifest androidManifest)
        throws
        InitializationError {
    super(testClass);
    this.sandbox = sandbox;

    this.config = config;
    this.androidManifest = androidManifest;
}
项目:Oleaster    文件:OleasterRobolectricRunner.java   
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);
}
项目:loadie    文件:MyRobolectricTestRunner.java   
@Override
protected void configureShadows(SdkEnvironment sdkEnvironment, Config config) {
    super.configureShadows(sdkEnvironment, config);
}
项目:retain-state    文件:MyRobolectricTestRunner.java   
@Override
protected void configureShadows(SdkEnvironment sdkEnvironment, Config config) {
    super.configureShadows(sdkEnvironment, config);
}