use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method moduleConditions_multipleDeviceGroupsCondition_throws.
@Test
public void moduleConditions_multipleDeviceGroupsCondition_throws() {
Optional<ManifestDeliveryElement> element = ManifestDeliveryElement.fromManifestRootNode(androidManifest("com.test.app", withDeviceGroupsCondition(ImmutableList.of("group1", "group2")), withDeviceGroupsCondition(ImmutableList.of("group3"))), /* isFastFollowAllowed= */
false);
assertThat(element).isPresent();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> element.get().getModuleConditions());
assertThat(exception).hasMessageThat().contains("Multiple '<dist:device-groups>' conditions are not supported.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method getModuleConditions_multipleUserCountriesConditions_throws.
@Test
public void getModuleConditions_multipleUserCountriesConditions_throws() {
Optional<ManifestDeliveryElement> element = ManifestDeliveryElement.fromManifestRootNode(androidManifest("com.test.app", withUserCountriesCondition(ImmutableList.of("en", "us")), withUserCountriesCondition(ImmutableList.of("sg"), /* exclude= */
true)), /* isFastFollowAllowed= */
false);
assertThat(element).isPresent();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> element.get().getModuleConditions());
assertThat(exception).hasMessageThat().contains("Multiple '<dist:user-countries>' conditions are not supported.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ModuleConditionsTest method multipleDeviceFeatureConditions_sameFeatureName_throws.
@Test
public void multipleDeviceFeatureConditions_sameFeatureName_throws() {
ModuleConditions.Builder builder = ModuleConditions.builder();
builder.addDeviceFeatureCondition(DeviceFeatureCondition.create("com.android.feature", /* version= */
Optional.of(1)));
builder.addDeviceFeatureCondition(DeviceFeatureCondition.create("com.android.feature", /* version= */
Optional.of(2)));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, builder::build);
assertThat(exception).hasMessageThat().contains("The device feature condition on 'com.android.feature' " + "is present more than once.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class BuildApksValidationTest method splits_textureFallbackNotPresentInAssetPacks.
@Test
public void splits_textureFallbackNotPresentInAssetPacks() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.test.app")).setResourceTable(resourceTableWithTestLabel("Test feature"))).addModule("feature_tcf_assets", builder -> builder.addFile("assets/textures#tcf_atc/atc_texture.dat").addFile("assets/textures#tcf_etc1/etc1_texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures#tcf_atc", assetsDirectoryTargeting(textureCompressionTargeting(ATC))), targetedAssetsDirectory("assets/textures#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(ETC1_RGB8))))).setManifest(androidManifestForFeature("com.test.app", withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).setBundleConfig(BundleConfigBuilder.create().addSplitDimension(Value.TEXTURE_COMPRESSION_FORMAT, /* negate= */
false).build()).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).build();
// Splitting by texture compression format is activated, but the textures in
// one module don't include a fallback folder, used for standalone and universal
// APKs, so we'll consider the bundle invalid:
InvalidBundleException exception = assertThrows(InvalidBundleException.class, command::execute);
assertThat(exception).hasMessageThat().contains("the fallback texture folders (folders without #tcf suffixes) will be used, but module" + " 'feature_tcf_assets' has no such folders.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class BuildBundleCommandTest method runsModuleDependencyValidator_cycle_throws.
@Test
public void runsModuleDependencyValidator_cycle_throws() throws Exception {
Path baseModulePath = new ZipBuilder().addFileWithProtoContent(ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME)).writeTo(tmpDir.resolve("base.zip"));
Path module1Path = new ZipBuilder().addFileWithProtoContent(ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME, withSplitId("module1"), withUsesSplit("module2"), withOnDemandAttribute(false), withFusingAttribute(true))).writeTo(tmpDir.resolve("module1.zip"));
Path module2Path = new ZipBuilder().addFileWithProtoContent(ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME, withSplitId("module2"), withUsesSplit("module3"), withOnDemandAttribute(false), withFusingAttribute(true))).writeTo(tmpDir.resolve("module2.zip"));
Path module3Path = new ZipBuilder().addFileWithProtoContent(ZipPath.create("manifest/AndroidManifest.xml"), androidManifest(PKG_NAME, withSplitId("module3"), withUsesSplit("module1"), withOnDemandAttribute(false), withFusingAttribute(true))).writeTo(tmpDir.resolve("module3.zip"));
BuildBundleCommand command = BuildBundleCommand.builder().setOutputPath(bundlePath).setModulesPaths(ImmutableList.of(baseModulePath, module1Path, module2Path, module3Path)).build();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, command::execute);
assertThat(exception).hasMessageThat().contains("Found cyclic dependency between modules");
}
Aggregations