Search in sources :

Example 16 with ConfigurationSizes

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

the class VariantTotalSizeAggregatorTest method splitVariant_singleModule_multipleTargeting_withDimensions.

@Test
public void splitVariant_singleModule_multipleTargeting_withDimensions() {
    Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
    "base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkAbiTargeting(ARMEABI, ImmutableSet.of(ARM64_V8A)), ZipPath.create("base-armeabi.apk"), /* isMasterSplit= */
    false), createApkDescription(apkAbiTargeting(ARM64_V8A, ImmutableSet.of(ARMEABI)), ZipPath.create("base-arm64_v8a.apk"), /* isMasterSplit= */
    false), createApkDescription(apkDensityTargeting(XHDPI, ImmutableSet.of(XXHDPI)), ZipPath.create("base-xhdpi.apk"), /* isMasterSplit= */
    false), createApkDescription(apkDensityTargeting(XXHDPI, ImmutableSet.of(XHDPI)), ZipPath.create("base-xxhdpi.apk"), /* isMasterSplit= */
    false), createApkDescription(apkLanguageTargeting("en"), ZipPath.create("base-en.apk"), /* isMasterSplit= */
    false)));
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.<String, Long>builder().put("base-master.apk", 10L).put("base-armeabi.apk", 4L).put("base-arm64_v8a.apk", 6L).put("base-xhdpi.apk", 2L).put("base-xxhdpi.apk", 3L).put("base-en.apk", 1L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setDimensions(ImmutableSet.of(ABI, SCREEN_DENSITY)).build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setAbi("armeabi").setScreenDensity("XHDPI").build(), 17L, SizeConfiguration.builder().setAbi("armeabi").setScreenDensity("XXHDPI").build(), 18L, SizeConfiguration.builder().setAbi("arm64-v8a").setScreenDensity("XHDPI").build(), 19L, SizeConfiguration.builder().setAbi("arm64-v8a").setScreenDensity("XXHDPI").build(), 20L);
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setAbi("armeabi").setScreenDensity("XHDPI").build(), 17L, SizeConfiguration.builder().setAbi("armeabi").setScreenDensity("XXHDPI").build(), 18L, SizeConfiguration.builder().setAbi("arm64-v8a").setScreenDensity("XHDPI").build(), 19L, SizeConfiguration.builder().setAbi("arm64-v8a").setScreenDensity("XXHDPI").build(), 20L);
}
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 17 with ConfigurationSizes

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

the class VariantTotalSizeAggregatorTest method splitVariant_multipleModules_multipleTargeting_withDeviceSpec.

@Test
public void splitVariant_multipleModules_multipleTargeting_withDeviceSpec() {
    Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
    "base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkAbiTargeting(MIPS, ImmutableSet.of(X86)), ZipPath.create("base-mips.apk"), /* isMasterSplit= */
    false), createApkDescription(apkAbiTargeting(X86, ImmutableSet.of(MIPS)), ZipPath.create("base-x86.apk"), /* isMasterSplit= */
    false), createApkDescription(apkLanguageTargeting("en"), ZipPath.create("base-en.apk"), /* isMasterSplit= */
    false), createApkDescription(apkLanguageTargeting("fr"), ZipPath.create("base-fr.apk"), /* isMasterSplit= */
    false)), createSplitApkSet(/* moduleName= */
    "feature", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature-master.apk")), createApkDescription(apkDensityTargeting(XHDPI, ImmutableSet.of(XXHDPI)), ZipPath.create("feature-xhdpi.apk"), /* isMasterSplit= */
    false), createApkDescription(apkDensityTargeting(XXHDPI, ImmutableSet.of(XHDPI)), ZipPath.create("feature-xxhdpi.apk"), /* isMasterSplit= */
    false)));
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.<String, Long>builder().put("base-master.apk", 10L).put("base-mips.apk", 3L).put("base-x86.apk", 4L).put("base-en.apk", 1L).put("base-fr.apk", 2L).put("feature-master.apk", 15L).put("feature-xhdpi.apk", 6L).put("feature-xxhdpi.apk", 5L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setDeviceSpec(mergeSpecs(density(XHDPI), abis("mips"))).build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), // 10+3+2+15+6
    36L);
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), // 10+3+1+15+6
    35L);
}
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 18 with ConfigurationSizes

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

the class VariantTotalSizeAggregatorTest method splitVariant_singleModule_multipleTargeting_withDifferentDimensionsAndDeviceSpec.

@Test
public void splitVariant_singleModule_multipleTargeting_withDifferentDimensionsAndDeviceSpec() {
    Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
    "base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createApkDescription(apkLanguageTargeting("jp"), ZipPath.create("base-jp.apk"), /* isMasterSplit= */
    false), createApkDescription(apkLanguageTargeting("en-US"), ZipPath.create("base-en-US.apk"), /* isMasterSplit= */
    false), createApkDescription(apkDensityTargeting(XHDPI, ImmutableSet.of(XXHDPI)), ZipPath.create("base-xhdpi.apk"), /* isMasterSplit= */
    false), createApkDescription(apkDensityTargeting(XXHDPI, ImmutableSet.of(XHDPI)), ZipPath.create("base-xxhdpi.apk"), /* isMasterSplit= */
    false), 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.<String, Long>builder().put("base-master.apk", 10L).put("base-jp.apk", 1L).put("base-en-US.apk", 2L).put("base-xhdpi.apk", 6L).put("base-xxhdpi.apk", 3L).put("base-x86.apk", 4L).put("base-x86_64.apk", 5L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setDimensions(ImmutableSet.of(SCREEN_DENSITY, SDK)).setDeviceSpec(mergeSpecs(locales("jp"), abis("x86"))).build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("XHDPI").build(), 21L, SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("XXHDPI").build(), 18L);
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("XHDPI").build(), 21L, SizeConfiguration.builder().setSdkVersion("21-").setScreenDensity("XXHDPI").build(), 18L);
}
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 19 with ConfigurationSizes

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

the class VariantTotalSizeAggregatorTest method getSize_standaloneVariant_withDeviceSpecAndWithoutDimensions.

@Test
public void getSize_standaloneVariant_withDeviceSpecAndWithoutDimensions() {
    ZipPath apk = ZipPath.create("sample.apk");
    Variant variant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(MIPS), variantDensityTargeting(LDPI, ImmutableSet.of(XXXHDPI))), ApkTargeting.getDefaultInstance(), apk);
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("sample.apk", 15L), BundleToolVersion.getCurrentVersion(), variant, getSizeCommand.setDeviceSpec(mergeSpecs(locales("jp"), abis("mips"))).build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).isEqualTo(configurationSizes.getMaxSizeConfigurationMap());
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 15L);
}
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 20 with ConfigurationSizes

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

the class VariantTotalSizeAggregatorTest method instantVariant_multipleModules_withInstantVariant.

@Test
public void instantVariant_multipleModules_withInstantVariant() {
    // Instant variants only have instant split APKs.
    Variant lVariant = createVariant(lPlusVariantTargeting(), createInstantApkSet(/* moduleName= */
    "base", ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk")), createInstantApkSet(/* moduleName= */
    "feature", ApkTargeting.getDefaultInstance(), ZipPath.create("feature-master.apk")), createInstantApkSet(/* moduleName= */
    "feature1", ApkTargeting.getDefaultInstance(), ZipPath.create("feature1-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).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setInstant(true).build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 31L);
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 31L);
}
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)

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