Search in sources :

Example 1 with ConfigurationSizes

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

the class AssetModuleSizeAggregatorTest method getSize_singleAssetModule_noTargeting.

@Test
public void getSize_singleAssetModule_noTargeting() throws Exception {
    ImmutableList<AssetSliceSet> assetModules = ImmutableList.of(createAssetSliceSet("asset1", DeliveryType.INSTALL_TIME, createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("asset1-master.apk"))));
    VariantTargeting variantTargeting = VariantTargeting.getDefaultInstance();
    ImmutableMap<String, Long> sizeByApkPaths = ImmutableMap.of("asset1-master.apk", 10L);
    ConfigurationSizes configurationSizes = new AssetModuleSizeAggregator(assetModules, variantTargeting, sizeByApkPaths, getSizeCommand.build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 10L);
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 10L);
}
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 2 with ConfigurationSizes

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

the class AssetModuleSizeAggregatorTest method getSize_multipleAssetModules_withTargeting.

@Test
public void getSize_multipleAssetModules_withTargeting() throws Exception {
    ImmutableList<AssetSliceSet> assetModules = ImmutableList.of(ASSET_MODULE_1, ASSET_MODULE_2);
    VariantTargeting variantTargeting = variantSdkTargeting(21);
    ConfigurationSizes configurationSizes = new AssetModuleSizeAggregator(assetModules, variantTargeting, SIZE_BY_APK_PATHS, getSizeCommand.setDimensions(ImmutableSet.of(TEXTURE_COMPRESSION_FORMAT)).build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setTextureCompressionFormat("etc2").build(), ASSET_1_MASTER_SIZE + ASSET_1_ETC2_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ETC2_SIZE, SizeConfiguration.builder().setTextureCompressionFormat("astc").build(), ASSET_1_MASTER_SIZE + ASSET_1_ASTC_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ASTC_SIZE);
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setTextureCompressionFormat("etc2").build(), ASSET_1_MASTER_SIZE + ASSET_1_ETC2_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ETC2_SIZE, SizeConfiguration.builder().setTextureCompressionFormat("astc").build(), ASSET_1_MASTER_SIZE + ASSET_1_ASTC_SIZE + ASSET_2_MASTER_SIZE + ASSET_2_ASTC_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 3 with ConfigurationSizes

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

the class AssetModuleSizeAggregatorTest method getSize_noAssetModules.

@Test
public void getSize_noAssetModules() throws Exception {
    ConfigurationSizes configurationSizes = new AssetModuleSizeAggregator(ImmutableList.of(), VariantTargeting.getDefaultInstance(), ImmutableMap.of(), getSizeCommand.build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 0L);
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 0L);
}
Also used : ConfigurationSizes(com.android.tools.build.bundletool.model.ConfigurationSizes) Test(org.junit.Test)

Example 4 with ConfigurationSizes

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

the class VariantTotalSizeAggregatorTest method splitVariant_singleModule_SingleTargeting.

@Test
public void splitVariant_singleModule_SingleTargeting() {
    Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
    "base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk"))));
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("base-master.apk", 10L), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.build()).getSize();
    assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 10L);
    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) Test(org.junit.Test)

Example 5 with ConfigurationSizes

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

the class VariantTotalSizeAggregatorTest method getSize_standaloneVariants_withAllDeviceSpecAndDimensions.

@Test
public void getSize_standaloneVariants_withAllDeviceSpecAndDimensions() {
    ZipPath apk = ZipPath.create("sample.apk");
    Variant variant = standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(15), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(ARM64_V8A, ImmutableSet.of(X86)), variantDensityTargeting(MDPI, ImmutableSet.of(XXHDPI, XXXHDPI))), ApkTargeting.getDefaultInstance(), apk);
    ConfigurationSizes configurationSizes = new VariantTotalSizeAggregator(ImmutableMap.of("sample.apk", 11L), BundleToolVersion.getCurrentVersion(), variant, getSizeCommand.setDimensions(ImmutableSet.of(ABI, SCREEN_DENSITY, LANGUAGE, SDK)).setDeviceSpec(mergeSpecs(locales("fr", "jp"), abis("arm64-v8a", "mips"), density(MDPI), sdkVersion(15))).build()).getSize();
    assertThat(configurationSizes.getMinSizeConfigurationMap()).isEqualTo(configurationSizes.getMaxSizeConfigurationMap());
    assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.builder().setSdkVersion("15").setScreenDensity("160").setLocale("fr,jp").setAbi("arm64-v8a,mips").build(), 11L);
}
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