Search in sources :

Example 11 with InvalidBundleException

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

the class AssetModuleFilesValidatorTest method moduleWithInvalidEntries_throws.

@Test
public void moduleWithInvalidEntries_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder(MODULE_NAME).setManifest(androidManifestForAssetModule(PKG_NAME)).addFile("res/string.xml").addFile("lib/x86/awesomelib.so").addFile("assets/kitten.jpg").addFile("root/groot.jpg").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AssetModuleFilesValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Invalid entries found in asset pack 'assetmodule': 'res/string.xml'," + " 'lib/x86/awesomelib.so', 'root/groot.jpg'.");
}
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 12 with InvalidBundleException

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

the class AssetsTargetingValidatorTest method validateModule_emptyTargetedDirectory_throws.

@Test
public void validateModule_emptyTargetedDirectory_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8))));
    BundleModule module = new BundleModuleBuilder("testModule").setAssetsConfig(config).setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("Targeted directory 'assets/dir#tcf_etc1' is empty.");
}
Also used : Assets(com.android.bundle.Files.Assets) 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 13 with InvalidBundleException

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

the class BundleConfigValidatorTest method optimizations_tcfDimensionSuffixStrippingWithInvalidDefault_throws.

@Test
public void optimizations_tcfDimensionSuffixStrippingWithInvalidDefault_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearOptimizations().addSplitDimension(SplitDimension.newBuilder().setValueValue(Value.TEXTURE_COMPRESSION_FORMAT_VALUE).setSuffixStripping(SuffixStripping.newBuilder().setEnabled(true).setDefaultSuffix("unrecognized_tcf")).build()));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new BundleConfigValidator().validateBundle(appBundle));
    assertThat(exception).hasMessageThat().contains("The default texture compression format chosen for suffix stripping" + " (\"unrecognized_tcf\") is not valid.");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) Test(org.junit.Test)

Example 14 with InvalidBundleException

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

the class BundleConfigValidatorTest method optimizations_duplicateSplitDimensions_positiveAndNegative_throws.

@Test
public void optimizations_duplicateSplitDimensions_positiveAndNegative_throws() throws Exception {
    AppBundle appBundle = createAppBundle(BundleConfigBuilder.create().clearOptimizations().addSplitDimension(SplitDimension.Value.ABI, /* negate= */
    false).addSplitDimension(SplitDimension.Value.ABI, /* negate= */
    true));
    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 15 with InvalidBundleException

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

the class BundleConfigValidatorTest method compression_invalidGlob_throws.

@Test
public void compression_invalidGlob_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)

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