use of org.robolectric.internal.AndroidSandbox in project robolectric by robolectric.
the class RobolectricTestRunner method beforeTest.
@Override
protected void beforeTest(Sandbox sandbox, FrameworkMethod method, Method bootstrappedMethod) throws Throwable {
AndroidSandbox androidSandbox = (AndroidSandbox) sandbox;
RobolectricFrameworkMethod roboMethod = (RobolectricFrameworkMethod) method;
PerfStatsCollector perfStatsCollector = PerfStatsCollector.getInstance();
Sdk sdk = roboMethod.getSdk();
perfStatsCollector.putMetadata(AndroidMetadata.class, new AndroidMetadata(ImmutableMap.of("ro.build.version.sdk", "" + sdk.getApiLevel()), roboMethod.resourcesMode.name()));
Logger.lifecycle(roboMethod.getDeclaringClass().getName() + "." + roboMethod.getMethod().getName() + ": sdk=" + sdk.getApiLevel() + "; resources=" + roboMethod.resourcesMode);
if (roboMethod.resourcesMode == ResourcesMode.LEGACY) {
Logger.warn("Legacy resources mode is deprecated; see" + " http://robolectric.org/migrating/#migrating-to-40");
}
roboMethod.setStuff(androidSandbox, androidSandbox.getTestEnvironment());
Class<TestLifecycle> cl = androidSandbox.bootstrappedClass(getTestLifecycleClass());
roboMethod.testLifecycle = ReflectionHelpers.newInstance(cl);
AndroidManifest appManifest = roboMethod.getAppManifest();
roboMethod.getTestEnvironment().setUpApplicationState(bootstrappedMethod, roboMethod.getConfiguration(), appManifest);
roboMethod.testLifecycle.beforeTest(bootstrappedMethod);
}
Aggregations