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