Search in sources :

Example 76 with Variant

use of com.android.bundle.Commands.Variant 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 77 with Variant

use of com.android.bundle.Commands.Variant 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 78 with Variant

use of com.android.bundle.Commands.Variant 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 79 with Variant

use of com.android.bundle.Commands.Variant 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 80 with Variant

use of com.android.bundle.Commands.Variant 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

Variant (com.android.bundle.Commands.Variant)134 Test (org.junit.Test)130 BuildApksResult (com.android.bundle.Commands.BuildApksResult)100 ZipPath (com.android.tools.build.bundletool.model.ZipPath)82 Path (java.nio.file.Path)80 ZipFile (java.util.zip.ZipFile)79 AppBundle (com.android.tools.build.bundletool.model.AppBundle)66 AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)66 ApkSet (com.android.bundle.Commands.ApkSet)63 ApkDescription (com.android.bundle.Commands.ApkDescription)60 ApkSetUtils.extractFromApkSetFile (com.android.tools.build.bundletool.testing.ApkSetUtils.extractFromApkSetFile)59 File (java.io.File)59 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)56 AssetSliceSet (com.android.bundle.Commands.AssetSliceSet)55 ApkSetUtils.extractTocFromApkSetFile (com.android.tools.build.bundletool.testing.ApkSetUtils.extractTocFromApkSetFile)55 CodeRelatedFile (com.android.bundle.CodeTransparencyOuterClass.CodeRelatedFile)54 ApkSetUtils.parseTocFromFile (com.android.tools.build.bundletool.testing.ApkSetUtils.parseTocFromFile)54 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)54 ImmutableSet (com.google.common.collect.ImmutableSet)54 ApkVerifier (com.android.apksig.ApkVerifier)53