use of com.android.bundle.Commands.Variant in project bundletool by google.
the class ResultUtilsTest method filterStandaloneApkVariant.
@Test
public void filterStandaloneApkVariant() throws Exception {
Variant standaloneVariant = createStandaloneVariant();
Variant splitVariant = createSplitVariant();
Variant instantVariant = createInstantVariant();
BuildApksResult apksResult = BuildApksResult.newBuilder().addVariant(standaloneVariant).addVariant(splitVariant).addVariant(instantVariant).build();
assertThat(ResultUtils.standaloneApkVariants(apksResult)).containsExactly(standaloneVariant);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class ResultUtilsTest method isSplitApkVariantTrue.
@Test
public void isSplitApkVariantTrue() throws Exception {
Variant variant = createSplitVariant();
assertThat(ResultUtils.isSplitApkVariant(variant)).isTrue();
assertThat(ResultUtils.isStandaloneApkVariant(variant)).isFalse();
assertThat(ResultUtils.isInstantApkVariant(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 isStandaloneApkVariantTrue.
@Test
public void isStandaloneApkVariantTrue() throws Exception {
Variant variant = createStandaloneVariant();
assertThat(ResultUtils.isStandaloneApkVariant(variant)).isTrue();
assertThat(ResultUtils.isSplitApkVariant(variant)).isFalse();
assertThat(ResultUtils.isInstantApkVariant(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 GetSizeCommand method getSizeTotalInternal.
@VisibleForTesting
ConfigurationSizes getSizeTotalInternal() {
BuildApksResult buildApksResult = ResultUtils.readTableOfContents(getApksArchivePath());
ImmutableList<Variant> variants = new VariantMatcher(getDeviceSpec(), getInstant()).getAllMatchingVariants(buildApksResult);
ImmutableMap<String, Long> variantCompressedSizeByApkPaths = getVariantCompressedSizeByApkPaths(variants, getApksArchivePath());
ImmutableList<String> assetModuleApks = buildApksResult.getAssetSliceSetList().stream().flatMap(module -> module.getApkDescriptionList().stream()).map(ApkDescription::getPath).collect(toImmutableList());
ImmutableMap<String, Long> assetModuleCompressedSizeByApkPaths = getCompressedSizeByApkPaths(assetModuleApks, getApksArchivePath());
ImmutableMap<SizeConfiguration, Long> minSizeConfigurationMap = ImmutableMap.of();
ImmutableMap<SizeConfiguration, Long> maxSizeConfigurationMap = ImmutableMap.of();
for (Variant variant : variants) {
ConfigurationSizes variantConfigurationSizes = new VariantTotalSizeAggregator(variantCompressedSizeByApkPaths, Version.of(buildApksResult.getBundletool().getVersion()), variant, this).getSize();
ConfigurationSizes assetModuleConfigurationSizes = new AssetModuleSizeAggregator(buildApksResult.getAssetSliceSetList(), variant.getTargeting(), assetModuleCompressedSizeByApkPaths, this).getSize();
ConfigurationSizes configurationSizes = ConfigurationSizesMerger.merge(variantConfigurationSizes, assetModuleConfigurationSizes);
minSizeConfigurationMap = combineMaps(minSizeConfigurationMap, configurationSizes.getMinSizeConfigurationMap(), Math::min);
maxSizeConfigurationMap = combineMaps(maxSizeConfigurationMap, configurationSizes.getMaxSizeConfigurationMap(), Math::max);
}
return ConfigurationSizes.create(minSizeConfigurationMap, maxSizeConfigurationMap);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class BuildApksManagerTest method splitNames_assetLanguages.
@Test
public void splitNames_assetLanguages() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("dex/classes.dex").addFile("assets/paks#lang_es/es.pak").addFile("assets/paks/en.pak").setManifest(androidManifest("com.test.app")).setAssetsConfig(assets(targetedAssetsDirectory("assets/paks#lang_es", assetsDirectoryTargeting(languageTargeting("es"))), targetedAssetsDirectory("assets/paks", assetsDirectoryTargeting(alternativeLanguageTargeting("es")))))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
assertThat(splitApkVariants(result)).hasSize(1);
Variant splitApkVariant = splitApkVariants(result).get(0);
assertThat(splitApkVariant.getApkSetList()).hasSize(1);
assertThat(apkNamesInVariant(splitApkVariant)).containsExactly("base-master.apk", "base-es.apk", "base-other_lang.apk");
}
Aggregations