use of org.robolectric.res.PackageResourceTable in project robolectric by robolectric.
the class RobolectricTestRunner method beforeTest.
@Override
protected void beforeTest(Sandbox sandbox, FrameworkMethod method, Method bootstrappedMethod) throws Throwable {
SdkEnvironment sdkEnvironment = (SdkEnvironment) sandbox;
RobolectricFrameworkMethod roboMethod = (RobolectricFrameworkMethod) method;
roboMethod.parallelUniverseInterface = getHooksInterface(sdkEnvironment);
Class<TestLifecycle> cl = sdkEnvironment.bootstrappedClass(getTestLifecycleClass());
roboMethod.testLifecycle = ReflectionHelpers.newInstance(cl);
final Config config = roboMethod.config;
final AndroidManifest appManifest = roboMethod.getAppManifest();
roboMethod.parallelUniverseInterface.setSdkConfig((sdkEnvironment).getSdkConfig());
roboMethod.parallelUniverseInterface.resetStaticState(config);
SdkConfig sdkConfig = roboMethod.sdkConfig;
Class<?> androidBuildVersionClass = (sdkEnvironment).bootstrappedClass(Build.VERSION.class);
ReflectionHelpers.setStaticField(androidBuildVersionClass, "SDK_INT", sdkConfig.getApiLevel());
ReflectionHelpers.setStaticField(androidBuildVersionClass, "RELEASE", sdkConfig.getAndroidVersion());
PackageResourceTable systemResourceTable = sdkEnvironment.getSystemResourceTable(getJarResolver());
PackageResourceTable appResourceTable = getAppResourceTable(appManifest);
roboMethod.parallelUniverseInterface.setUpApplicationState(bootstrappedMethod, roboMethod.testLifecycle, appManifest, config, new RoutingResourceTable(getCompiletimeSdkResourceTable(), appResourceTable), new RoutingResourceTable(systemResourceTable, appResourceTable), new RoutingResourceTable(systemResourceTable));
roboMethod.testLifecycle.beforeTest(bootstrappedMethod);
}
use of org.robolectric.res.PackageResourceTable in project robolectric by robolectric.
the class RobolectricTestRunner method getAppResourceTable.
private PackageResourceTable getAppResourceTable(final AndroidManifest appManifest) {
PackageResourceTable resourceTable = appResourceTableCache.get(appManifest);
if (resourceTable == null) {
resourceTable = ResourceMerger.buildResourceTable(appManifest);
appResourceTableCache.put(appManifest, resourceTable);
}
return resourceTable;
}
Aggregations