use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class VariantTotalSizeAggregatorTest method splitVariant_multipleModules_selectModules.
@Test
public void splitVariant_multipleModules_selectModules() {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk"))), createSplitApkSet(/* moduleName= */
"feature", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature-master.apk"))), createSplitApkSet(/* moduleName= */
"feature1", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature1-master.apk"))), createSplitApkSet(/* moduleName= */
"feature2", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature2-master.apk"))));
ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.<String, Long>builder().put("base-master.apk", 10L).put("feature-master.apk", 15L).put("feature1-master.apk", 6L).put("feature2-master.apk", 4L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setModules(ImmutableSet.of("base", "feature1")).build()).getSize();
// base, feature1, feature2 (install-time) modules are selected.
assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 20L);
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 20L);
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class GetSizeCommandTest method getSizeTotalInternal_multipleDimensions.
@Test
public void getSizeTotalInternal_multipleDimensions() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkDensityTargeting(LDPI, ImmutableSet.of(MDPI)), ZipPath.create("base-ldpi.apk"), /* isMasterSplit= */
false), createApkDescription(apkDensityTargeting(MDPI, ImmutableSet.of(LDPI)), ZipPath.create("base-mdpi.apk"), /* isMasterSplit= */
false)));
Variant preLVariant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(15), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(ARMEABI, ImmutableSet.of(X86))), ApkTargeting.getDefaultInstance(), ZipPath.create("preL.apk"));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).addVariant(preLVariant).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ConfigurationSizes configurationSizes = GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDimensions(ImmutableSet.of(Dimension.SDK, Dimension.ABI, Dimension.LANGUAGE, Dimension.SCREEN_DENSITY)).build().getSizeTotalInternal();
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("LDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("MDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("15-20").setAbi("armeabi").build(), compressedApkSize);
assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("LDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("MDPI").build(), 2 * compressedApkSize, SizeConfiguration.builder().setSdkVersion("15-20").setAbi("armeabi").build(), compressedApkSize);
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class GetSizeCommandTest method getSizeTotalInternal_singleSplitVariant.
@Test
public void getSizeTotalInternal_singleSplitVariant() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkAbiTargeting(X86, ImmutableSet.of(X86_64)), ZipPath.create("base-x86.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(X86_64, ImmutableSet.of(X86)), ZipPath.create("base-x86_64.apk"), /* isMasterSplit= */
false)));
ZipBuilder archiveBuilder = new ZipBuilder();
archiveBuilder.addFileWithContent(ZipPath.create("base-master.apk"), DUMMY_BYTES);
archiveBuilder.addFileWithContent(ZipPath.create("base-x86.apk"), DUMMY_BYTES, // APK stored uncompressed in the APKs zip.
EntryOption.UNCOMPRESSED);
archiveBuilder.addFileWithContent(ZipPath.create("base-x86_64.apk"), new byte[10000]);
archiveBuilder.addFileWithProtoContent(ZipPath.create("toc.pb"), BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).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())).isEqualTo(// base+x86
2 * compressedApkSize);
assertThat(configurationSizes.getMaxSizeConfigurationMap().keySet()).containsExactly(SizeConfiguration.getDefaultInstance());
assertThat(configurationSizes.getMaxSizeConfigurationMap().get(SizeConfiguration.getDefaultInstance())).isGreaterThan(// base+x86_64
2 * compressedApkSize);
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class GetSizeCommandTest method getSizeTotalInternal_withNoDimensionsAndDeviceSpec.
@Test
public void getSizeTotalInternal_withNoDimensionsAndDeviceSpec() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk"))));
Variant preLVariant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(X86, ImmutableSet.of(ARMEABI_V7A, ARM64_V8A))), ApkTargeting.getDefaultInstance(), ZipPath.create("preL.apk"));
ZipBuilder archiveBuilder = new ZipBuilder();
archiveBuilder.addFileWithContent(ZipPath.create("base-master.apk"), DUMMY_BYTES);
archiveBuilder.addFileWithContent(ZipPath.create("preL.apk"), new byte[10000]);
archiveBuilder.addFileWithProtoContent(ZipPath.create("toc.pb"), BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).addVariant(preLVariant).build());
Path apksArchiveFile = archiveBuilder.writeTo(tmpDir.resolve("bundle.apks"));
ConfigurationSizes configurationSizes = GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDeviceSpec(DeviceSpec.newBuilder().setSdkVersion(21).build()).build().getSizeTotalInternal();
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), // only split apk
compressedApkSize);
assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), // only split apk
compressedApkSize);
}
use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.
the class ConfigurationSizesMergerTest method merge_defaultConfiguration.
@Test
public void merge_defaultConfiguration() throws Exception {
ConfigurationSizes configurationSizes1 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.getDefaultInstance(), 10L), ImmutableMap.of(SizeConfiguration.getDefaultInstance(), 20L));
ConfigurationSizes configurationSizes2 = ConfigurationSizes.create(ImmutableMap.of(SizeConfiguration.getDefaultInstance(), 30L), ImmutableMap.of(SizeConfiguration.getDefaultInstance(), 40L));
ConfigurationSizes mergedConfigurationSizes = ConfigurationSizesMerger.merge(configurationSizes1, configurationSizes2);
assertThat(mergedConfigurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 40L);
assertThat(mergedConfigurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 60L);
}
Aggregations