Search in sources :

Example 21 with ConfigurationSizes

use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.

the class AssetModuleSizeAggregatorTest method getSize_multipleAssetModules_withDeviceSpecAndVariantTargeting.

@Test
public void getSize_multipleAssetModules_withDeviceSpecAndVariantTargeting() throws Exception {
    ImmutableList<AssetSliceSet> assetModules = ImmutableList.of(ASSET_MODULE_1, ASSET_MODULE_2);
    VariantTargeting variantTargeting = variantTextureTargeting(ETC2);
    ConfigurationSizes configurationSizes = new AssetModuleSizeAggregator(assetModules, variantTargeting, SIZE_BY_APK_PATHS, getSizeCommand.setDimensions(ImmutableSet.of(TEXTURE_COMPRESSION_FORMAT, SDK)).setDeviceSpec(sdkVersion(21)).build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setTextureCompressionFormat("etc2").setSdkVersion("21").build(), ASSET_1_MASTER_SIZE + ASSET_1_ETC2_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ETC2_SIZE);
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setTextureCompressionFormat("etc2").setSdkVersion("21").build(), ASSET_1_MASTER_SIZE + ASSET_1_ETC2_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ETC2_SIZE);
}
Also used : ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) ApksArchiveHelpers.createAssetSliceSet(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createAssetSliceSet) AssetSliceSet(com.android.bundle.Commands.AssetSliceSet) Test(org.junit.Test)

Example 22 with ConfigurationSizes

use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.

the class VariantTotalSizeAggregatorTest method splitVariant_singleModule_multipleTargeting_withDimensionsAndDeviceSpec.

@Test
public void splitVariant_singleModule_multipleTargeting_withDimensionsAndDeviceSpec() {
    Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
    "base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkLanguageTargeting("en"), ZipPath.create("base-en.apk"), /* isMasterSplit= */
    false), createApkDescription(apkLanguageTargeting("fr"), ZipPath.create("base-fr.apk"), /* isMasterSplit= */
    false), 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)));
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.<String, Long>builder().put("base-master.apk", 10L).put("base-en.apk", 1L).put("base-fr.apk", 2L).put("base-mdpi.apk", 6L).put("base-ldpi.apk", 3L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setDimensions(ImmutableSet.of(LANGUAGE)).setDeviceSpec(mergeSpecs(locales("en"))).build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setLocale("en").build(), 17L);
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setLocale("en").build(), 14L);
}
Also used : Variant(com.android.bundle.Commands.Variant) ApksArchiveHelpers.standaloneVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.standaloneVariant) ApksArchiveHelpers.createVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createVariant) ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) Test(org.junit.Test)

Example 23 with ConfigurationSizes

use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.

the class VariantTotalSizeAggregatorTest method getSize_standaloneVariant_withoutDimensionsAndDeviceSpec.

@Test
public void getSize_standaloneVariant_withoutDimensionsAndDeviceSpec() {
    ZipPath apk = ZipPath.create("sample.apk");
    Variant variant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(X86, ImmutableSet.of(ARMEABI_V7A, ARM64_V8A))), ApkTargeting.getDefaultInstance(), apk);
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("sample.apk", 10L), BundleToolVersion.getCurrentVersion(), variant, getSizeCommand.build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).isEqualTo(configurationSizes.getMaxSizeConfigurationMap());
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 10L);
}
Also used : Variant(com.android.bundle.Commands.Variant) ApksArchiveHelpers.standaloneVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.standaloneVariant) ApksArchiveHelpers.createVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createVariant) ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 24 with ConfigurationSizes

use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.

the class VariantTotalSizeAggregatorTest method splitVariant_singleModule_multipleTargeting.

@Test
public void splitVariant_singleModule_multipleTargeting() {
    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)));
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("base-master.apk", 10L, "base-x86.apk", 4L, "base-x86_64.apk", 6L), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 16L);
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 14L);
}
Also used : Variant(com.android.bundle.Commands.Variant) ApksArchiveHelpers.standaloneVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.standaloneVariant) ApksArchiveHelpers.createVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createVariant) ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) Test(org.junit.Test)

Example 25 with ConfigurationSizes

use of com.android.tools.build.bundletool.model.ConfigurationSizes in project bundletool by google.

the class VariantTotalSizeAggregatorTest method getSize_standaloneVariant_withModules.

@Test
public void getSize_standaloneVariant_withModules() {
    ZipPath apk = ZipPath.create("sample.apk");
    Variant variant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21)))), ApkTargeting.getDefaultInstance(), apk);
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("sample.apk", 10L), BundleToolVersion.getCurrentVersion(), variant, getSizeCommand.setModules(ImmutableSet.of("base")).build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).isEmpty();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).isEmpty();
}
Also used : Variant(com.android.bundle.Commands.Variant) ApksArchiveHelpers.standaloneVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.standaloneVariant) ApksArchiveHelpers.createVariant(com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createVariant) ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Aggregations

ConfigurationSizes (com.android.tools.build.bundletool.model.ConfigurationSizes)28 Test (org.junit.Test)27 Variant (com.android.bundle.Commands.Variant)20 ApksArchiveHelpers.createVariant (com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createVariant)19 ApksArchiveHelpers.standaloneVariant (com.android.tools.build.bundletool.testing.ApksArchiveHelpers.standaloneVariant)19 ZipPath (com.android.tools.build.bundletool.model.ZipPath)10 Path (java.nio.file.Path)5 AssetSliceSet (com.android.bundle.Commands.AssetSliceSet)3 BuildApksResult (com.android.bundle.Commands.BuildApksResult)3 VariantTargeting (com.android.bundle.Targeting.VariantTargeting)3 ZipBuilder (com.android.tools.build.bundletool.io.ZipBuilder)3 ApksArchiveHelpers.createAssetSliceSet (com.android.tools.build.bundletool.testing.ApksArchiveHelpers.createAssetSliceSet)3 AssetModuleSizeAggregator (com.android.tools.build.bundletool.device.AssetModuleSizeAggregator)1 VariantMatcher (com.android.tools.build.bundletool.device.VariantMatcher)1 VariantTotalSizeAggregator (com.android.tools.build.bundletool.device.VariantTotalSizeAggregator)1 SizeConfiguration (com.android.tools.build.bundletool.model.SizeConfiguration)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1