use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ResourceTableValidatorTest method duplicateResourceId_differentModule_throws.
@Test
public void duplicateResourceId_differentModule_throws() throws Exception {
BundleModule firstModule = new BundleModuleBuilder("base").setResourceTable(resourceTable(pkg(USER_PACKAGE_OFFSET, "com.test.app", type(0x01, "drawable", entry(0x0002, "logo"))))).setManifest(androidManifest("com.test.app")).build();
BundleModule secondModule = new BundleModuleBuilder("secondModule").setResourceTable(resourceTable(pkg(USER_PACKAGE_OFFSET, "com.test.app", type(0x01, "drawable", entry(0x0002, "logo"))))).setManifest(androidManifest("com.test.app")).build();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ResourceTableValidator().checkResourceIds(ImmutableList.of(firstModule, secondModule)));
assertThat(exception).hasMessageThat().contains("Duplicate resource");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ModuleDependencyValidatorTest method validateAllModules_instantModuleToOnDemandModulesDependency_throws.
@Test
public void validateAllModules_instantModuleToOnDemandModulesDependency_throws() throws Exception {
ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME, withInstant(true))), module("feature1", androidManifest(PKG_NAME, withOnDemandAttribute(true), withInstant(false))), module("feature2", androidManifest(PKG_NAME, withUsesSplit("feature1"), withInstant(true))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
assertThat(exception).hasMessageThat().contains("Instant module 'feature2' cannot depend on a module 'feature1' that is not instant.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ModuleDependencyValidatorTest method validateAllModules_conditionalModule_dependsOnConditional_throws.
@Test
public void validateAllModules_conditionalModule_dependsOnConditional_throws() throws Exception {
ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME)), module("conditional", androidManifest(PKG_NAME, withFeatureCondition("android.feature"), withUsesSplit("conditional2"))), module("conditional2", androidManifest(PKG_NAME, withFeatureCondition("android.feature2"))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
assertThat(exception).hasMessageThat().contains("Conditional module 'conditional' cannot depend on a module 'conditional2' that is " + "not install-time.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ModuleDependencyValidatorTest method validateAllModules_cycle_throws.
@Test
public void validateAllModules_cycle_throws() throws Exception {
ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME)), module("module1", androidManifest(PKG_NAME, withUsesSplit("module2"))), module("module2", androidManifest(PKG_NAME, withUsesSplit("module3"))), module("module3", androidManifest(PKG_NAME, withUsesSplit("module1"))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
assertThat(exception).hasMessageThat().contains("Found cyclic dependency between modules");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ModuleDependencyValidatorTest method validateAllModules_assetModuleHasDependee_throws.
@Test
public void validateAllModules_assetModuleHasDependee_throws() throws Exception {
ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME)), module("asset", androidManifestForAssetModule(PKG_NAME, withOnDemandDelivery())), module("feature", androidManifest(PKG_NAME, withOnDemandDelivery(), withUsesSplit("asset"))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
assertThat(exception).hasMessageThat().contains("Module 'feature' cannot depend on module 'asset' because one of them is an asset" + " pack.");
}
Aggregations