Search in sources :

Example 11 with VariantTargeting

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

the class AssetModuleSizeAggregatorTest method getSize_singleAssetModule_noTargeting.

@Test
public void getSize_singleAssetModule_noTargeting() throws Exception {
    ImmutableList<AssetSliceSet> assetModules = ImmutableList.of(createAssetSliceSet("asset1", DeliveryType.INSTALL_TIME, createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("asset1-master.apk"))));
    VariantTargeting variantTargeting = VariantTargeting.getDefaultInstance();
    ImmutableMap<String, Long> sizeByApkPaths = ImmutableMap.of("asset1-master.apk", 10L);
    ConfigurationSizes configurationSizes = new AssetModuleSizeAggregator(assetModules, variantTargeting, sizeByApkPaths, getSizeCommand.build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 10L);
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 10L);
}
Also used : ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) ApksArchiveHelpers.createAssetSliceSet(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createAssetSliceSet) AssetSliceSet(com.android.bundle.Commands.AssetSliceSet) Test(org.junit.Test)

Example 12 with VariantTargeting

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

the class AssetModuleSizeAggregatorTest method getSize_multipleAssetModules_withTargeting.

@Test
public void getSize_multipleAssetModules_withTargeting() throws Exception {
    ImmutableList<AssetSliceSet> assetModules = ImmutableList.of(ASSET_MODULE_1, ASSET_MODULE_2);
    VariantTargeting variantTargeting = variantSdkTargeting(21);
    ConfigurationSizes configurationSizes = new AssetModuleSizeAggregator(assetModules, variantTargeting, SIZE_BY_APK_PATHS, getSizeCommand.setDimensions(ImmutableSet.of(TEXTURE_COMPRESSION_FORMAT)).build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setTextureCompressionFormat("etc2").build(), ASSET_1_MASTER_SIZE + ASSET_1_ETC2_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ETC2_SIZE, SizeConfiguration.builder().setTextureCompressionFormat("astc").build(), ASSET_1_MASTER_SIZE + ASSET_1_ASTC_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ASTC_SIZE);
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setTextureCompressionFormat("etc2").build(), ASSET_1_MASTER_SIZE + ASSET_1_ETC2_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ETC2_SIZE, SizeConfiguration.builder().setTextureCompressionFormat("astc").build(), ASSET_1_MASTER_SIZE + ASSET_1_ASTC_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ASTC_SIZE);
}
Also used : ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) ApksArchiveHelpers.createAssetSliceSet(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createAssetSliceSet) AssetSliceSet(com.android.bundle.Commands.AssetSliceSet) Test(org.junit.Test)

Example 13 with VariantTargeting

use of com.android.bundle.Targeting.VariantTargeting 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)

Example 14 with VariantTargeting

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

the class AlternativeVariantTargetingPopulatorTest method screenDensity_alternativesPopulated.

@Test
public void screenDensity_alternativesPopulated() throws Exception {
    VariantTargeting ldpiTargeting = variantDensityTargeting(DensityAlias.LDPI);
    VariantTargeting mdpiTargeting = variantDensityTargeting(DensityAlias.MDPI);
    VariantTargeting hdpiTargeting = variantDensityTargeting(DensityAlias.HDPI);
    ImmutableList<ModuleSplit> outputVariants = new ScreenDensityAlternativesPopulator().addAlternativeVariantTargeting(ImmutableList.of(createModuleSplit(ldpiTargeting), createModuleSplit(mdpiTargeting), createModuleSplit(hdpiTargeting)));
    assertThat(outputVariants).hasSize(3);
    ModuleSplit ldpiVariantNew = outputVariants.get(0);
    assertThat(ldpiVariantNew.getVariantTargeting()).ignoringRepeatedFieldOrder().isEqualTo(variantDensityTargeting(toScreenDensity(DensityAlias.LDPI), ImmutableSet.of(toScreenDensity(DensityAlias.MDPI), toScreenDensity(DensityAlias.HDPI))));
    ModuleSplit mdpiVariantNew = outputVariants.get(1);
    assertThat(mdpiVariantNew.getVariantTargeting()).ignoringRepeatedFieldOrder().isEqualTo(variantDensityTargeting(toScreenDensity(DensityAlias.MDPI), ImmutableSet.of(toScreenDensity(DensityAlias.LDPI), toScreenDensity(DensityAlias.HDPI))));
    ModuleSplit hdpiVariantNew = outputVariants.get(2);
    assertThat(hdpiVariantNew.getVariantTargeting()).ignoringRepeatedFieldOrder().isEqualTo(variantDensityTargeting(toScreenDensity(DensityAlias.HDPI), ImmutableSet.of(toScreenDensity(DensityAlias.LDPI), toScreenDensity(DensityAlias.MDPI))));
}
Also used : ScreenDensityAlternativesPopulator(com.android.tools.build.bundletool.model.targeting.AlternativeVariantTargetingPopulator.ScreenDensityAlternativesPopulator) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) TargetingUtils.mergeVariantTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeVariantTargeting) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) Test(org.junit.Test)

