use of com.android.bundle.Commands.Variant in project bundletool by google.
the class GetSizeCommandTest method getSizeTotal_withAssetModulesAndMultipleVariants.
@Test
public void getSizeTotal_withAssetModulesAndMultipleVariants() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk"))));
Variant nVariant = createVariant(variantSdkTargeting(24), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master_2.apk"))));
AssetSliceSet assetModule = createAssetSliceSet(/* moduleName= */
"asset1", DeliveryType.INSTALL_TIME, createMasterApkDescription(apkSdkTargeting(sdkVersionFrom(21)), ZipPath.create("asset1-master.apk")), createApkDescription(mergeApkTargeting(apkTextureTargeting(ETC2, ImmutableSet.of(ASTC)), apkSdkTargeting(sdkVersionFrom(21))), ZipPath.create("asset1-tcf_etc2.apk"), /* isMasterSplit= */
false), createApkDescription(mergeApkTargeting(apkTextureTargeting(ASTC, ImmutableSet.of(ETC2)), apkSdkTargeting(sdkVersionFrom(21))), ZipPath.create("asset1-tcf_astc.apk"), /* isMasterSplit= */
false));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).addVariant(nVariant).addAssetSliceSet(assetModule).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDimensions(ImmutableSet.of(Dimension.TEXTURE_COMPRESSION_FORMAT, Dimension.ABI, Dimension.SDK)).build().getSizeTotal(new PrintStream(outputStream));
assertThat(new String(outputStream.toByteArray(), UTF_8).split(CRLF)).asList().containsExactly("SDK,ABI,TEXTURE_COMPRESSION_FORMAT,MIN,MAX", String.format("%s,,%s,%d,%d", "21-", "etc2", 3 * compressedApkSize, 3 * compressedApkSize), String.format("%s,,%s,%d,%d", "21-", "astc", 3 * compressedApkSize, 3 * compressedApkSize), String.format("%s,,%s,%d,%d", "24-", "etc2", 3 * compressedApkSize, 3 * compressedApkSize), String.format("%s,,%s,%d,%d", "24-", "astc", 3 * compressedApkSize, 3 * compressedApkSize));
}
use of com.android.bundle.Commands.Variant 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.bundle.Commands.Variant in project bundletool by google.
the class GetSizeCommandTest method getSizeTotal_multipleDimensions.
@Test
public void getSizeTotal_multipleDimensions() throws Exception {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkAbiTargeting(MIPS64, ImmutableSet.of(MIPS)), ZipPath.create("base-mips64.apk"), /* isMasterSplit= */
false), createApkDescription(apkAbiTargeting(MIPS, ImmutableSet.of(MIPS64)), ZipPath.create("base-mips.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"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDimensions(ImmutableSet.of(Dimension.SDK, Dimension.ABI, Dimension.LANGUAGE, Dimension.SCREEN_DENSITY)).build().getSizeTotal(new PrintStream(outputStream));
ImmutableList<String> csvRows = ImmutableList.copyOf(new String(outputStream.toByteArray(), UTF_8).split(CRLF));
assertThat(csvRows).containsExactly("SDK,ABI,SCREEN_DENSITY,LANGUAGE,MIN,MAX", String.format("21-,mips64,,,%d,%d", 2 * compressedApkSize, 2 * compressedApkSize), String.format("21-,mips,,,%d,%d", 2 * compressedApkSize, 2 * compressedApkSize));
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class ResultUtilsTest method isInstantApkVariantTrue.
@Test
public void isInstantApkVariantTrue() throws Exception {
Variant variant = createInstantVariant();
assertThat(ResultUtils.isInstantApkVariant(variant)).isTrue();
assertThat(ResultUtils.isSplitApkVariant(variant)).isFalse();
assertThat(ResultUtils.isStandaloneApkVariant(variant)).isFalse();
assertThat(ResultUtils.isSystemApkVariant(variant)).isFalse();
assertThat(ResultUtils.isArchivedApkVariant(variant)).isFalse();
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class ResultUtilsTest method filterSystemApkVariant.
@Test
public void filterSystemApkVariant() throws Exception {
Variant systemVariant = createSystemVariant();
BuildApksResult apksResult = BuildApksResult.newBuilder().addVariant(systemVariant).build();
assertThat(ResultUtils.systemApkVariants(apksResult)).containsExactly(systemVariant);
}
Aggregations