Search in sources :

Example 81 with Variant

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

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

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

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

Example 85 with Variant

use of com.android.bundle.Commands.Variant in project bundletool by google.

the class VariantTotalSizeAggregatorTest method getSize_standaloneVariant_withDimensionsAndWithoutDeviceSpec.

@Test
public void getSize_standaloneVariant_withDimensionsAndWithoutDeviceSpec() {
    ZipPath apk = ZipPath.create("sample.apk");
    Variant variant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(ARMEABI_V7A, ImmutableSet.of(X86, ARM64_V8A)), variantDensityTargeting(XHDPI, ImmutableSet.of(MDPI, LDPI))), ApkTargeting.getDefaultInstance(), apk);
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("sample.apk", 20L), BundleToolVersion.getCurrentVersion(), variant, getSizeCommand.setDimensions(ImmutableSet.of(ABI, SCREEN_DENSITY, LANGUAGE, SDK)).build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).isEqualTo(configurationSizes.getMaxSizeConfigurationMap());
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setAbi("armeabi-v7a").setScreenDensity("XHDPI").setSdkVersion("1-20").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) ZipPath(com.android.tools.build.bundletool.model.ZipPath) 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