use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class ModuleSplitsToShardMergerTest method manifests_noBaseManifest_throws.
@Test
public void manifests_noBaseManifest_throws() throws Exception {
AndroidManifest manifest1 = AndroidManifest.create(androidManifest("com.test.app1"));
AndroidManifest manifest2 = AndroidManifest.create(androidManifest("com.test.app2"));
ModuleSplit split1 = createModuleSplitBuilder().setAndroidManifest(manifest1).setModuleName(BundleModuleName.create("module1")).build();
ModuleSplit split2 = createModuleSplitBuilder().setAndroidManifest(manifest2).setModuleName(BundleModuleName.create("module2")).build();
Throwable exception = assertThrows(CommandExecutionException.class, () -> splitsToShardMerger.mergeSingleShard(ImmutableList.of(split1, split2), createCache()));
assertThat(exception).hasMessageThat().contains("Expected to have base module");
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method replaceMode_fullyReplaceBaseElement.
@Test
public void replaceMode_fullyReplaceBaseElement() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("baseAction"), /* metadata= */
ImmutableList.of("baseMeta")), activityWithIntentFiltersAndMetadata("anotherActivity", /* intentFilters= */
ImmutableList.of("baseAction"), /* metadata= */
ImmutableList.of("baseMeta"))), androidManifestForFeature("com.testapp.feature1", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("feature1Action"), /* metadata= */
ImmutableList.of("feature1Meta"))), androidManifestForFeature("com.testapp.feature2", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("feature2Action"), /* metadata= */
ImmutableList.of()), activityWithIntentFiltersAndMetadata("anotherActivity", /* intentFilters= */
ImmutableList.of("feature2Action"), /* metadata= */
ImmutableList.of())));
AndroidManifest merged = createMerger(Mode.REPLACE).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("feature1Action"), /* metadata= */
ImmutableList.of("feature1Meta")), activityWithIntentFiltersAndMetadata("anotherActivity", /* intentFilters= */
ImmutableList.of("feature2Action"), /* metadata= */
ImmutableList.of())));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_conflictMetadata_throws.
@Test
public void mergeChildrenMode_conflictMetadata_throws() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addAttribute(XmlProtoAttributeBuilder.createAndroidAttribute(NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID).setValueAsString("meta")).addChildText("Base text")))), androidManifestForFeature("com.testapp.feature1", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addAttribute(XmlProtoAttributeBuilder.createAndroidAttribute(NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID).setValueAsString("meta")).addChildText("Feature text")))));
CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> createMerger(Mode.MERGE_CHILDREN).merge(manifests));
assertThat(exception).hasMessageThat().contains("Multiple meta-data entries with the same name are found inside activity:myActivity");
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method onlyBaseManifest.
@Test
@Theory
public void onlyBaseManifest(FusingAndroidManifestMerger.Mode mode) {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withDebuggableAttribute(true), withCustomThemeActivity("activity", BASE_THEME_REF_ID)));
AndroidManifest merged = createMerger(mode).merge(manifests);
assertThat(merged).isEqualTo(getOnlyElement(manifests.get(BASE_MODULE_NAME)));
}
use of com.android.tools.build.bundletool.model.AndroidManifest in project bundletool by google.
the class FusingAndroidManifestMergerTest method noBaseManifest_throws.
@Test
public void noBaseManifest_throws() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = ImmutableSetMultimap.of(BundleModuleName.create("feature"), AndroidManifest.create(androidManifest("com.testapp")));
CommandExecutionException exception = assertThrows(CommandExecutionException.class, () -> createMerger(Mode.REPLACE).merge(manifests));
assertThat(exception).hasMessageThat().isEqualTo("Expected to have base module.");
}
Aggregations