Search in sources :

Example 21 with BundleModule

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

the class AssetBundleValidatorTest method validateAllModules_assetOnlyWithInstallTime_throws.

@Test
public void validateAllModules_assetOnlyWithInstallTime_throws() throws Exception {
    ImmutableList<BundleModule> allModules = ImmutableList.of(assetOnlyModule("asset", androidManifestForAssetModule(PKG_NAME, withInstallTimeDelivery())));
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AssetBundleValidator().validateAllModules(allModules));
    assertThat(exception).hasMessageThat().contains("Asset-only bundle contains an install-time asset module");
}
Also used : InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 22 with BundleModule

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

the class AssetModuleFilesValidatorTest method validModule_succeeds.

@Test
public void validModule_succeeds() throws Exception {
    BundleModule module = new BundleModuleBuilder(MODULE_NAME).setManifest(androidManifest(PKG_NAME)).addFile("assets/img.jpg").build();
    new AssetModuleFilesValidator().validateModule(module);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 23 with BundleModule

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

the class AssetModuleFilesValidatorTest method moduleWithInvalidEntry_throws.

@Test
public void moduleWithInvalidEntry_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder(MODULE_NAME).setManifest(androidManifestForAssetModule(PKG_NAME)).addFile("dex/classes.dex").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AssetModuleFilesValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Invalid entry found in asset pack 'assetmodule': 'dex/classes.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 24 with BundleModule

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

the class AssetModuleFilesValidatorTest method moduleWithInvalidEntries_throws.

@Test
public void moduleWithInvalidEntries_throws() throws Exception {
    BundleModule module = new BundleModuleBuilder(MODULE_NAME).setManifest(androidManifestForAssetModule(PKG_NAME)).addFile("res/string.xml").addFile("lib/x86/awesomelib.so").addFile("assets/kitten.jpg").addFile("root/groot.jpg").build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AssetModuleFilesValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Invalid entries found in asset pack 'assetmodule': 'res/string.xml'," + " 'lib/x86/awesomelib.so', 'root/groot.jpg'.");
}
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 25 with BundleModule

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

the class AssetsTargetingValidatorTest method validateModule_valid_succeeds.

@Test
public void validateModule_valid_succeeds() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir_other#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8))));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("assets/dir_other#tcf_etc1/raw.dat").setAssetsConfig(config).setManifest(androidManifest("com.test.app")).build();
    new AssetsTargetingValidator().validateModule(module);
}
Also used : Assets(com.android.bundle.Files.Assets) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) 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