Search in sources :

Example 61 with InvalidBundleException

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

the class TextureCompressionFormatParityValidatorTest method differentTCFs_throws.

@Test
public void differentTCFs_throws() throws Exception {
    BundleModule moduleA = new BundleModuleBuilder("a").addFile("assets/textures#tcf_astc/level1.assets").addFile("assets/textures#tcf_etc2/level1.assets").setManifest(androidManifest("com.test.app")).build();
    BundleModule moduleB = new BundleModuleBuilder("b").addFile("assets/other_textures#tcf_astc/astc_file.assets").addFile("assets/other_textures#tcf_pvrtc/etc2_file.assets").setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new TextureCompressionFormatParityValidator().validateAllModules(ImmutableList.of(moduleA, moduleB)));
    assertThat(exception).hasMessageThat().contains("All modules with targeted textures must have the same set of texture formats, but" + " module 'a' has formats [ASTC, ETC2] (without fallback directories) and module" + " 'b' has formats [ASTC, PVRTC] (without fallback directories).");
}
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 62 with InvalidBundleException

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

the class TextureCompressionFormatParityValidatorTest method differentFallbacks_throws.

@Test
public void differentFallbacks_throws() throws Exception {
    BundleModule moduleA = new BundleModuleBuilder("a").addFile("assets/textures#tcf_astc/level1.assets").addFile("assets/textures/level1.assets").setManifest(androidManifest("com.test.app")).build();
    BundleModule moduleB = new BundleModuleBuilder("b").addFile("assets/other_textures#tcf_astc/astc_file.assets").setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new TextureCompressionFormatParityValidator().validateAllModules(ImmutableList.of(moduleA, moduleB)));
    assertThat(exception).hasMessageThat().contains("All modules with targeted textures must have the same set of texture formats, but" + " module 'a' has formats [ASTC] (with fallback directories) and module 'b' has" + " formats [ASTC] (without fallback directories).");
}
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 63 with InvalidBundleException

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

the class DeviceTierParityValidatorTest method differentTiersInDifferentFolders_throws.

@Test
public void differentTiersInDifferentFolders_throws() {
    BundleModule moduleA = new BundleModuleBuilder("a").addFile("assets/img1#tier_0/image.jpg").addFile("assets/img1#tier_1/image.jpg").addFile("assets/img2#tier_0/image.jpg").setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new DeviceTierParityValidator().validateAllModules(ImmutableList.of(moduleA)));
    assertThat(exception).hasMessageThat().contains("All device-tier-targeted folders in a module must support the same set of tiers, but" + " module 'a' supports [0, 1] and folder 'assets/img2' supports only [0].");
}
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 64 with InvalidBundleException

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

the class DexFilesValidatorTest method singleDexFile_hasClasses1_throws.

@Test
public void singleDexFile_hasClasses1_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder("base").addFile("dex/classes1.dex").setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new DexFilesValidator().validateModule(module));
    assertThat(exception).hasMessageThat().contains("expecting file 'classes.dex' but found 'classes1.dex'");
}
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 65 with InvalidBundleException

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

the class DexFilesValidatorTest method manyDexFiles_hasClasses1_throws.

@Test
public void manyDexFiles_hasClasses1_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder("base").addFile("dex/classes.dex").addFile("dex/classes1.dex").addFile("dex/classes2.dex").setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new DexFilesValidator().validateModule(module));
    assertThat(exception).hasMessageThat().contains("expecting file 'classes2.dex' but found 'classes1.dex'");
}
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)

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