Search in sources :

Example 21 with InvalidBundleException

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

the class AndroidManifestValidatorTest method conditionalModuleNonRemovable_throws.

@Test
public void conditionalModuleNonRemovable_throws() throws Exception {
    ImmutableList<BundleModule> bundleModules = ImmutableList.of(new BundleModuleBuilder(BASE_MODULE_NAME).addFile("assets/textures#tcf_astc/level1.assets").setManifest(androidManifest("com.test")).build(), new BundleModuleBuilder("asset_module").addFile("assets/other_textures#tcf_astc/astc_file.assets").setManifest(androidManifestForAssetModule("com.test.app", withInstallTimeRemovableElement(false), withMinSdkVersion(24), withFeatureCondition("android.feature"))).build());
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateAllModules(bundleModules));
    assertThat(exception).hasMessageThat().contains("Conditional modules cannot be set to non-removable.");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 22 with InvalidBundleException

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

the class AndroidManifestValidatorTest method withMultipleDistinctSplitIds_throws.

@Test
public void withMultipleDistinctSplitIds_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifestForFeature(PKG_NAME, withSplitId(FEATURE_MODULE_NAME), withSecondSplitId("modulesplitname2"))).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("attribute 'split' cannot be declared more than once");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 23 with InvalidBundleException

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

the class AndroidManifestValidatorTest method assetModuleWithConditionalTargeting_throws.

@Test
public void assetModuleWithConditionalTargeting_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder("assetmodule").setManifest(androidManifestForAssetModule(PKG_NAME, withFeatureCondition("camera"))).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Conditional targeting is not allowed in asset packs, but found in 'assetmodule'.");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 24 with InvalidBundleException

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

the class AndroidManifestValidatorTest method withNegativeMinSdk_throws.

@Test
public void withNegativeMinSdk_throws() throws Exception {
    BundleModule module = baseModule(withMinSdkVersion(-1));
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(e).hasMessageThat().isEqualTo("minSdkVersion must be nonnegative, found: (-1).");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 25 with InvalidBundleException

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

the class AndroidManifestValidatorTest method withHighTargetSandboxVersionCode_throws.

@Test
public void withHighTargetSandboxVersionCode_throws() throws Exception {
    BundleModule module = baseModule(withTargetSandboxVersion(3));
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateAllModules(ImmutableList.of(module)));
    assertThat(e).hasMessageThat().contains("cannot have a value greater than 2, but found 3");
}
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