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");
}
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");
}
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());
}
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());
}
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());
}
Aggregations