Search in sources :

Example 16 with BundleModule

use of com.android.tools.build.bundletool.model.BundleModule 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 17 with BundleModule

use of com.android.tools.build.bundletool.model.BundleModule 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)

Example 18 with BundleModule

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

the class ApexBundleValidatorTest method validateModule_missingPackageFromApexManifest_throws.

@Test
public void validateModule_missingPackageFromApexManifest_throws() throws Exception {
    BundleModule apexModule = new BundleModuleBuilder("apexTestModule").setManifest(androidManifest(PKG_NAME)).setApexConfig(APEX_CONFIG).addFile(APEX_MANIFEST_PATH, ApexManifest.getDefaultInstance().toByteArray()).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("APEX manifest must have a package name");
}
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 19 with BundleModule

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

the class ApexBundleValidatorTest method validateAllModules_multipleApexModules_throws.

@Test
public void validateAllModules_multipleApexModules_throws() throws Exception {
    BundleModule apexModule = validApexModule();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ApexBundleValidator().validateAllModules(ImmutableList.of(apexModule, apexModule)));
    assertThat(exception).hasMessageThat().contains("Multiple APEX modules are not allowed, found 2.");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 20 with BundleModule

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

the class ApexBundleValidatorTest method validateModule_untargetedImageFile_throws.

@Test
public void validateModule_untargetedImageFile_throws() throws Exception {
    BundleModule apexModule = new BundleModuleBuilder("apexTestModule").setManifest(androidManifest(PKG_NAME)).setApexConfig(APEX_CONFIG).addFile(APEX_MANIFEST_PATH, APEX_MANIFEST).addFile("apex/x86_64.img").addFile("apex/x86.img").addFile("apex/armeabi-v7a.img").addFile("apex/arm64-v8a.img").addFile("apex/x86_64.x86.img").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new ApexBundleValidator().validateModule(apexModule));
    assertThat(exception).hasMessageThat().contains("Found APEX image files that are not targeted");
}
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

BundleModule (com.android.tools.build.bundletool.model.BundleModule)404 Test (org.junit.Test)370 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)321 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)158 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)112 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)42 ResourceTable (com.android.aapt.Resources.ResourceTable)40 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)29 ImmutableList (com.google.common.collect.ImmutableList)27 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)24 ImmutableSet (com.google.common.collect.ImmutableSet)22 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)21 DensityAlias (com.android.bundle.Targeting.ScreenDensity.DensityAlias)19 AppBundle (com.android.tools.build.bundletool.model.AppBundle)15 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)15 TestUtils.extractPaths (com.android.tools.build.bundletool.testing.TestUtils.extractPaths)15 Truth.assertThat (com.google.common.truth.Truth.assertThat)15 RunWith (org.junit.runner.RunWith)15 Assets (com.android.bundle.Files.Assets)14 VariantTargeting (com.android.bundle.Targeting.VariantTargeting)14