Search in sources :

Example 21 with Assets

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

the class TargetingGeneratorTest method generateTargetingForAssets_emptyInput_emptyOutput.

@Test
public void generateTargetingForAssets_emptyInput_emptyOutput() throws Exception {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of());
    assertThat(assetsConfig).isEqualToDefaultInstance();
}
Also used : Assets(com.android.bundle.Files.Assets) Test(org.junit.Test)

Example 22 with Assets

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

the class TargetingGeneratorTest method generateTargetingForAssets_deviceTierTargeting.

@Test
public void generateTargetingForAssets_deviceTierTargeting() {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of(ZipPath.create("assets/img#tier_0"), ZipPath.create("assets/img#tier_1"), ZipPath.create("assets/img#tier_2")));
    assertThat(assetsConfig).ignoringRepeatedFieldOrder().isEqualTo(Assets.newBuilder().addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/img#tier_0").setTargeting(assetsDirectoryTargeting(deviceTierTargeting(/* value= */
    0, /* alternatives= */
    ImmutableList.of(1, 2))))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/img#tier_1").setTargeting(assetsDirectoryTargeting(deviceTierTargeting(/* value= */
    1, /* alternatives= */
    ImmutableList.of(0, 2))))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/img#tier_2").setTargeting(assetsDirectoryTargeting(deviceTierTargeting(/* value= */
    2, /* alternatives= */
    ImmutableList.of(0, 1))))).build());
}
Also used : Assets(com.android.bundle.Files.Assets) Test(org.junit.Test)

Example 23 with Assets

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

the class TargetingGeneratorTest method generateTargetingForAssets_NonTargeted_midpath.

@Test
public void generateTargetingForAssets_NonTargeted_midpath() {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of(ZipPath.create("assets/world/texture#tcf_atc/rest/i18n#lang_en"), ZipPath.create("assets/world/texture#tcf_atc/rest/i18n#lang_ru"), // Note that the two below should not have any alternatives for OpenGL version.
    ZipPath.create("assets/world/texture#tcf_etc1/rest/i18n#lang_ru"), 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/rest/i18n#lang_ru").setTargeting(mergeAssetsTargeting(assetsDirectoryTargeting(languageTargeting("ru")), assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8, ImmutableSet.of(TextureCompressionFormatAlias.ATC)))))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_atc/rest/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/rest/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 24 with Assets

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

the class TargetingGeneratorTest method generateTargetingForAssets_languageTargeting.

@Test
public void generateTargetingForAssets_languageTargeting() {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of(ZipPath.create("assets/world/i18n#lang_de"), ZipPath.create("assets/world/i18n#lang_jp"), ZipPath.create("assets/world/i18n"), // compression format.
    ZipPath.create("assets/world/texture#tcf_etc1/i18n#lang_pl"), ZipPath.create("assets/world/texture#tcf_etc1/i18n")));
    assertThat(assetsConfig).ignoringRepeatedFieldOrder().isEqualTo(Assets.newBuilder().addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/i18n#lang_de").setTargeting(assetsDirectoryTargeting(languageTargeting("de")))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/i18n#lang_jp").setTargeting(assetsDirectoryTargeting(languageTargeting("jp")))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/i18n").setTargeting(assetsDirectoryTargeting(alternativeLanguageTargeting("de", "jp")))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_etc1/i18n#lang_pl").setTargeting(mergeAssetsTargeting(assetsDirectoryTargeting(languageTargeting("pl")), assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8))))).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/texture#tcf_etc1/i18n").setTargeting(mergeAssetsTargeting(assetsDirectoryTargeting(alternativeLanguageTargeting("pl")), assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8))))).build());
}
Also used : Assets(com.android.bundle.Files.Assets) Test(org.junit.Test)

Example 25 with Assets

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

the class TargetingGeneratorTest method generateTargetingForAssets_nonTargetedDirectories.

@Test
public void generateTargetingForAssets_nonTargetedDirectories() throws Exception {
    Assets assetsConfig = new TargetingGenerator().generateTargetingForAssets(ImmutableList.of(ZipPath.create("assets/static"), ZipPath.create("assets/world/static"), ZipPath.create("assets/world/static-alt")));
    assertThat(assetsConfig).ignoringRepeatedFieldOrder().isEqualTo(Assets.newBuilder().addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/static").setTargeting(AssetsDirectoryTargeting.getDefaultInstance())).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/static").setTargeting(AssetsDirectoryTargeting.getDefaultInstance())).addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/world/static-alt").setTargeting(AssetsDirectoryTargeting.getDefaultInstance())).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