use of com.android.bundle.Commands.AssetModulesInfo in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_assetOnly.
@Test
@Theory
public void buildApksCommand_assetOnly(@FromDataPoints("bundleVersion") Version bundleVersion) throws Exception {
AssetModulesConfig assetModulesConfig = AssetModulesConfig.newBuilder().setAssetVersionTag("qwe").addAppVersion(11).build();
AssetModulesInfo assetModulesInfo = AssetModulesInfo.newBuilder().setAssetVersionTag("qwe").addAppVersion(11).build();
AppBundle appBundle = new AppBundleBuilder().addModule("asset_module1", builder -> builder.setManifest(androidManifestForAssetModule("com.test.app", withOnDemandDelivery())).addFile("assets/images/image.jpg")).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withBundleConfig(BundleConfig.newBuilder().setAssetModulesConfig(assetModulesConfig).setType(BundleType.ASSET_ONLY)).withBundletoolVersion(bundleVersion.toString()).withOutputPath(outputFilePath).withCustomBuildApksCommandSetter(command -> command.setAssetModulesVersionOverride(123L)).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
// Variants
assertThat(splitApkVariants(result)).isEmpty();
// Asset Slices
List<AssetSliceSet> sliceSets = result.getAssetSliceSetList();
assertThat(sliceSets).hasSize(1);
AssetSliceSet assetSliceSet = sliceSets.get(0);
assertThat(assetSliceSet.getAssetModuleMetadata().hasInstantMetadata()).isTrue();
assertThat(assetSliceSet.getApkDescriptionList()).hasSize(1);
assertThat(apkSetFile).hasFile(assetSliceSet.getApkDescription(0).getPath());
ApkDescription apkDescription = assetSliceSet.getApkDescription(0);
assertThat(apkDescription.getPath()).isEqualTo(String.format("asset-slices/%s-master.apk", assetSliceSet.getAssetModuleMetadata().getName()));
assertThat(apkDescription.hasAssetSliceMetadata()).isTrue();
assertThat(apkDescription.getAssetSliceMetadata().getIsMasterSplit()).isTrue();
assertThat(result.getAssetModulesInfo()).isEqualTo(assetModulesInfo);
}
Aggregations