Search in sources :

Example 96 with InvalidBundleException

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

the class BundleConfigValidatorTest method optimizations_duplicateSplitDimensions_throws.

@Test
public void optimizations_duplicateSplitDimensions_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearOptimizations().addSplitDimension(SplitDimension.Value.ABI).addSplitDimension(SplitDimension.Value.ABI));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(exception).hasMessageThat().contains("duplicate split dimensions:");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) Test(org.junit.Test)

Example 97 with InvalidBundleException

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

the class BundleConfigValidatorTest method compression_forbiddenCharactersInGlob_carriageReturn_throws.

@Test
public void compression_forbiddenCharactersInGlob_carriageReturn_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearCompression().addUncompressedGlob("res/raw/**\nassets/raw/**"));
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(e).hasMessageThat().contains("Invalid uncompressed glob: 'res/raw/**\nassets/raw/**'.");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) Test(org.junit.Test)

Example 98 with InvalidBundleException

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

the class BundleConfigValidatorTest method optimizations_nonTcfDimensionsSuffixStripping_throws.

@Test
public void optimizations_nonTcfDimensionsSuffixStripping_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearOptimizations().addSplitDimension(SplitDimension.newBuilder().setValueValue(Value.LANGUAGE_VALUE).setSuffixStripping(SuffixStripping.newBuilder().setEnabled(true)).build()));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(exception).hasMessageThat().contains("Suffix stripping was enabled for an unsupported dimension. Supported dimensions are:" + " TEXTURE_COMPRESSION_FORMAT, DEVICE_TIER.");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) Test(org.junit.Test)

Example 99 with InvalidBundleException

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

the class BundleConfigValidatorTest method compression_forbiddenCharactersInGlob_backslash_throws.

@Test
public void compression_forbiddenCharactersInGlob_backslash_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearCompression().addUncompressedGlob("res\\\\raw\\\\**"));
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(e).hasMessageThat().contains("Invalid uncompressed glob: 'res\\\\raw\\\\**'.");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) Test(org.junit.Test)

Example 100 with InvalidBundleException

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

the class BundleConfigValidatorTest method optimizations_unrecognizedDimensionsEnabled_throws.

@Test
public void optimizations_unrecognizedDimensionsEnabled_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearOptimizations().addSplitDimension(SplitDimension.newBuilder().setValueValue(1234).build()));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(exception).hasMessageThat().contains("BundleConfig.pb contains an unrecognized split dimension.");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) 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