use of com.android.bundle.Commands.Variant in project bundletool by google.
the class VariantMatcherTest method getAllMatchingVariants_apexVariants_fullDeviceSpec.
@Test
public void getAllMatchingVariants_apexVariants_fullDeviceSpec() {
ZipPath x86Apk = ZipPath.create("standalone-x86.apk");
ZipPath x64X86Apk = ZipPath.create("standalone-x86_64.x86.apk");
ImmutableSet<ImmutableSet<AbiAlias>> x86Set = ImmutableSet.of(ImmutableSet.of(X86));
ImmutableSet<ImmutableSet<AbiAlias>> x64X86Set = ImmutableSet.of(ImmutableSet.of(X86_64, X86));
MultiAbiTargeting x86Targeting = multiAbiTargeting(x86Set, x64X86Set);
MultiAbiTargeting x64X86Targeting = multiAbiTargeting(x64X86Set, x86Set);
Variant x86Variant = multiAbiTargetingApexVariant(x86Targeting, x86Apk);
Variant x64X86Variant = multiAbiTargetingApexVariant(x64X86Targeting, x64X86Apk);
BuildApksResult buildApksResult = BuildApksResult.newBuilder().addAllVariant(ImmutableList.of(x86Variant, x64X86Variant)).build();
assertThat(new VariantMatcher(abis("x86")).getAllMatchingVariants(buildApksResult)).containsExactly(x86Variant);
assertThat(new VariantMatcher(abis("x86_64", "x86")).getAllMatchingVariants(buildApksResult)).containsExactly(x64X86Variant);
assertThat(new VariantMatcher(abis("x86_64", "x86", "armeabi-v7a")).getAllMatchingVariants(buildApksResult)).containsExactly(x64X86Variant);
// Other device specs don't affect the matching variant.
assertThat(new VariantMatcher(mergeSpecs(abis("x86"), density(HDPI))).getAllMatchingVariants(buildApksResult)).containsExactly(x86Variant);
}
use of com.android.bundle.Commands.Variant 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);
}
use of com.android.bundle.Commands.Variant 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);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class VariantTotalSizeAggregatorTest method splitVariant_multipleModules_selectModules.
@Test
public void splitVariant_multipleModules_selectModules() {
Variant lVariant = createVariant(lPlusVariantTargeting(), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("base-master.apk"))), createSplitApkSet(/* moduleName= */
"feature", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature-master.apk"))), createSplitApkSet(/* moduleName= */
"feature1", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature1-master.apk"))), createSplitApkSet(/* moduleName= */
"feature2", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("feature2-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).put("feature2-master.apk", 4L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setModules(ImmutableSet.of("base", "feature1")).build()).getSize();
// base, feature1, feature2 (install-time) modules are selected.
assertThat(configurationSizes.getMaxSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 20L);
assertThat(configurationSizes.getMinSizeConfigurationMap()).containsExactly(SizeConfiguration.getDefaultInstance(), 20L);
}
use of com.android.bundle.Commands.Variant in project bundletool by google.
the class VariantTotalSizeAggregatorTest method splitVariant_singleModule_multipleTargeting_withIncompatibleAbiDeviceSpecs.
@Test
public void splitVariant_singleModule_multipleTargeting_withIncompatibleAbiDeviceSpecs() {
Variant lVariant = createVariant(variantSdkTargeting(sdkVersionFrom(21)), createSplitApkSet("base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), ZipPath.create("apkL.apk")), createApkDescription(apkAbiTargeting(AbiAlias.X86, ImmutableSet.of()), ZipPath.create("apkL-x86.apk"), /* isMasterSplit= */
false)));
VariantTotalSizeAggregator variantTotalSizeAggregator = new VariantTotalSizeAggregator(ImmutableMap.<String, Long>builder().put("apkL.apk", 10L).put("apkL-x86.apk", 6L).build(), BundleToolVersion.getCurrentVersion(), lVariant, getSizeCommand.setDeviceSpec(mergeSpecs(abis("arm64-v8a"), locales("en"), density(XHDPI))).build());
Throwable exception = assertThrows(IncompatibleDeviceException.class, variantTotalSizeAggregator::getSize);
assertThat(exception).hasMessageThat().contains("The app doesn't support ABI architectures of the device. Device ABIs: [arm64-v8a], " + "app ABIs: [x86]");
}
Aggregations