use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_throws_duplicateModuleEntriesWithDifferentContent.
@Test
public void testMultipleModulesWithInstallTime_throws_duplicateModuleEntriesWithDifferentContent() 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("detail1/manifest/AndroidManifest.xml"), installTimeModuleManifest).addFileWithContent(ZipPath.create("detail1/assets/detailsAssetfile.txt"), DUMMY_CONTENT).addFileWithProtoContent(ZipPath.create("detail2/manifest/AndroidManifest.xml"), installTimeModuleManifest).addFileWithContent(ZipPath.create("detail2/assets/baseAssetfile.txt"), DUMMY_CONTENT_2).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> BundleModuleMerger.mergeNonRemovableInstallTimeModules(AppBundle.buildFromZip(appBundleZip), /* overrideBundleToolVersion = */
false));
assertThat(exception).hasMessageThat().contains("Existing module entry 'assets/baseAssetfile.txt' with different contents.");
}
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class BundleModuleMergerTest method testMultipleModulesWithInstallTime_noMergingIfBuiltWithOlderBundleTool.
@Test
public void testMultipleModulesWithInstallTime_noMergingIfBuiltWithOlderBundleTool() throws Exception {
XmlNode installTimeModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeDelivery());
createBasicZipBuilder(BUNDLE_CONFIG_0_14_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_bundleToolVersionOverrideIgnored.
// Override ignored for bundles built by bundletool version >= 1.0.0. Allows developers to
// selectively merge modules.
@Test
public void testMultipleModulesWithInstallTime_bundleToolVersionOverrideIgnored() throws Exception {
XmlNode installTimeModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeDelivery());
XmlNode installTimeNonRemovableModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeRemovableElement(false));
XmlNode installTimeRemovableModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeRemovableElement(true));
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).addFileWithProtoContent(ZipPath.create("detail2/manifest/AndroidManifest.xml"), installTimeNonRemovableModuleManifest).addFileWithContent(ZipPath.create("detail2/assets/detailsAssetfile.txt"), DUMMY_CONTENT).addFileWithProtoContent(ZipPath.create("detail3/manifest/AndroidManifest.xml"), installTimeRemovableModuleManifest).addFileWithContent(ZipPath.create("detail3/assets/detailsAssetfile.txt"), DUMMY_CONTENT).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
AppBundle appBundle = BundleModuleMerger.mergeNonRemovableInstallTimeModules(AppBundle.buildFromZip(appBundleZip), /* overrideBundleToolVersion = */
true);
assertThat(appBundle.getFeatureModules().keySet()).comparingElementsUsing(equalsBundleModuleName()).containsExactly("base", "detail3");
}
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class BundleModuleMergerTest method testDoNotMergeIfConditionalModule.
@Test
public void testDoNotMergeIfConditionalModule() throws Exception {
XmlNode conditionalModuleManifest = androidManifest("com.test.app.detail", withMinSdkVersion(24), withFeatureCondition("android.feature"));
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"), conditionalModuleManifest).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 ManifestDeliveryElementTest method deliveryElement_typoInChildElement_throws_fastFollowEnabled.
@Test
public void deliveryElement_typoInChildElement_throws_fastFollowEnabled() {
XmlNode nodeWithTypo = createAndroidManifestWithDeliveryElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "delivery").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "instal-time")));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> ManifestDeliveryElement.fromManifestRootNode(nodeWithTypo, /* isFastFollowAllowed= */
true));
assertThat(exception).hasMessageThat().contains("Expected <dist:delivery> element to contain only <dist:install-time>, " + "<dist:on-demand>, <dist:fast-follow> elements but found: 'instal-time' " + "with namespace URI: 'http://schemas.android.com/apk/distribution'");
}
Aggregations