use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class AssetSlicesGeneratorTest method onDemandAssetModule_addsVersionName.
@Test
public void onDemandAssetModule_addsVersionName() throws Exception {
AppBundle appBundle = createAppBundle(new BundleModuleBuilder("asset_module").setManifest(androidManifestForAssetModule(PACKAGE_NAME, withOnDemandDelivery())).build());
ImmutableList<ModuleSplit> assetSlices = new AssetSlicesGenerator(appBundle, ApkGenerationConfiguration.getDefaultInstance(), Optional.empty()).generateAssetSlices();
assertThat(assetSlices).hasSize(1);
ModuleSplit assetSlice = assetSlices.get(0);
assertThat(assetSlice.getAndroidManifest().getVersionName()).hasValue(VERSION_NAME);
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class BuildExtractApksTest method forLDeviceUniversalApk.
@Test
public void forLDeviceUniversalApk() throws Exception {
AppBundle appBundle = createAppBundle();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).setApkBuildMode(UNIVERSAL).build();
Path apkSetFilePath = command.execute();
ExtractApksCommand extractApksCommand = ExtractApksCommand.builder().setOutputDirectory(outputDir).setApksArchivePath(apkSetFilePath).setDeviceSpec(L_X86_64_ES_DEVICE).build();
ImmutableList<Path> extractedApks = extractApksCommand.execute();
assertThat(extractedApks.stream().map(Path::getFileName).map(Path::toString).collect(toImmutableList())).containsExactly("universal.apk");
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class BuildExtractApksTest method forPreLDeviceUniversalApk.
@Test
public void forPreLDeviceUniversalApk() throws Exception {
AppBundle appBundle = createAppBundle();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).setApkBuildMode(UNIVERSAL).build();
Path apkSetFilePath = command.execute();
ExtractApksCommand extractApksCommand = ExtractApksCommand.builder().setOutputDirectory(outputDir).setApksArchivePath(apkSetFilePath).setDeviceSpec(PRE_L_X86_ES_DEVICE).build();
ImmutableList<Path> extractedApks = extractApksCommand.execute();
assertThat(extractedApks.stream().map(Path::getFileName).map(Path::toString).collect(toImmutableList())).containsExactly("universal.apk");
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class BuildExtractApksTest method forLDevice.
@Test
public void forLDevice() throws Exception {
AppBundle appBundle = createAppBundle();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setAapt2Command(aapt2Command).build();
Path apkSetFilePath = command.execute();
ExtractApksCommand extractApksCommand = ExtractApksCommand.builder().setOutputDirectory(outputDir).setApksArchivePath(apkSetFilePath).setDeviceSpec(L_X86_64_ES_DEVICE).build();
ImmutableList<String> extractedApks = extractApksCommand.execute().stream().map(Path::getFileName).map(Path::toString).collect(toImmutableList());
assertThat(extractedApks).hasSize(4);
assertThat(extractedApks).containsAtLeast("base-xhdpi.apk", "base-es.apk");
assertThat(extractedApks).containsAnyOf("base-master.apk", "base-master_2.apk");
assertThat(extractedApks).containsAnyOf("base-x86_64.apk", "base-x86_64_2.apk");
}
use of com.android.tools.build.bundletool.model.AppBundle in project bundletool by google.
the class BundleModuleMergerTest method fuseApplicationElementsInManifest_1_8_0.
@Test
public void fuseApplicationElementsInManifest_1_8_0() throws Exception {
XmlNode installTimeModuleManifest = androidManifestForFeature("com.test.app.detail", withInstallTimeDelivery(), withSplitNameActivity("activity1", "detail"), withSplitNameService("service", "detail"));
createBasicZipBuilder(BUNDLE_CONFIG_1_8_0).addFileWithProtoContent(ZipPath.create("base/manifest/AndroidManifest.xml"), MANIFEST).addFileWithProtoContent(ZipPath.create("detail/manifest/AndroidManifest.xml"), installTimeModuleManifest).writeTo(bundleFile);
try (ZipFile appBundleZip = new ZipFile(bundleFile.toFile())) {
AppBundle appBundle = BundleModuleMerger.mergeNonRemovableInstallTimeModules(AppBundle.buildFromZip(appBundleZip), /* overrideBundleToolVersion = */
false);
XmlNode fusedManifest = androidManifest("com.test.app.detail", withSplitNameActivity("activity1", "detail"), withSplitNameService("service", "detail"), withMetadataValue("com.android.dynamic.apk.fused.modules", "base,detail"));
assertThat(appBundle.getBaseModule().getAndroidManifest().getManifestRoot().getProto()).isEqualTo(fusedManifest);
}
}
Aggregations