use of org.robolectric.internal.ManifestIdentifier in project robolectric by robolectric.
the class ManifestFactoryTest method whenConfigSpecified_overridesValuesFromFile.
@Test
public void whenConfigSpecified_overridesValuesFromFile() 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().setManifest("/TestAndroidManifest.xml").setPackageName("another.package").build();
ManifestFactory manifestFactory = testRunner.getManifestFactory(config);
assertThat(manifestFactory).isInstanceOf(DefaultManifestFactory.class);
ManifestIdentifier manifestIdentifier = manifestFactory.identify(config);
assertThat(manifestIdentifier.getManifestFile()).isEqualTo(Fs.fileFromPath(getClass().getResource("/TestAndroidManifest.xml").getPath()));
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()).isEqualTo("another.package");
}
use of org.robolectric.internal.ManifestIdentifier 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"));
}
Aggregations