Search in sources :

Example 81 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class ModuleDependencyValidatorTest method validateAllModules_assetModuleHasDependency_throws.

@Test
public void validateAllModules_assetModuleHasDependency_throws() throws Exception {
    ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME)), module("asset", androidManifestForAssetModule(PKG_NAME, withOnDemandDelivery(), withUsesSplit("feature"))), module("feature", androidManifest(PKG_NAME, withOnDemandDelivery())));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
    assertThat(exception).hasMessageThat().contains("Module 'asset' cannot depend on module 'feature' because one of them is an asset" + " pack.");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 82 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class ModuleDependencyValidatorTest method validateAllModules_installTimeModuleMinSdkSmallerThanBase_fails.

@Test
public void validateAllModules_installTimeModuleMinSdkSmallerThanBase_fails() throws Exception {
    ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME, withMinSdkVersion(20))), module("feature1", androidManifest(PKG_NAME, withMinSdkVersion(19))));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
    assertThat(exception).hasMessageThat().contains("Install-time module 'feature1' has a minSdkVersion(19) different than the" + " minSdkVersion(20) of its dependency 'base'.");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 83 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class ModuleDependencyValidatorTest method validateAllModules_referencesUnknownModule_throws.

@Test
public void validateAllModules_referencesUnknownModule_throws() throws Exception {
    ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME)), module("featureA", androidManifest(PKG_NAME, withUsesSplit("unknown"))));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
    assertThat(exception).hasMessageThat().contains("Module 'unknown' is referenced by <uses-split> but does not exist");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 84 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class ModuleDependencyValidatorTest method validateAllModules_missingBase_throws.

@Test
public void validateAllModules_missingBase_throws() throws Exception {
    ImmutableList<BundleModule> allModules = ImmutableList.of(module("not_base", androidManifest(PKG_NAME, withSplitId("not_base"))));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
    assertThat(exception).hasMessageThat().contains("Mandatory 'base' module is missing");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 85 with InvalidBundleException

use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.

the class ModuleDependencyValidatorTest method validateAllModules_reflexiveDependency_throws.

@Test
public void validateAllModules_reflexiveDependency_throws() throws Exception {
    ImmutableList<BundleModule> allModules = ImmutableList.of(module("base", androidManifest(PKG_NAME)), module("feature", androidManifest(PKG_NAME, withUsesSplit("feature"))));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ModuleDependencyValidator().validateAllModules(allModules));
    assertThat(exception).hasMessageThat().contains("depends on itself");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Aggregations

InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)188 Test (org.junit.Test)188 BundleModule (com.android.tools.build.bundletool.model.BundleModule)106 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)69 ZipPath (com.android.tools.build.bundletool.model.ZipPath)28 AppBundle (com.android.tools.build.bundletool.model.AppBundle)17 XmlNode (com.android.aapt.Resources.XmlNode)14 Path (java.nio.file.Path)14 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)12 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)10 ResourceTable (com.android.aapt.Resources.ResourceTable)9 ZipFile (java.util.zip.ZipFile)9 ZipBuilder (com.android.tools.build.bundletool.io.ZipBuilder)8 AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)8 ApexImages (com.android.bundle.Files.ApexImages)6 NativeLibraries (com.android.bundle.Files.NativeLibraries)6 BundleConfigBuilder (com.android.tools.build.bundletool.testing.BundleConfigBuilder)6 Truth.assertThat (com.google.common.truth.Truth.assertThat)6 IOException (java.io.IOException)6 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)6