Search in sources :

Example 61 with AndroidManifest

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")));
}
Also used : ResourcePath(org.robolectric.res.ResourcePath) AndroidManifest(org.robolectric.manifest.AndroidManifest) Test(org.junit.Test)

Example 62 with AndroidManifest

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"));
}
Also used : Config(org.robolectric.annotation.Config) ManifestIdentifier(org.robolectric.internal.ManifestIdentifier) AndroidManifest(org.robolectric.manifest.AndroidManifest) Properties(java.util.Properties) ManifestFactory(org.robolectric.internal.ManifestFactory) DefaultManifestFactory(org.robolectric.internal.DefaultManifestFactory) Test(org.junit.Test)

Aggregations

AndroidManifest (org.robolectric.manifest.AndroidManifest)62 Test (org.junit.Test)28 ArrayList (java.util.ArrayList)10 ResourcePath (org.robolectric.res.ResourcePath)9 Properties (java.util.Properties)8 ActivityData (org.robolectric.manifest.ActivityData)8 Context (android.content.Context)6 BuildConfig (org.robolectric.gradleapp.BuildConfig)6 IntentFilterData (org.robolectric.manifest.IntentFilterData)6 FileFsFile (org.robolectric.res.FileFsFile)5 FsFile (org.robolectric.res.FsFile)5 Config (org.robolectric.annotation.Config)4 ActivityInfo (android.content.pm.ActivityInfo)3 File (java.io.File)3 DefaultManifestFactory (org.robolectric.internal.DefaultManifestFactory)3 ManifestFactory (org.robolectric.internal.ManifestFactory)3 Application (android.app.Application)2 ManifestIdentifier (org.robolectric.internal.ManifestIdentifier)2 ContentProviderData (org.robolectric.manifest.ContentProviderData)2 Sdk (org.robolectric.pluginapi.Sdk)2