use of com.android.tools.build.bundletool.model.BundleModuleName in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_implicitMergingDexRenaming.
@Test
public void testMultipleModulesWithInstallTime_implicitMergingDexRenaming() throws Exception {
XmlNode installTimeModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeDelivery());
createBasicZipBuilder(BUNDLE_CONFIG_1_0_0).addFileWithProtoContent(ZipPath.create("base/manifest/AndroidManifest.xml"), MANIFEST).addFileWithContent(ZipPath.create("base/dex/classes.dex"), DUMMY_CONTENT).addFileWithContent(ZipPath.create("base/assets/baseAssetfile.txt"), DUMMY_CONTENT).addFileWithProtoContent(ZipPath.create("detail/manifest/AndroidManifest.xml"), installTimeModuleManifest).addFileWithContent(ZipPath.create("detail/assets/detailsAssetfile.txt"), DUMMY_CONTENT).addFileWithContent(ZipPath.create("detail/dex/classes.dex"), DUMMY_CONTENT).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
AppBundle appBundlePreMerge = AppBundle.buildFromZip(appBundleZip);
AppBundle appBundlePostMerge = BundleModuleMerger.mergeNonRemovableInstallTimeModules(appBundlePreMerge, /* overrideBundleToolVersion = */
false);
assertThat(appBundlePostMerge.getModules().keySet().stream().map(BundleModuleName::getName)).containsExactly("base");
assertThat(appBundlePreMerge.getModules().values().stream().mapToLong(module -> module.getEntries().size()).sum()).isEqualTo(appBundlePostMerge.getModules().values().stream().mapToLong(module -> module.getEntries().size()).sum());
assertThat(appBundlePostMerge.getBaseModule().getEntry(ZipPath.create("dex/classes.dex"))).isPresent();
assertThat(appBundlePostMerge.getBaseModule().getEntry(ZipPath.create("dex/classes2.dex"))).isPresent();
}
}
use of com.android.tools.build.bundletool.model.BundleModuleName in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_metadataWithoutName_notMerged.
@Test
public void mergeChildrenMode_metadataWithoutName_notMerged() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addChildElement(XmlProtoElementBuilder.create("data"))))), androidManifestForFeature("com.testapp.feature", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addChildElement(XmlProtoElementBuilder.create("action"))))));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("meta-data").addChildElement(XmlProtoElementBuilder.create("action"))))));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.BundleModuleName in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeFeatureElementsIntoBaseManifest.
@Test
@Theory
public void mergeFeatureElementsIntoBaseManifest(FusingAndroidManifestMerger.Mode mode) {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withSplitNameService("onlyBaseService", "base"), withSplitNameService("baseAndFeatureService", "base"), withSplitNameActivity("myActivity", "base")), androidManifestForFeature("com.testapp.feature1", withSplitNameService("baseAndFeatureService", "feature1"), withSplitNameActivity("anotherActivity", "feature1")), androidManifestForFeature("com.testapp.feature2", withSplitNameService("justFeatureService", "feature2"), withSplitNameActivity("myActivity", "feature2")));
AndroidManifest merged = createMerger(mode).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", withSplitNameService("onlyBaseService", "base"), withSplitNameService("baseAndFeatureService", "feature1"), withSplitNameActivity("myActivity", "feature2"), withSplitNameActivity("anotherActivity", "feature1"), withSplitNameService("justFeatureService", "feature2")));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.BundleModuleName 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.BundleModuleName 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");
}
Aggregations