use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_notMergingAssetModules.
@Test
public void testMultipleModulesWithInstallTime_notMergingAssetModules() throws Exception {
XmlNode assetModuleManifest = androidManifestForAssetModule("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"), assetModuleManifest).addFileWithContent(ZipPath.create("detail/assets/detailsAssetfile.txt"), DUMMY_CONTENT).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
AppBundle appBundle = BundleModuleMerger.mergeNonRemovableInstallTimeModules(AppBundle.buildFromZip(appBundleZip), /* overrideBundleToolVersion = */
false);
assertThat(appBundle.getAssetModules().keySet()).comparingElementsUsing(equalsBundleModuleName()).containsExactly("detail");
assertThat(appBundle.getFeatureModules().keySet()).comparingElementsUsing(equalsBundleModuleName()).containsExactly("base");
}
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_notMergingMlModules.
@Test
public void testMultipleModulesWithInstallTime_notMergingMlModules() throws Exception {
XmlNode installTimeModuleManifest = androidManifestForMlModule("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).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
AppBundle appBundle = BundleModuleMerger.mergeNonRemovableInstallTimeModules(AppBundle.buildFromZip(appBundleZip), /* overrideBundleToolVersion = */
false);
assertThat(appBundle.getFeatureModules().keySet()).comparingElementsUsing(equalsBundleModuleName()).containsExactly("base", "detail");
}
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_implicitMerging.
@Test
public void testMultipleModulesWithInstallTime_implicitMerging() 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).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
AppBundle appBundle = BundleModuleMerger.mergeNonRemovableInstallTimeModules(AppBundle.buildFromZip(appBundleZip), /* overrideBundleToolVersion = */
false);
assertThat(appBundle.getFeatureModules().keySet()).comparingElementsUsing(equalsBundleModuleName()).containsExactly("base");
}
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_explicitMerging.
@Test
public void testMultipleModulesWithInstallTime_explicitMerging() throws Exception {
XmlNode installTimeModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeRemovableElement(false));
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).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
AppBundle appBundlePreMerge = AppBundle.buildFromZip(appBundleZip);
AppBundle appBundlePostMerge = BundleModuleMerger.mergeNonRemovableInstallTimeModules(appBundlePreMerge, /* overrideBundleToolVersion = */
false);
assertThat(appBundlePreMerge.getModules().values().stream().mapToLong(module -> module.getEntries().size()).sum()).isEqualTo(appBundlePostMerge.getModules().values().stream().mapToLong(module -> module.getEntries().size()).sum());
assertThat(appBundlePostMerge.getFeatureModules().keySet()).comparingElementsUsing(equalsBundleModuleName()).containsExactly("base");
}
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class StandaloneApksGeneratorTest method removeSplitNameFromShard.
@Test
public void removeSplitNameFromShard() throws Exception {
XmlNode manifest = androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "foo"));
BundleModule bundleModule = new BundleModuleBuilder("base").addFile("assets/file.txt").addFile("dex/classes.dex").addFile("res/drawable/image.jpg").addFile("res/drawable-mdpi/image.jpg").addFile("root/license.dat").setManifest(manifest).build();
ImmutableList<ModuleSplit> shards = standaloneApksGenerator.generateStandaloneApks(ImmutableList.of(bundleModule), NO_DIMENSIONS);
assertThat(shards).hasSize(1);
ModuleSplit fatShard = shards.get(0);
ImmutableList<XmlElement> activities = fatShard.getAndroidManifest().getManifestRoot().getElement().getChildElement("application").getChildrenElements(ACTIVITY_ELEMENT_NAME).map(XmlProtoElement::getProto).collect(toImmutableList());
assertThat(activities).hasSize(2);
XmlElement activityElement = activities.get(1);
assertThat(activityElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, "FooActivity"));
}
Aggregations