Search in sources :

Example 91 with InvalidBundleException

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

the class AssetsTargetingValidatorTest method validateModule_assetModuleLanguageTargeting_throws.

@Test
public void validateModule_assetModuleLanguageTargeting_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir#lang_en", assetsDirectoryTargeting(languageTargeting("en"))));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("assets/dir#lang_en/raw.dat").setAssetsConfig(config).setManifest(androidManifestForAssetModule("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("Language targeting for asset packs is not supported, but found in module testModule.");
}
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 92 with InvalidBundleException

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

the class AssetsTargetingValidatorTest method validateModule_pathOutsideAssets_throws.

@Test
public void validateModule_pathOutsideAssets_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("lib/x86", assetsDirectoryTargeting(abiTargeting(X86))), targetedAssetsDirectory("assets/dir#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8))));
    BundleModule module = new BundleModuleBuilder("testModule").setAssetsConfig(config).addFile("assets/dir#tcf_etc1/file.txt").setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("directory must start with 'assets/'");
}
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 93 with InvalidBundleException

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

the class AssetsTargetingValidatorTest method validateModule_defaultInstanceOfLanguageTargeting_throws.

@Test
public void validateModule_defaultInstanceOfLanguageTargeting_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir", AssetsDirectoryTargeting.newBuilder().setLanguage(LanguageTargeting.getDefaultInstance()).build()));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("assets/dir/raw.dat").setAssetsConfig(config).setManifest(androidManifestForAssetModule("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("set but empty language targeting");
}
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 94 with InvalidBundleException

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

the class AssetsTargetingValidatorTest method validateModule_defaultInstanceOfAbiTargeting_throws.

@Test
public void validateModule_defaultInstanceOfAbiTargeting_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir", AssetsDirectoryTargeting.newBuilder().setAbi(AbiTargeting.getDefaultInstance()).build()));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("assets/dir/raw.dat").setAssetsConfig(config).setManifest(androidManifestForAssetModule("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("set but empty ABI targeting");
}
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 95 with InvalidBundleException

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

the class AssetsTargetingValidatorTest method validateModule_defaultInstanceOfTcfTargeting_throws.

@Test
public void validateModule_defaultInstanceOfTcfTargeting_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir", AssetsDirectoryTargeting.newBuilder().setTextureCompressionFormat(TextureCompressionFormatTargeting.getDefaultInstance()).build()));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("assets/dir/raw.dat").setAssetsConfig(config).setManifest(androidManifestForAssetModule("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("set but empty Texture Compression Format targeting");
}
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)

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