Search in sources :

Example 1 with InvalidBundleException

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

the class AbiParityValidatorTest method differentAbis_throws.

@Test
public void differentAbis_throws() throws Exception {
    BundleModule moduleA = new BundleModuleBuilder("a").addFile("lib/x86/lib1.so").addFile("lib/mips/lib2.so").setManifest(androidManifest("com.test.app")).build();
    BundleModule moduleB = new BundleModuleBuilder("b").addFile("lib/x86/lib3.so").addFile("lib/x86_64/lib4.so").setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AbiParityValidator().validateAllModules(ImmutableList.of(moduleA, moduleB)));
    assertThat(exception).hasMessageThat().contains("must support the same set of ABIs");
}
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 2 with InvalidBundleException

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

the class AndroidManifestValidatorTest method instantAssetModuleWithInstallTimeInstantDelivery_throws.

@Test
public void instantAssetModuleWithInstallTimeInstantDelivery_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder("assetmodule").setManifest(androidManifestForAssetModule(PKG_NAME, withOnDemandDelivery(), withInstantInstallTimeDelivery())).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateModule(module));
    assertThat(exception).hasMessageThat().startsWith("Instant delivery cannot be install-time (module '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 3 with InvalidBundleException

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

the class AndroidManifestValidatorTest method bundleModules_differentTargetSandboxVersionCode_throws.

@Test
public void bundleModules_differentTargetSandboxVersionCode_throws() throws Exception {
    ImmutableList<BundleModule> bundleModules = ImmutableList.of(new BundleModuleBuilder(BASE_MODULE_NAME).setManifest(androidManifest("com.test", withTargetSandboxVersion(1))).build(), new BundleModuleBuilder(FEATURE_MODULE_NAME).setManifest(androidManifest("com.test", withTargetSandboxVersion(2))).build());
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateAllModules(bundleModules));
    assertThat(exception).hasMessageThat().contains("should have the same value across modules, but found [1,2]");
}
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 4 with InvalidBundleException

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

the class AndroidManifestValidatorTest method supportsGlTextureWithTcfs_throws.

@Test
public void supportsGlTextureWithTcfs_throws() throws Exception {
    ImmutableList<BundleModule> bundleModules = ImmutableList.of(new BundleModuleBuilder(BASE_MODULE_NAME).setManifest(androidManifest("com.test", withVersionCode(2), withSupportsGlTexture("GL_OES_compressed_ETC1_RGB8_texture"))).build(), new BundleModuleBuilder("asset_module").addFile("assets/other_textures#tcf_astc/astc_file.assets").setManifest(androidManifestForAssetModule("com.test.app")).build());
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateAllModules(bundleModules));
    assertThat(exception).hasMessageThat().contains("Modules cannot have supports-gl-texture in their manifest (found:" + " [GL_OES_compressed_ETC1_RGB8_texture]) and" + " texture targeted directories in modules (found: [ASTC]).");
}
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 5 with InvalidBundleException

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

the class ApexBundleValidatorTest method validateModule_missingApexManifest_throws.

@Test
public void validateModule_missingApexManifest_throws() throws Exception {
    BundleModule apexModule = new BundleModuleBuilder("apexTestModule").setManifest(androidManifest(PKG_NAME)).setApexConfig(APEX_CONFIG).addFile("apex/x86_64.img").addFile("apex/x86.img").addFile("apex/armeabi-v7a.img").addFile("apex/arm64-v8a.img").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ApexBundleValidator().validateModule(apexModule));
    assertThat(exception).hasMessageThat().contains("Missing expected file in APEX bundle");
}
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