Search in sources :

Example 16 with Assets

use of com.android.bundle.Files.Assets in project bundletool by google.

the class AssetsTargetingValidatorTest method validateModule_defaultInstanceOfAbiTargeting_throws.

@Test
public void validateModule_defaultInstanceOfAbiTargeting_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir", AssetsDirectoryTargeting.newBuilder().setAbi(AbiTargeting.getDefaultInstance()).build()));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("assets/dir/raw.dat").setAssetsConfig(config).setManifest(androidManifestForAssetModule("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("set but empty ABI targeting");
}
Also used : Assets(com.android.bundle.Files.Assets) 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 Assets

use of com.android.bundle.Files.Assets in project bundletool by google.

the class AssetsTargetingValidatorTest method validateModule_defaultInstanceOfTcfTargeting_throws.

@Test
public void validateModule_defaultInstanceOfTcfTargeting_throws() throws Exception {
    Assets config = assets(targetedAssetsDirectory("assets/dir", AssetsDirectoryTargeting.newBuilder().setTextureCompressionFormat(TextureCompressionFormatTargeting.getDefaultInstance()).build()));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("assets/dir/raw.dat").setAssetsConfig(config).setManifest(androidManifestForAssetModule("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new AssetsTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("set but empty Texture Compression Format targeting");
}
Also used : Assets(com.android.bundle.Files.Assets) 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 Assets

use of com.android.bundle.Files.Assets in project bundletool by google.

the class TargetingGeneratorTest method generateTargetingForAssets_basicScenario_reverseOrder.

@Test
public void generateTargetingForAssets_basicScenario_reverseOrder() throws Exception {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of(ZipPath.create("assets/world/texture#tcf_atc/i18n#lang_en"), ZipPath.create("assets/world/texture#tcf_atc/i18n#lang_ru"), ZipPath.create("assets/world/texture#tcf_etc1/i18n"), ZipPath.create("assets/world/texture#tcf_etc1/i18n#lang_en")));
    assertThat(assetsConfig).ignoringRepeatedFieldOrder().isEqualTo(Assets.newBuilder().addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_etc1/i18n#lang_en").setTargeting(mergeAssetsTargeting(assetsDirectoryTargeting(languageTargeting("en")), assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8, ImmutableSet.of(TextureCompressionFormatAlias.ATC)))))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_etc1/i18n").setTargeting(mergeAssetsTargeting(assetsDirectoryTargeting(alternativeLanguageTargeting("en")), assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8, ImmutableSet.of(TextureCompressionFormatAlias.ATC)))))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_atc/i18n#lang_ru").setTargeting(mergeAssetsTargeting(assetsDirectoryTargeting(languageTargeting("ru")), assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ATC, ImmutableSet.of(TextureCompressionFormatAlias.ETC1_RGB8)))))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_atc/i18n#lang_en").setTargeting(mergeAssetsTargeting(assetsDirectoryTargeting(languageTargeting("en")), assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ATC, ImmutableSet.of(TextureCompressionFormatAlias.ETC1_RGB8)))))).build());
}
Also used : Assets(com.android.bundle.Files.Assets) Test(org.junit.Test)

Example 19 with Assets

use of com.android.bundle.Files.Assets in project bundletool by google.

the class TargetingGeneratorTest method generateTargetingForAssets_assetsAtTopLevel.

@Test
public void generateTargetingForAssets_assetsAtTopLevel() throws Exception {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of(ZipPath.create("assets")));
    assertThat(assetsConfig).ignoringRepeatedFieldOrder().isEqualTo(Assets.newBuilder().addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets").setTargeting(AssetsDirectoryTargeting.getDefaultInstance())).build());
}
Also used : Assets(com.android.bundle.Files.Assets) Test(org.junit.Test)

Example 20 with Assets

use of com.android.bundle.Files.Assets in project bundletool by google.

the class TargetingGeneratorTest method generateTargetingForAssets_different_types_leaves_ok.

@Test
public void generateTargetingForAssets_different_types_leaves_ok() throws Exception {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of(ZipPath.create("assets/world/texture#tcf_etc1"), ZipPath.create("assets/world/i18n#lang_en")));
    assertThat(assetsConfig).ignoringRepeatedFieldOrder().isEqualTo(Assets.newBuilder().addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_etc1").setTargeting(assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8)))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/i18n#lang_en").setTargeting(assetsDirectoryTargeting(languageTargeting("en")))).build());
}
Also used : Assets(com.android.bundle.Files.Assets) Test(org.junit.Test)

Aggregations

Assets (com.android.bundle.Files.Assets)27 Test (org.junit.Test)21 BundleModule (com.android.tools.build.bundletool.model.BundleModule)11 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)9 ZipPath (com.android.tools.build.bundletool.model.ZipPath)8 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)7 TargetedAssetsDirectory (com.android.bundle.Files.TargetedAssetsDirectory)4 ModuleEntry (com.android.tools.build.bundletool.model.ModuleEntry)4 AssetsDirectoryTargeting (com.android.bundle.Targeting.AssetsDirectoryTargeting)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 XmlNode (com.android.aapt.Resources.XmlNode)2 NativeLibraries (com.android.bundle.Files.NativeLibraries)2 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)2 AppBundle (com.android.tools.build.bundletool.model.AppBundle)2 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)2 Path (java.nio.file.Path)2 ZipFile (java.util.zip.ZipFile)2