use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.
the class BuckManifestFactoryTest method multiple_res_dirs.
@Test
public void multiple_res_dirs() throws Exception {
System.setProperty("buck.robolectric_res_directories", "buck/res1" + File.pathSeparator + "buck/res2");
System.setProperty("buck.robolectric_assets_directories", "buck/assets1" + File.pathSeparator + "buck/assets2");
ManifestIdentifier manifestIdentifier = buckManifestFactory.identify(configBuilder.build());
AndroidManifest manifest = RobolectricTestRunner.createAndroidManifest(manifestIdentifier);
assertThat(manifest.getResDirectory()).isEqualTo(Paths.get("buck/res2"));
assertThat(manifest.getAssetsDirectory()).isEqualTo(Paths.get("buck/assets2"));
List<ResourcePath> resourcePathList = manifest.getIncludedResourcePaths();
assertThat(resourcePathList.size()).isEqualTo(3);
assertThat(resourcePathList).containsExactly(new ResourcePath(manifest.getRClass(), Paths.get("buck/res2"), Paths.get("buck/assets2")), new ResourcePath(manifest.getRClass(), Paths.get("buck/res1"), null), new ResourcePath(manifest.getRClass(), null, Paths.get("buck/assets1")));
}
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) {
@Override
protected 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(Paths.get("/path/to/MergedManifest.xml"));
assertThat(manifestIdentifier.getResDir()).isEqualTo(Paths.get("/path/to/merged-resources"));
assertThat(manifestIdentifier.getAssetDir()).isEqualTo(Paths.get("/path/to/merged-assets"));
assertThat(manifestIdentifier.getLibraries()).isEmpty();
assertThat(manifestIdentifier.getPackageName()).isNull();
AndroidManifest androidManifest = RobolectricTestRunner.createAndroidManifest(manifestIdentifier);
assertThat(androidManifest.getAndroidManifestFile()).isEqualTo(Paths.get("/path/to/MergedManifest.xml"));
assertThat(androidManifest.getResDirectory()).isEqualTo(Paths.get("/path/to/merged-resources"));
assertThat(androidManifest.getAssetsDirectory()).isEqualTo(Paths.get("/path/to/merged-assets"));
}
Aggregations