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 ManifestFactoryTest method whenBuildSystemApiPropertiesFileIsPresent_shouldUseDefaultManifestFactory.
@Test
public void whenBuildSystemApiPropertiesFileIsPresent_shouldUseDefaultManifestFactory() throws Exception {
final Properties properties = new Properties();
properties.setProperty("android_sdk_home", "");
properties.setProperty("android_merged_manifest", "/path/to/MergedManifest.xml");
properties.setProperty("android_merged_resources", "/path/to/merged-resources");
properties.setProperty("android_merged_assets", "/path/to/merged-assets");
RobolectricTestRunner testRunner = new RobolectricTestRunner(ManifestFactoryTest.class) {
Properties getBuildSystemApiProperties() {
return properties;
}
};
Config.Implementation config = Config.Builder.defaults().build();
ManifestFactory manifestFactory = testRunner.getManifestFactory(config);
assertThat(manifestFactory).isInstanceOf(DefaultManifestFactory.class);
ManifestIdentifier manifestIdentifier = manifestFactory.identify(config);
assertThat(manifestIdentifier.getManifestFile()).isEqualTo(Fs.fileFromPath("/path/to/MergedManifest.xml"));
assertThat(manifestIdentifier.getResDir()).isEqualTo(Fs.fileFromPath("/path/to/merged-resources"));
assertThat(manifestIdentifier.getAssetDir()).isEqualTo(Fs.fileFromPath("/path/to/merged-assets"));
assertThat(manifestIdentifier.getLibraryDirs()).isEmpty();
assertThat(manifestIdentifier.getPackageName()).isNull();
AndroidManifest androidManifest = manifestFactory.create(manifestIdentifier);
assertThat(androidManifest.getAndroidManifestFile()).isEqualTo(Fs.fileFromPath("/path/to/MergedManifest.xml"));
assertThat(androidManifest.getResDirectory()).isEqualTo(Fs.fileFromPath("/path/to/merged-resources"));
assertThat(androidManifest.getAssetsDirectory()).isEqualTo(Fs.fileFromPath("/path/to/merged-assets"));
}
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());
}
use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class ParallelUniverseTest method setUpApplicationState.
private void setUpApplicationState(Config defaultConfig) {
ResourceTable sdkResourceProvider = ResourceTableFactory.newFrameworkResourceTable(new ResourcePath(android.R.class, null, null));
final RoutingResourceTable routingResourceTable = new RoutingResourceTable(ResourceTableFactory.newResourceTable("org.robolectric", new ResourcePath(R.class, null, null)));
pu.setUpApplicationState(null, new DefaultTestLifecycle(), new AndroidManifest(null, null, null, "package"), defaultConfig, sdkResourceProvider, routingResourceTable, RuntimeEnvironment.getSystemResourceTable());
}
use of org.robolectric.manifest.AndroidManifest in project algoliasearch-client-android by algolia.
the class CustomRunner method getAppManifest.
@Override
protected AndroidManifest getAppManifest(Config config) {
final String cwd = System.getProperty("user.dir");
Logger.debug("Current working directory: " + cwd);
if (config.constants() == Void.class) {
Logger.error("Field 'constants' not specified in @Config annotation");
Logger.error("This is required when using RobolectricGradleTestRunner!");
throw new RuntimeException("No 'constants' field in @Config annotation!");
}
final String type = getType(config);
final String flavor = getFlavor(config);
final String packageName = getPackageName(config);
final FileFsFile res;
final FileFsFile assets;
final FileFsFile manifest;
if (FileFsFile.from(BUILD_OUTPUT, "res").exists()) {
res = FileFsFile.from(BUILD_OUTPUT, "res", flavor, type);
} else {
res = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "res");
}
if (FileFsFile.from(BUILD_OUTPUT, "assets").exists()) {
assets = FileFsFile.from(BUILD_OUTPUT, "assets", flavor, type);
} else {
assets = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "assets");
}
if (FileFsFile.from(BUILD_OUTPUT, "manifests").exists()) {
// [CUSTOMIZED] The default implementation uses `full` instead of `aapt`.
manifest = FileFsFile.from(BUILD_OUTPUT, "manifests", "aapt", flavor, type, "AndroidManifest.xml");
} else {
manifest = FileFsFile.from(BUILD_OUTPUT, "bundles", flavor, type, "AndroidManifest.xml");
}
Logger.debug("Robolectric assets directory: " + assets.getPath());
Logger.debug(" Robolectric res directory: " + res.getPath());
Logger.debug(" Robolectric manifest path: " + manifest.getPath());
Logger.debug(" Robolectric package name: " + packageName);
return new AndroidManifest(manifest, res, assets, packageName);
}
Aggregations