Search in sources :

Example 11 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.

the class AndroidManifestValidatorTest method assetModule_withVersionCode_throws.

@Test
public void assetModule_withVersionCode_throws() throws Exception {
    ImmutableList<BundleModule> bundleModules = ImmutableList.of(new BundleModuleBuilder(BASE_MODULE_NAME).setManifest(androidManifest("com.test", withVersionCode(2))).build(), new BundleModuleBuilder("asset_module").setManifest(androidManifestForAssetModule("com.test.app", withVersionCode(42))).build());
    Throwable exception = assertThrows(InvalidBundleException.class, () -> new AndroidManifestValidator().validateAllModules(bundleModules));
    assertThat(exception).hasMessageThat().matches("Asset packs cannot specify a version code, but 'asset_module' does.");
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 12 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder 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 13 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder 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 14 with BundleModuleBuilder

use of com.android.tools.build.bundletool.testing.BundleModuleBuilder 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 15 with BundleModuleBuilder

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

Aggregations

BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)349 Test (org.junit.Test)348 BundleModule (com.android.tools.build.bundletool.model.BundleModule)321 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)164 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)69 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)44 ResourceTable (com.android.aapt.Resources.ResourceTable)38 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)28 DensityAlias (com.android.bundle.Targeting.ScreenDensity.DensityAlias)19 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)16 Truth.assertThat (com.google.common.truth.Truth.assertThat)16 RunWith (org.junit.runner.RunWith)16 TestUtils.extractPaths (com.android.tools.build.bundletool.testing.TestUtils.extractPaths)15 ImmutableList (com.google.common.collect.ImmutableList)15 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)15 ProtoTruth.assertThat (com.google.common.truth.extensions.proto.ProtoTruth.assertThat)15 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)14 NativeLibraries (com.android.bundle.Files.NativeLibraries)13 HDPI (com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI)13 USER_PACKAGE_OFFSET (com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET)13