use of com.android.tools.build.bundletool.model.ZipPath 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.tools.build.bundletool.model.ZipPath 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.tools.build.bundletool.model.ZipPath in project bundletool by google.
the class ExtractApksCommandTest method conditionalModule_deviceNotMatching.
@Test
public void conditionalModule_deviceNotMatching() throws Exception {
ZipPath apkBase = ZipPath.create("apkL-base.apk");
ZipPath apkConditional = ZipPath.create("apkN-conditional-module.apk");
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(sdkVersionFrom(1))), createSplitApkSet("base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkBase)), createConditionalApkSet("conditional", mergeModuleTargeting(moduleMinSdkVersionTargeting(24), moduleFeatureTargeting("android.hardware.camera.ar")), createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkConditional)))).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
DeviceSpec deviceSpec = mergeSpecs(deviceWithSdk(21));
ImmutableList<Path> matchedApks = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setOutputDirectory(tmpDir).build().execute();
assertThat(matchedApks).containsExactly(inOutputDirectory(apkBase));
for (Path matchedApk : matchedApks) {
checkFileExistsAndReadable(tmpDir.resolve(matchedApk));
}
}
use of com.android.tools.build.bundletool.model.ZipPath in project bundletool by google.
the class ExtractApksCommandTest method bundleWithDeviceTierTargeting_noDeviceTierSpecifiedNorDefault_usesZeroAsDefault.
@Test
public void bundleWithDeviceTierTargeting_noDeviceTierSpecifiedNorDefault_usesZeroAsDefault() throws Exception {
ZipPath baseMasterApk = ZipPath.create("base-master.apk");
ZipPath baseLowApk = ZipPath.create("base-tier_0.apk");
ZipPath baseHighApk = ZipPath.create("base-tier_1.apk");
BuildApksResult buildApksResult = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(SdkVersion.getDefaultInstance())), createSplitApkSet("base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), baseMasterApk), splitApkDescription(apkDeviceTierTargeting(deviceTierTargeting(/* value= */
0, /* alternatives= */
ImmutableList.of(1))), baseLowApk), splitApkDescription(apkDeviceTierTargeting(deviceTierTargeting(/* value= */
1, /* alternatives= */
ImmutableList.of(0))), baseHighApk)))).build();
Path apksArchiveFile = createApksArchiveFile(buildApksResult, tmpDir.resolve("bundle.apks"));
DeviceSpec deviceSpec = lDevice();
ImmutableList<Path> matchedApks = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setOutputDirectory(tmpDir).build().execute();
// Master and high tier splits for base and asset module.
assertThat(matchedApks).containsExactly(inOutputDirectory(baseMasterApk), inOutputDirectory(baseLowApk));
for (Path matchedApk : matchedApks) {
checkFileExistsAndReadable(tmpDir.resolve(matchedApk));
}
}
use of com.android.tools.build.bundletool.model.ZipPath in project bundletool by google.
the class ExtractApksCommandTest method moduleWithDependency_extractDependency.
@Test
public void moduleWithDependency_extractDependency() throws Exception {
ZipPath apkBase = ZipPath.create("base-master.apk");
ZipPath apkFeature1 = ZipPath.create("feature1-master.apk");
ZipPath apkFeature2 = ZipPath.create("feature2-master.apk");
ZipPath apkFeature3 = ZipPath.create("feature3-master.apk");
BuildApksResult tableOfContentsProto = BuildApksResult.newBuilder().setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).addVariant(createVariant(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(SdkVersion.getDefaultInstance())), createSplitApkSet(/* moduleName= */
"base", createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkBase)), createSplitApkSet(/* moduleName= */
"feature1", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkFeature1)), createSplitApkSet(/* moduleName= */
"feature2", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of("feature1"), createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkFeature2)), createSplitApkSet(/* moduleName= */
"feature3", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of("feature2"), createMasterApkDescription(ApkTargeting.getDefaultInstance(), apkFeature3)))).build();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
DeviceSpec deviceSpec = deviceWithSdk(21);
ImmutableList<Path> apks = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).setOutputDirectory(tmpDir).setModules(ImmutableSet.of("feature2")).build().execute();
assertThat(apks).containsExactly(inOutputDirectory(apkBase), inOutputDirectory(apkFeature1), inOutputDirectory(apkFeature2));
for (Path apk : apks) {
checkFileExistsAndReadable(tmpDir.resolve(apk));
}
}
Aggregations