use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class ResourceMergerTest method libraryConfigShouldOverrideProjectProperties.
@Test
@Config(manifest = "src/test/resources/TestAndroidManifest.xml", libraries = "lib1")
public void libraryConfigShouldOverrideProjectProperties() throws Exception {
AndroidManifest manifest = Shadows.shadowOf(RuntimeEnvironment.application).getAppManifest();
List<AndroidManifest> libraryManifests = manifest.getLibraryManifests();
assertEquals(1, libraryManifests.size());
assertEquals("org.robolectric.lib1", libraryManifests.get(0).getPackageName());
}
use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class DefaultPackageManager method getProviderInfo.
@Override
public ProviderInfo getProviderInfo(ComponentName className, int flags) throws NameNotFoundException {
String packageName = className.getPackageName();
AndroidManifest androidManifest = androidManifests.get(packageName);
String classString = resolvePackageName(packageName, className);
for (ContentProviderData contentProviderData : androidManifest.getContentProviders()) {
if (contentProviderData.getClassName().equals(classString)) {
ProviderInfo providerInfo = new ProviderInfo();
providerInfo.packageName = packageName;
providerInfo.name = contentProviderData.getClassName();
// todo: support multiple authorities
providerInfo.authority = contentProviderData.getAuthorities();
providerInfo.readPermission = contentProviderData.getReadPermission();
providerInfo.writePermission = contentProviderData.getWritePermission();
providerInfo.pathPermissions = createPathPermissions(contentProviderData.getPathPermissionDatas());
if ((flags & GET_META_DATA) != 0) {
providerInfo.metaData = metaDataToBundle(contentProviderData.getMetaData().getValueMap());
}
return providerInfo;
}
}
return null;
}
use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class DefaultPackageManager method getServiceInfo.
@Override
public ServiceInfo getServiceInfo(ComponentName className, int flags) throws NameNotFoundException {
String packageName = className.getPackageName();
AndroidManifest androidManifest = androidManifests.get(packageName);
String serviceName = className.getClassName();
ServiceData serviceData = androidManifest.getServiceData(serviceName);
if (serviceData == null) {
throw new NameNotFoundException(serviceName);
}
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.packageName = packageName;
serviceInfo.name = serviceName;
serviceInfo.applicationInfo = getApplicationInfo(packageName, flags);
serviceInfo.permission = serviceData.getPermission();
if ((flags & GET_META_DATA) != 0) {
serviceInfo.metaData = metaDataToBundle(serviceData.getMetaData().getValueMap());
}
return serviceInfo;
}
use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class ManifestFactoryTest method shouldLoadLibraryManifests.
@Test
public void shouldLoadLibraryManifests() throws Exception {
Properties properties = new Properties();
properties.setProperty("manifest", resourceFile("TestAndroidManifest.xml").toString());
properties.setProperty("libraries", "lib1");
Config config = Config.Implementation.fromProperties(properties);
ManifestFactory manifestFactory = new RobolectricTestRunner(ManifestFactoryTest.class).getManifestFactory(config);
AndroidManifest manifest = manifestFactory.create(manifestFactory.identify(config));
List<AndroidManifest> libraryManifests = manifest.getLibraryManifests();
assertEquals(1, libraryManifests.size());
assertEquals("org.robolectric.lib1", libraryManifests.get(0).getPackageName());
}
use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class OverrideSdkVersionTest method whenNotOverridden_shouldUseTargetSdkVersionFromAppManifest.
@Test
public void whenNotOverridden_shouldUseTargetSdkVersionFromAppManifest() {
AndroidManifest appManifest = ShadowApplication.getInstance().getAppManifest();
assertThat(Build.VERSION.SDK_INT).isEqualTo(appManifest.getTargetSdkVersion());
}
Aggregations