use of com.android.bundle.Commands.AssetSliceSet 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.Commands.AssetSliceSet 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.Commands.AssetSliceSet in project bundletool by google.
the class GetSizeCommandTest method getSizeTotal_withAssetModulesAndDeviceSpec.
@Test
public void getSizeTotal_withAssetModulesAndDeviceSpec() 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)));
AssetSliceSet assetModule = createAssetSliceSet(/* moduleName= */
"asset1", DeliveryType.INSTALL_TIME, createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("asset1-master.apk")), createApkDescription(apkTextureTargeting(ETC2, ImmutableSet.of(ASTC)), ZipPath.create("asset1-tcf_etc2.apk"), /* isMasterSplit= */
false), createApkDescription(apkTextureTargeting(ASTC, ImmutableSet.of(ETC2)), ZipPath.create("asset1-tcf_astc.apk"), /* isMasterSplit= */
false));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).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.ABI, Dimension.TEXTURE_COMPRESSION_FORMAT, Dimension.SDK)).setDeviceSpec(DeviceSpec.newBuilder().setSdkVersion(25).addSupportedAbis("x86").addGlExtensions("GL_KHR_texture_compression_astc_ldr").build()).build().getSizeTotal(new PrintStream(outputStream));
assertThat(new String(outputStream.toByteArray(), UTF_8)).isEqualTo("SDK,ABI,TEXTURE_COMPRESSION_FORMAT,MIN,MAX" + CRLF + String.format("%s,%s,%s,%d,%d", "25", "x86", "astc", 4 * compressedApkSize, 4 * compressedApkSize) + CRLF);
}
use of com.android.bundle.Commands.AssetSliceSet 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.AssetSliceSet in project bundletool by google.
the class GetSizeCommandTest method getSizeTotal_withAssetModules.
@Test
public void getSizeTotal_withAssetModules() 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)));
AssetSliceSet assetModule = createAssetSliceSet(/* moduleName= */
"asset1", DeliveryType.INSTALL_TIME, createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("asset1-master.apk")), createApkDescription(apkTextureTargeting(ETC2, ImmutableSet.of(ASTC)), ZipPath.create("asset1-tcf_etc2.apk"), /* isMasterSplit= */
false), createApkDescription(apkTextureTargeting(ASTC, ImmutableSet.of(ETC2)), ZipPath.create("asset1-tcf_astc.apk"), /* isMasterSplit= */
false));
// Only install-time asset modules are counted towards the size.
AssetSliceSet ignoredOnDemandAssetModule = createAssetSliceSet(/* moduleName= */
"asset2", DeliveryType.ON_DEMAND, createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("asset2-master.apk")));
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(lVariant).addAssetSliceSet(assetModule).addAssetSliceSet(ignoredOnDemandAssetModule).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GetSizeCommand.builder().setGetSizeSubCommand(GetSizeSubcommand.TOTAL).setApksArchivePath(apksArchiveFile).setDimensions(ImmutableSet.of(Dimension.ABI, Dimension.TEXTURE_COMPRESSION_FORMAT, 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,%s,%d,%d", "21-", "x86_64", "astc", 4 * compressedApkSize, 4 * compressedApkSize), String.format("%s,%s,%s,%d,%d", "21-", "x86_64", "etc2", 4 * compressedApkSize, 4 * compressedApkSize), String.format("%s,%s,%s,%d,%d", "21-", "x86", "astc", 4 * compressedApkSize, 4 * compressedApkSize), String.format("%s,%s,%s,%d,%d", "21-", "x86", "etc2", 4 * compressedApkSize, 4 * compressedApkSize));
}
Aggregations