use of com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.UNIVERSAL in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_universalApk_variantUsesMinSdkFromManifest.
@Test
public void buildApksCommand_universalApk_variantUsesMinSdkFromManifest() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("assets/a.txt").setManifest(androidManifest("com.test.app", withMinSdkVersion(23))).setResourceTable(resourceTableWithTestLabel("Test feature"))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withApkBuildMode(UNIVERSAL).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
// Should not shard by any dimension and generate single APK with default targeting.
assertThat(result.getVariantList()).hasSize(1);
assertThat(splitApkVariants(result)).isEmpty();
assertThat(standaloneApkVariants(result)).hasSize(1);
Variant universalVariant = standaloneApkVariants(result).get(0);
assertThat(universalVariant.getTargeting()).isEqualTo(variantSdkTargeting(/* minSdkVersion= */
23));
}
use of com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.UNIVERSAL in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_universal_generatesSingleApkWithAllTcfAssets.
@Test
public void buildApksCommand_universal_generatesSingleApkWithAllTcfAssets() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.test.app"))).addModule("tcf_assets", builder -> builder.addFile("assets/textures#tcf_atc/texture.dat").addFile("assets/textures#tcf_etc1/texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures#tcf_atc", assetsDirectoryTargeting(textureCompressionTargeting(ATC))), targetedAssetsDirectory("assets/textures#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(ETC1_RGB8))))).setManifest(androidManifestForAssetModule("com.test.app", withInstallTimeDelivery()))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withApkBuildMode(UNIVERSAL).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
assertThat(standaloneApkVariants(result)).hasSize(1);
Variant universalVariant = standaloneApkVariants(result).get(0);
assertThat(apkDescriptions(universalVariant)).hasSize(1);
ApkDescription universalApk = apkDescriptions(universalVariant).get(0);
// Check APK content
File universalApkFile = extractFromApkSetFile(apkSetFile, universalApk.getPath(), outputDir);
try (ZipFile universalApkZipFile = new ZipFile(universalApkFile)) {
// Even if we used targeted folders, they are all included because we did not activate
// texture targeting optimization.
assertThat(filesUnderPath(universalApkZipFile, ASSETS_DIRECTORY)).containsExactly("assets/textures#tcf_atc/texture.dat", "assets/textures#tcf_etc1/texture.dat");
}
}
Aggregations