Search in sources :

Example 11 with ApkTargeting

use of com.android.bundle.Targeting.ApkTargeting in project bundletool by google.

the class MergingUtilsTest method mergeShardTargetings_differentDensities_ok.

@Test
public void mergeShardTargetings_differentDensities_ok() {
    ApkTargeting targeting1 = apkDensityTargeting(DensityAlias.MDPI, ImmutableSet.of(DensityAlias.HDPI, DensityAlias.LDPI));
    ApkTargeting targeting2 = apkDensityTargeting(DensityAlias.HDPI, ImmutableSet.of(DensityAlias.MDPI, DensityAlias.LDPI));
    ApkTargeting merged = MergingUtils.mergeShardTargetings(targeting1, targeting2);
    assertThat(merged).ignoringRepeatedFieldOrder().isEqualTo(apkDensityTargeting(ImmutableSet.of(DensityAlias.MDPI, DensityAlias.HDPI), ImmutableSet.of(DensityAlias.LDPI)));
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) TargetingUtils.mergeApkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting) Test(org.junit.Test)

Example 12 with ApkTargeting

use of com.android.bundle.Targeting.ApkTargeting in project bundletool by google.

the class MergingUtilsTest method mergeShardTargetings_defaultInstances_ok.

@Test
public void mergeShardTargetings_defaultInstances_ok() {
    ApkTargeting targeting = ApkTargeting.getDefaultInstance();
    ApkTargeting merged = MergingUtils.mergeShardTargetings(targeting, targeting);
    assertThat(merged).isEqualTo(targeting);
    assertThat(merged.hasAbiTargeting()).isFalse();
    assertThat(merged.hasScreenDensityTargeting()).isFalse();
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) TargetingUtils.mergeApkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting) Test(org.junit.Test)

Example 13 with ApkTargeting

use of com.android.bundle.Targeting.ApkTargeting in project bundletool by google.

the class MergingUtilsTest method mergeShardTargetings_equalDeviceTier_ok.

@Test
public void mergeShardTargetings_equalDeviceTier_ok() {
    ApkTargeting targeting = apkDeviceTierTargeting(deviceTierTargeting(0, ImmutableList.of(1)));
    assertThat(MergingUtils.mergeShardTargetings(targeting, targeting)).isEqualTo(targeting);
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) TargetingUtils.mergeApkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting) Test(org.junit.Test)

Example 14 with ApkTargeting

use of com.android.bundle.Targeting.ApkTargeting in project bundletool by google.

the class MergingUtilsTest method mergeShardTargetings_differentLanguages_ok.

@Test
public void mergeShardTargetings_differentLanguages_ok() {
    ApkTargeting targeting1 = apkAlternativeLanguageTargeting("en", "jp");
    ApkTargeting targeting2 = apkLanguageTargeting("fr");
    assertThat(MergingUtils.mergeShardTargetings(targeting1, targeting2)).isEqualTo(apkLanguageTargeting(ImmutableSet.of("fr"), ImmutableSet.of("en", "jp")));
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) TargetingUtils.mergeApkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting) Test(org.junit.Test)

Example 15 with ApkTargeting

use of com.android.bundle.Targeting.ApkTargeting in project bundletool by google.

the class TargetingUtils method standaloneApkVariantTargeting.

public static VariantTargeting standaloneApkVariantTargeting(ModuleSplit standaloneApk) {
    ApkTargeting apkTargeting = standaloneApk.getApkTargeting();
    VariantTargeting.Builder variantTargeting = sdkVariantTargeting(standaloneApk.getAndroidManifest().getEffectiveMinSdkVersion()).toBuilder();
    if (apkTargeting.hasAbiTargeting()) {
        variantTargeting.setAbiTargeting(apkTargeting.getAbiTargeting());
    }
    if (apkTargeting.hasScreenDensityTargeting()) {
        variantTargeting.setScreenDensityTargeting(apkTargeting.getScreenDensityTargeting());
    }
    if (apkTargeting.hasMultiAbiTargeting()) {
        variantTargeting.setMultiAbiTargeting(apkTargeting.getMultiAbiTargeting());
    }
    if (apkTargeting.hasTextureCompressionFormatTargeting()) {
        variantTargeting.setTextureCompressionFormatTargeting(apkTargeting.getTextureCompressionFormatTargeting());
    }
    return variantTargeting.build();
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) VariantTargeting(com.android.bundle.Targeting.VariantTargeting)

Aggregations

ApkTargeting (com.android.bundle.Targeting.ApkTargeting)49 Test (org.junit.Test)44 TargetingUtils.mergeApkTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting)28 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)22 BundleModule (com.android.tools.build.bundletool.model.BundleModule)18 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)18 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)10 ResourceTable (com.android.aapt.Resources.ResourceTable)8 DensityAlias (com.android.bundle.Targeting.ScreenDensity.DensityAlias)7 ImmutableList (com.google.common.collect.ImmutableList)7 ImmutableSet (com.google.common.collect.ImmutableSet)7 ApexImages (com.android.bundle.Files.ApexImages)6 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)6 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)6 Configuration (com.android.aapt.ConfigurationOuterClass.Configuration)5 ZipPath (com.android.tools.build.bundletool.model.ZipPath)5 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)5 MDPI (com.android.tools.build.bundletool.testing.ResourcesTableFactory.MDPI)5 USER_PACKAGE_OFFSET (com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET)5 ImmutableMap (com.google.common.collect.ImmutableMap)5