Java 类org.robolectric.TestLifecycle 实例源码

项目: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);
}
项目:lmis-moz-mobile    文件:LMISTestRunner.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return MyTestLifeCycle.class;
}
项目:Fabric-Example-App-Android    文件:SdkTestRunner.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return TestLifeCycleWithInjection.class;
}
项目:FullRobolectricTestSample    文件:CustomRobolectricTestRunnerTest.java   
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() {
  return X.class;
}
项目:FullRobolectricTestSample    文件:CustomRobolectricTestRunnerTest.java   
@Override protected Class<? extends TestLifecycle> getTestLifecycleClass() {
  return MyTestLifecycle.class;
}
项目:android-unittesting    文件:RobolectricGradleTestRunner.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return MyTestLifecycle.class;
}
项目:Android_Yellow_Pages_App_TDD    文件:RobolectricTestRunnerWithInjection.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return TestLifeCycleWithInjection.class;
}
项目:injected-test-runner    文件:InjectedTestRunner.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return TestLifecycleWithMockito.class;
}
项目:injected-test-runner    文件:DaggerInjectedTestRunner.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return TestLifecycleWithMockito.class;
}
项目:Android_Yellow_Pages_App_Content_Provider    文件:RobolectricTestRunnerWithInjection.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return TestLifeCycleWithInjection.class;
}
项目:piwik-sdk-android    文件:FullEnvTestRunner.java   
@Override
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return FullEnvTestLifeCycle.class;
}
项目:Oleaster    文件:OleasterRobolectricRunner.java   
/**
 * An instance of the returned class will be created for each test invocation.
 *
 * Custom TestRunner subclasses may wish to override this method to provide alternate configuration.
 *
 * @return a class which implements {@link TestLifecycle}. This implementation returns a {@link DefaultTestLifecycle}.
 */
protected Class<? extends TestLifecycle> getTestLifecycleClass() {
    return DefaultTestLifecycle.class;
}
项目:FullRobolectricTestSample    文件:ParallelUniverseInterface.java   
void setUpApplicationState(Method method, TestLifecycle testLifecycle, boolean strictI18n, ResourceLoader systemResourceLoader, AndroidManifest appManifest, Config config);