use of com.android.tools.build.bundletool.model.BundleModuleName in project bundletool by google.
the class BundleModuleMergerTest method testRealBundle.
@Test
public void testRealBundle() throws Exception {
File file = tmp.newFile();
try (FileOutputStream os = new FileOutputStream(file)) {
// This bundle has a base module and 3 feature modules: java, assets and initialInstall.
// initialInstall should be merged into base.
os.write(TestData.readBytes("testdata/bundle/install-time-permanent-modules.aab"));
}
Path bundleFile = file.toPath();
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", "java", "assets");
assertEntriesPreserved(appBundlePreMerge, appBundlePostMerge);
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_onlyOneMetadataPerName.
@Test
public void mergeChildrenMode_onlyOneMetadataPerName() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of(), /* metadata= */
ImmutableList.of("sharedMeta", "baseMeta"))), androidManifestForFeature("com.testapp.feature1", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of(), /* metadata= */
ImmutableList.of("sharedMeta"))));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of(), /* metadata= */
ImmutableList.of("sharedMeta", "baseMeta"))));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.BundleModuleName in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_nonIntentFilterOrMetadataElements_notMerged.
@Test
public void mergeChildrenMode_nonIntentFilterOrMetadataElements_notMerged() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("elementBase")))), androidManifestForFeature("com.testapp.feature1", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("elementFeature")))));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildElement(XmlProtoElementBuilder.create("elementFeature")))));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.BundleModuleName in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_keepTextNodesInsideElement.
@Test
public void mergeChildrenMode_keepTextNodesInsideElement() {
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"))))), androidManifestForFeature("com.testapp.feature1", withActivity("myActivity", activity -> activity.addChildText("text"))));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", withActivity("myActivity", activity -> activity.addChildText("text").addChildElement(XmlProtoElementBuilder.create("meta-data").addAttribute(XmlProtoAttributeBuilder.createAndroidAttribute(NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID).setValueAsString("meta"))))));
assertThat(merged).isEqualTo(expected);
}
use of com.android.tools.build.bundletool.model.BundleModuleName in project bundletool by google.
the class FusingAndroidManifestMergerTest method mergeChildrenMode_gatherAllMetadataAndIntentFilters.
@Test
public void mergeChildrenMode_gatherAllMetadataAndIntentFilters() {
SetMultimap<BundleModuleName, AndroidManifest> manifests = createManifests(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("baseAction", "baseAction2"), /* 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())));
AndroidManifest merged = createMerger(Mode.MERGE_CHILDREN).merge(manifests);
AndroidManifest expected = AndroidManifest.create(androidManifest("com.testapp", activityWithIntentFiltersAndMetadata("myActivity", /* intentFilters= */
ImmutableList.of("feature1Action", "feature2Action", "baseAction", "baseAction2"), /* metadata= */
ImmutableList.of("feature1Meta", "baseMeta"))));
assertThat(merged).isEqualTo(expected);
}
Aggregations