use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class ConfigurationSizesMergerTest method merge_disjointDimensions.
@Test
public void merge_disjointDimensions() throws Exception {
final long config1X86Min = 1 << 0;
final long config1MipsMin = 1 << 1;
final long config1X86Max = 1 << 2;
final long config1MipsMax = 1 << 3;
final long config2HdpiMin = 1 << 4;
final long config2XhdpiMin = 1 << 5;
final long config2HdpiMax = 1 << 6;
final long config2XhdpiMax = 1 << 7;
ConfigurationSizes configurationSizes1 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").setSdkVersion("21-").build(), config1X86Min, SizeConfiguration.builder().setAbi("mips").setSdkVersion("21-").build(), config1MipsMin), ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").setSdkVersion("21-").build(), config1X86Max, SizeConfiguration.builder().setAbi("mips").setSdkVersion("21-").build(), config1MipsMax));
ConfigurationSizes configurationSizes2 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.builder().setScreenDensity("hdpi").setSdkVersion("21-").build(), config2HdpiMin, SizeConfiguration.builder().setScreenDensity("xhdpi").setSdkVersion("21-").build(), config2XhdpiMin), ImmutableMap.of(SizeConfiguration.builder().setScreenDensity("hdpi").setSdkVersion("21-").build(), config2HdpiMax, SizeConfiguration.builder().setScreenDensity("xhdpi").setSdkVersion("21-").build(), config2XhdpiMax));
// All combinations of ABIs and screen densities should be generated.
ConfigurationSizes expectedMergedConfigurationSizes = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").setScreenDensity("hdpi").setSdkVersion("21-").build(), config1X86Min + config2HdpiMin, SizeConfiguration.builder().setAbi("mips").setScreenDensity("hdpi").setSdkVersion("21-").build(), config1MipsMin + config2HdpiMin, SizeConfiguration.builder().setAbi("x86").setScreenDensity("xhdpi").setSdkVersion("21-").build(), config1X86Min + config2XhdpiMin, SizeConfiguration.builder().setAbi("mips").setScreenDensity("xhdpi").setSdkVersion("21-").build(), config1MipsMin + config2XhdpiMin), ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").setScreenDensity("hdpi").setSdkVersion("21-").build(), config1X86Max + config2HdpiMax, SizeConfiguration.builder().setAbi("mips").setScreenDensity("hdpi").setSdkVersion("21-").build(), config1MipsMax + config2HdpiMax, SizeConfiguration.builder().setAbi("x86").setScreenDensity("xhdpi").setSdkVersion("21-").build(), config1X86Max + config2XhdpiMax, SizeConfiguration.builder().setAbi("mips").setScreenDensity("xhdpi").setSdkVersion("21-").build(), config1MipsMax + config2XhdpiMax));
ConfigurationSizes actualMergedConfigurationSizes = ConfigurationSizesMerger.merge(configurationSizes1, configurationSizes2);
assertThat(actualMergedConfigurationSizes.getMinSizeConfigurationMap()).isEqualTo(expectedMergedConfigurationSizes.getMinSizeConfigurationMap());
assertThat(actualMergedConfigurationSizes.getMaxSizeConfigurationMap()).isEqualTo(expectedMergedConfigurationSizes.getMaxSizeConfigurationMap());
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class ConfigurationSizesMergerTest method merge_withEmptyConfiguration.
@Test
public void merge_withEmptyConfiguration() throws Exception {
ConfigurationSizes configurationSizes1 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").build(), 10L), ImmutableMap.of(SizeConfiguration.builder().setAbi("x86").build(), 20L));
ConfigurationSizes configurationSizes2 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.getDefaultInstance(), 0L), ImmutableMap.of(SizeConfiguration.getDefaultInstance(), 0L));
ConfigurationSizes mergedConfigurationSizes = ConfigurationSizesMerger.merge(configurationSizes1, configurationSizes2);
assertThat(mergedConfigurationSizes.getMinSizeConfigurationMap()).isEqualTo(configurationSizes1.getMinSizeConfigurationMap());
assertThat(mergedConfigurationSizes.getMaxSizeConfigurationMap()).isEqualTo(configurationSizes1.getMaxSizeConfigurationMap());
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class GetSizeCommandTest method getSizeTotalInternal_withDimensionsAndDeviceSpec.
@Test
public void getSizeTotalInternal_withDimensionsAndDeviceSpec() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkLanguageTargeting("jp"), ZipPath.create("base-jp.apk"), /* isMasterSplit= */
false), createApkDescription(apkLanguageTargeting("fr"), ZipPath.create("base-fr.apk"), /* isMasterSplit= */
false), createApkDescription(apkDensityTargeting(HDPI, ImmutableSet.of(LDPI)), ZipPath.create("base-hdpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkDensityTargeting(LDPI, ImmutableSet.of(HDPI)), ZipPath.create("base-ldpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(ARM64_V8A, ImmutableSet.of(ARMEABI_V7A)), ZipPath.create("base-arm64_v8a.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(ARMEABI_V7A, ImmutableSet.of(ARM64_V8A)), ZipPath.create("base-armeabi_v7a.apk"), /* isMasterSplit= */
false)));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ConfigurationSizes configurationSizes = GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDeviceSpec(DeviceSpec.newBuilder().setSdkVersion(21).setScreenDensity(125).addSupportedLocales("jp").build()).setDimensions(ImmutableSet.of(Dimension.SDK, Dimension.ABI, Dimension.LANGUAGE, Dimension.SCREEN_DENSITY)).build().getSizeTotalInternal();
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setAbi("armeabi-v7a").setLocale("jp").setScreenDensity("125").setSdkVersion("21").build(), 4 * compressedApkSize, SizeConfiguration.builder().setAbi("arm64-v8a").setLocale("jp").setScreenDensity("125").setSdkVersion("21").build(), 4 * compressedApkSize);
assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setAbi("armeabi-v7a").setLocale("jp").setScreenDensity("125").setSdkVersion("21").build(), 4 * compressedApkSize, SizeConfiguration.builder().setAbi("arm64-v8a").setLocale("jp").setScreenDensity("125").setSdkVersion("21").build(), 4 * compressedApkSize);
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class GetSizeCommandTest method getSizeTotalInternal_multipleStandaloneVariant.
@Test
public void getSizeTotalInternal_multipleStandaloneVariant() throws Exception {
Variant preLLdpiVariant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantDensityTargeting(LDPI, ImmutableSet.of(MDPI))), ApkTargeting.getDefaultInstance(), ZipPath.create("preL-ldpi.apk"));
Variant preLMdpiVariant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantDensityTargeting(MDPI, ImmutableSet.of(LDPI))), ApkTargeting.getDefaultInstance(), ZipPath.create("preL-mdpi.apk"));
ZipBuilder archiveBuilder = new ZipBuilder();
archiveBuilder.addFileWithContent(ZipPath.create("preL-ldpi.apk"), new byte[1000]);
archiveBuilder.addFileWithContent(ZipPath.create("preL-mdpi.apk"), new byte[10]);
archiveBuilder.addFileWithProtoContent(ZipPath.create("toc.pb"), BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(preLLdpiVariant).addVariant(preLMdpiVariant).build());
Path apksArchiveFile = archiveBuilder.writeTo(tmpDir.resolve("bundle.apks"));
ConfigurationSizes configurationSizes = GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).build().getSizeTotalInternal();
assertThat(configurationSizes.getMinSizeConfigurationMap().keySet()).containsExactly(SizeConfiguration.getDefaultInstance());
assertThat(configurationSizes.getMinSizeConfigurationMap().get(SizeConfiguration.getDefaultInstance())).isLessThan(compressedApkSize);
assertThat(configurationSizes.getMaxSizeConfigurationMap().keySet()).containsExactly(SizeConfiguration.getDefaultInstance());
assertThat(configurationSizes.getMaxSizeConfigurationMap().get(SizeConfiguration.getDefaultInstance())).isGreaterThan(compressedApkSize);
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class VariantTotalSizeAggregatorTest method splitVariant_singleModule_multipleTargeting_withAllDeviceSpecsAndDimensions.
@Test
public void splitVariant_singleModule_multipleTargeting_withAllDeviceSpecsAndDimensions() {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkLanguageTargeting("fr"), ZipPath.create("base-fr.apk"), /* isMasterSplit= */
false), createApkDescription(apkLanguageTargeting("en-GB"), ZipPath.create("base-en-GB.apk"), /* isMasterSplit= */
false), createApkDescription(apkDensityTargeting(XHDPI, ImmutableSet.of(XXHDPI)), ZipPath.create("base-xhdpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkDensityTargeting(XXHDPI, ImmutableSet.of(XHDPI)), ZipPath.create("base-xxhdpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(MIPS, ImmutableSet.of(MIPS64)), ZipPath.create("base-mips.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(MIPS64, ImmutableSet.of(MIPS)), ZipPath.create("base-mips64.apk"), /* isMasterSplit= */
false)));
ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.<String, Long>builder().put("base-master.apk", 10L).put("base-fr.apk", 1L).put("base-en-GB.apk", 2L).put("base-xhdpi.apk", 6L).put("base-xxhdpi.apk", 3L).put("base-mips.apk", 4L).put("base-mips64.apk", 5L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setDimensions(ImmutableSet.of(SCREEN_DENSITY, SDK, LANGUAGE, ABI)).setDeviceSpec(mergeSpecs(locales("fr", "jp"), abis("x86", "mips"), density(XHDPI), sdkVersion(21))).build()).getSize();
assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21").setScreenDensity("320").setLocale("fr,jp").setAbi("x86,mips").build(), 21L);
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21").setScreenDensity("320").setLocale("fr,jp").setAbi("x86,mips").build(), 21L);
}
Aggregations