Example 15 with VariantTargeting

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

the class AlternativeVariantTargetingPopulatorTest method sdk_alternativesPopulated.

@Test
public void sdk_alternativesPopulated() throws Exception {
    VariantTargeting lPlusTargeting = variantSdkTargeting(sdkVersionFrom(21));
    VariantTargeting mPlusTargeting = variantSdkTargeting(sdkVersionFrom(23));
    VariantTargeting defaultSdkTargeting = variantSdkTargeting(SdkVersion.getDefaultInstance());
    ImmutableList<ModuleSplit> outputVariants = new SdkVersionAlternativesPopulator().addAlternativeVariantTargeting(ImmutableList.of(createModuleSplit(lPlusTargeting), createModuleSplit(mPlusTargeting), createModuleSplit(defaultSdkTargeting)));
    assertThat(outputVariants).hasSize(3);
    ModuleSplit lPlusVariantNew = outputVariants.get(0);
    assertThat(lPlusVariantNew.getVariantTargeting()).ignoringRepeatedFieldOrder().isEqualTo(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(SdkVersion.getDefaultInstance(), sdkVersionFrom(23))));
    ModuleSplit mPlusVariantNew = outputVariants.get(1);
    assertThat(mPlusVariantNew.getVariantTargeting()).ignoringRepeatedFieldOrder().isEqualTo(variantSdkTargeting(sdkVersionFrom(23), ImmutableSet.of(SdkVersion.getDefaultInstance(), sdkVersionFrom(21))));
    ModuleSplit defaultSdkVariantNew = outputVariants.get(2);
    assertThat(defaultSdkVariantNew.getVariantTargeting()).ignoringRepeatedFieldOrder().isEqualTo(variantSdkTargeting(SdkVersion.getDefaultInstance(), ImmutableSet.of(sdkVersionFrom(21), sdkVersionFrom(23))));
}
Also used : SdkVersionAlternativesPopulator(com.android.tools.build.bundletool.model.targeting.AlternativeVariantTargetingPopulator.SdkVersionAlternativesPopulator) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) TargetingUtils.mergeVariantTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeVariantTargeting) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) Test(org.junit.Test)

Aggregations

VariantTargeting (com.android.bundle.Targeting.VariantTargeting)37 Test (org.junit.Test)31 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)16 TargetingUtils.mergeVariantTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.mergeVariantTargeting)16 BundleModule (com.android.tools.build.bundletool.model.BundleModule)12 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)9 SdkVersion (com.android.bundle.Targeting.SdkVersion)6 ImmutableSet (com.google.common.collect.ImmutableSet)6 AssetSliceSet (com.android.bundle.Commands.AssetSliceSet)5 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)5 GeneratedApks (com.android.tools.build.bundletool.model.GeneratedApks)5 TargetingUtils.lPlusVariantTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.lPlusVariantTargeting)5 ImmutableList (com.google.common.collect.ImmutableList)5 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)4 Configuration (com.android.aapt.ConfigurationOuterClass.Configuration)3 BundleConfig (com.android.bundle.Config.BundleConfig)3 ApexImages (com.android.bundle.Files.ApexImages)3 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)3 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)3 ApexManifest (com.android.apex.ApexManifestProto.ApexManifest)2