Search in sources :

Example 16 with AndroidManifest

use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.

the class GradleManifestFactoryTest method getAppManifest_forApplications_shouldCreateManifest.

@Test
public void getAppManifest_forApplications_shouldCreateManifest() throws Exception {
    final AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfig.class).build());
    assertThat(manifest.getPackageName()).isEqualTo("org.robolectric.gradleapp");
    assertThat(manifest.getResDirectory()).isEqualTo(file("build/intermediates/res/flavor1/type1"));
    assertThat(manifest.getAssetsDirectory()).isEqualTo(file("build/intermediates/assets/flavor1/type1"));
    assertThat(manifest.getAndroidManifestFile()).isEqualTo(file("build/intermediates/manifests/full/flavor1/type1/AndroidManifest.xml"));
}
Also used : AndroidManifest(org.robolectric.manifest.AndroidManifest) Test(org.junit.Test)

Example 17 with AndroidManifest

use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.

the class GradleManifestFactoryTest method rClassShouldBeInTheSamePackageAsBuildConfig.

@Test
public void rClassShouldBeInTheSamePackageAsBuildConfig() throws Exception {
    File manifestFile = new File(joinPath("build", "intermediates", "manifests", "full", org.robolectric.gradleapp.BuildConfig.FLAVOR, org.robolectric.gradleapp.BuildConfig.BUILD_TYPE), "AndroidManifest.xml");
    manifestFile.getParentFile().mkdirs();
    newFile(manifestFile, "<manifest package=\"something\"/>");
    AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfig.class).build());
    assertThat(manifest.getRClass().getPackage().getName()).isEqualTo("org.robolectric.gradleapp");
}
Also used : AndroidManifest(org.robolectric.manifest.AndroidManifest) TestUtil.newFile(org.robolectric.util.TestUtil.newFile) FileFsFile(org.robolectric.res.FileFsFile) File(java.io.File) FsFile(org.robolectric.res.FsFile) Test(org.junit.Test)

Example 18 with AndroidManifest

use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.

the class GradleManifestFactoryTest method getAppManifest_withOverriddenConfigManifest_shouldCreateManifest.

@Test
public void getAppManifest_withOverriddenConfigManifest_shouldCreateManifest() throws Exception {
    final AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfig.class).setManifest("TestAndroidManifest.xml").build());
    assertThat(manifest.getAndroidManifestFile().getPath()).isEqualTo(getClass().getClassLoader().getResource("TestAndroidManifest.xml").getPath());
    assertThat(manifest.getPackageName()).isEqualTo("org.robolectric.gradleapp");
    assertThat(manifest.getResDirectory()).isEqualTo(file("build/intermediates/res/flavor1/type1"));
    assertThat(manifest.getAssetsDirectory()).isEqualTo(file("build/intermediates/assets/flavor1/type1"));
}
Also used : AndroidManifest(org.robolectric.manifest.AndroidManifest) BuildConfig(org.robolectric.gradleapp.BuildConfig) Test(org.junit.Test)

Example 19 with AndroidManifest

use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.

the class GradleManifestFactoryTest method getAppManifest_forLibraries_shouldCreateManifest.

@Test
public void getAppManifest_forLibraries_shouldCreateManifest() throws Exception {
    delete(FileFsFile.from("build", "intermediates", "res").getFile());
    delete(FileFsFile.from("build", "intermediates", "assets").getFile());
    delete(FileFsFile.from("build", "intermediates", "manifests", "full").getFile());
    final AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfig.class).build());
    assertThat(manifest.getPackageName()).isEqualTo("org.robolectric.gradleapp");
    assertThat(manifest.getResDirectory()).isEqualTo(file("build/intermediates/bundles/flavor1/type1/res"));
    assertThat(manifest.getAssetsDirectory()).isEqualTo(file("build/intermediates/bundles/flavor1/type1/assets"));
    assertThat(manifest.getAndroidManifestFile()).isEqualTo(file("build/intermediates/bundles/flavor1/type1/AndroidManifest.xml"));
}
Also used : AndroidManifest(org.robolectric.manifest.AndroidManifest) Test(org.junit.Test)

Example 20 with AndroidManifest

use of org.robolectric.manifest.AndroidManifest in project robolectric by robolectric.

the class GradleManifestFactoryTest method getAppManifest_withOverriddenConfigAssetDir_shouldCreateManifest.

@Test
public void getAppManifest_withOverriddenConfigAssetDir_shouldCreateManifest() throws Exception {
    final AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfig.class).setAssetDir("../../src/test/resources/assets").build());
    assertThat(manifest.getPackageName()).isEqualTo("org.robolectric.gradleapp");
    assertThat(manifest.getResDirectory()).isEqualTo(file("build/intermediates/res/flavor1/type1"));
    assertThat(manifest.getAssetsDirectory()).isEqualTo(file("build/intermediates/../../src/test/resources/assets"));
    assertThat(manifest.getAndroidManifestFile()).isEqualTo(file("build/intermediates/manifests/full/flavor1/type1/AndroidManifest.xml"));
}
Also used : AndroidManifest(org.robolectric.manifest.AndroidManifest) BuildConfig(org.robolectric.gradleapp.BuildConfig) Test(org.junit.Test)

Aggregations

AndroidManifest (org.robolectric.manifest.AndroidManifest)40 Test (org.junit.Test)21 Config (org.robolectric.annotation.Config)6 BuildConfig (org.robolectric.gradleapp.BuildConfig)6 FsFile (org.robolectric.res.FsFile)5 FileFsFile (org.robolectric.res.FileFsFile)4 ActivityInfo (android.content.pm.ActivityInfo)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 DefaultManifestFactory (org.robolectric.internal.DefaultManifestFactory)3 ManifestFactory (org.robolectric.internal.ManifestFactory)3 ContentProviderData (org.robolectric.manifest.ContentProviderData)3 File (java.io.File)2 ActivityData (org.robolectric.manifest.ActivityData)2 ResourcePath (org.robolectric.res.ResourcePath)2 Application (android.app.Application)1 ContentProvider (android.content.ContentProvider)1 ProviderInfo (android.content.pm.ProviderInfo)1 ResolveInfo (android.content.pm.ResolveInfo)1 ServiceInfo (android.content.pm.ServiceInfo)1