Search in sources :

Example 26 with AndroidManifest

use of org.robolectric.manifest.AndroidManifest in project Just-Another-Android-App by athkalia.

the class PermissionsTest method permissions_sanity_check.

@Test
public void permissions_sanity_check() {
    // Arrange
    AndroidManifest androidManifest = new AndroidManifest(Fs.fileFromPath("build/intermediates/manifests/full/debug/AndroidManifest.xml"), null, null);
    Set<String> permissions = new HashSet<>(androidManifest.getUsedPermissions());
    // Assert
    String[] expectedPermissions = { "android.permission.INTERNET" };
    assertThat(permissions).containsOnly(expectedPermissions);
}
Also used : AndroidManifest(org.robolectric.manifest.AndroidManifest) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with AndroidManifest

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

the class GradleManifestFactoryTest method getAppManifest_withMergedResources_shouldHaveMergedResPath.

@Test
public void getAppManifest_withMergedResources_shouldHaveMergedResPath() throws Exception {
    FileFsFile.from("build", "intermediates", "res", "merged").getFile().mkdirs();
    final AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfig.class).setPackageName("fake.package.name").build());
    assertThat(manifest.getPackageName()).isEqualTo("fake.package.name");
    assertThat(manifest.getResDirectory()).isEqualTo(file("build/intermediates/res/merged/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) BuildConfig(org.robolectric.gradleapp.BuildConfig) Test(org.junit.Test)

Example 28 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 {
    ManifestIdentifier manifestIdentifier = buckManifestFactory.identify(configBuilder.build());
    AndroidManifest manifest = buckManifestFactory.create(manifestIdentifier);
    assertThat(manifest.getResDirectory()).isEqualTo(FileFsFile.from("buck/res2"));
    assertThat(manifest.getAssetsDirectory()).isEqualTo(FileFsFile.from("buck/assets"));
    List<ResourcePath> resourcePathList = manifest.getIncludedResourcePaths();
    assertThat(resourcePathList.size()).isEqualTo(2);
    assertThat(resourcePathList).containsExactly(new ResourcePath(manifest.getRClass(), FileFsFile.from("buck/res2"), FileFsFile.from("buck/assets")), new ResourcePath(manifest.getRClass(), FileFsFile.from("buck/res1"), FileFsFile.from("buck/assets")));
}
Also used : ResourcePath(org.robolectric.res.ResourcePath) AndroidManifest(org.robolectric.manifest.AndroidManifest) Test(org.junit.Test)

Example 29 with AndroidManifest

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

the class GradleManifestFactoryTest method getAppManifest_withPackageNameOverride_shouldCreateManifest.

@Test
public void getAppManifest_withPackageNameOverride_shouldCreateManifest() throws Exception {
    final AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfig.class).setPackageName("fake.package.name").build());
    assertThat(manifest.getPackageName()).isEqualTo("fake.package.name");
    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) BuildConfig(org.robolectric.gradleapp.BuildConfig) Test(org.junit.Test)

Example 30 with AndroidManifest

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

the class GradleManifestFactoryTest method getAppManifest_shouldCreateManifestWithMethodOverrides.

@Test
public void getAppManifest_shouldCreateManifestWithMethodOverrides() throws Exception {
    final AndroidManifest manifest = createManifest(configBuilder.setConstants(BuildConfigOverride.class).build());
    assertThat(manifest.getResDirectory()).isEqualTo(file("build/intermediates/res/flavor2/type2"));
    assertThat(manifest.getAssetsDirectory()).isEqualTo(file("build/intermediates/assets/flavor2/type2"));
    assertThat(manifest.getAndroidManifestFile()).isEqualTo(file("build/intermediates/manifests/full/flavor2/type2/AndroidManifest.xml"));
}
Also used : AndroidManifest(org.robolectric.manifest.AndroidManifest) 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