@Test public void deviceSpec_instantSplitsGenerated() throws Exception { DeviceSpec deviceSpec = lDeviceWithDensity(XHDPI); bundleSerializer.writeToDisk(createInstantBundle(), bundlePath); BuildApksCommand command = BuildApksCommand.builder() .setBundlePath(bundlePath) .setOutputFile(outputFilePath) .setDeviceSpec(deviceSpec) .build(); Path apksArchive = command.execute(); ZipFile apksZipFile = new ZipFile(apksArchive.toFile()); assertThat(apksZipFile) .containsExactlyEntries( "toc.pb", "splits/base-master.apk", "instant/instant-base-master.apk"); BuildApksResult result = extractTocFromApkSetFile(apksZipFile, outputDir); assertThat(instantApkVariants(result)).hasSize(1); assertThat(splitApkVariants(result)).hasSize(1); Variant variant = splitApkVariants(result).get(0); assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0); assertThat(apkSet.getApkDescriptionList()).hasSize(1); assertThat(apkNamesInSet(apkSet)).containsExactly("splits/base-master.apk"); variant = instantApkVariants(result).get(0); assertThat(variant.getApkSetList()).hasSize(1); apkSet = variant.getApkSet(0); assertThat(apkSet.getApkDescriptionList()).hasSize(1); assertThat(apkNamesInSet(apkSet)).containsExactly("instant/instant-base-master.apk"); }
Variant variant = result.getVariant(0); assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0);
@Test public void deviceSpec_correctSplitsGenerated() throws Exception { DeviceSpec deviceSpec = lDeviceWithDensity(XHDPI); bundleSerializer.writeToDisk(createLdpiHdpiAppBundle(), bundlePath); BuildApksCommand command = BuildApksCommand.builder() .setBundlePath(bundlePath) .setOutputFile(outputFilePath) .setDeviceSpec(deviceSpec) .build(); Path apksArchive = command.execute(); ZipFile apksZipFile = new ZipFile(apksArchive.toFile()); assertThat(apksZipFile) .containsExactlyEntries("toc.pb", "splits/base-master.apk", "splits/base-xhdpi.apk"); BuildApksResult result = extractTocFromApkSetFile(apksZipFile, outputDir); assertThat(result.getVariantList()).hasSize(1); Variant variant = result.getVariant(0); assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0); // One master and one density split. assertThat(apkSet.getApkDescriptionList()).hasSize(2); assertThat(apkNamesInSet(apkSet)) .containsExactly("splits/base-master.apk", "splits/base-xhdpi.apk"); }
for (Variant variant : systemVariantsByAbi.values()) { assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0); apkSet .getApkDescriptionList()
for (Variant variant : standaloneVariantsByAbi.values()) { assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0); assertThat(apkSet.getApkDescriptionList()).hasSize(1); assertThat(apkSetFile).hasFile(apkSet.getApkDescription(0).getPath());
variantSdkTargeting(LOWEST_SDK_VERSION))); assertThat(x86Variant.getApkSetList()).hasSize(1); ApkSet apkSet = x86Variant.getApkSet(0); if (systemApkBuildMode.equals(SYSTEM)) {
Variant standaloneApkVariant = standaloneApkVariants(result).get(0); assertThat(standaloneApkVariant.getApkSetList()).hasSize(1); ApkSet shards = standaloneApkVariant.getApkSet(0); assertThat(shards.getModuleMetadata().getName()).isEqualTo("base"); assertThat(shards.getApkDescriptionList()).hasSize(1);
Variant variant = result.getVariant(0); assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0);
Variant variant = result.getVariant(0); assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0);
Variant variant = result.getVariant(0); assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0);
@Test public void buildApksCommand_standalone_oneModuleOneVariant() throws Exception { bundlePath = FileUtils.getRandomFilePath(tmp, "bundle-", ".aab"); AppBundle appBundle = new AppBundleBuilder() .addModule( "base", builder -> builder.addFile("dex/classes.dex").setManifest(androidManifest("com.test.app"))) .build(); bundleSerializer.writeToDisk(appBundle, bundlePath); BuildApksCommand command = BuildApksCommand.builder() .setBundlePath(bundlePath) .setOutputFile(outputFilePath) .setAapt2Command(aapt2Command) .build(); Path apkSetFilePath = execute(command); ZipFile apkSetFile = new ZipFile(apkSetFilePath.toFile()); BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir); assertThat(standaloneApkVariants(result)).hasSize(1); Variant standaloneApkVariant = standaloneApkVariants(result).get(0); assertThat(standaloneApkVariant.getApkSetList()).hasSize(1); ApkSet shards = standaloneApkVariant.getApkSet(0); assertThat(shards.getModuleMetadata().getName()).isEqualTo("base"); assertThat(shards.getApkDescriptionList()).hasSize(1); assertThat(ZipPath.create(shards.getApkDescription(0).getPath()).getFileName()) .isEqualTo(ZipPath.create("standalone.apk")); assertThat(apkSetFile).hasFile(shards.getApkDescription(0).getPath()); }
@Test public void deviceSpec_correctStandaloneGenerated() throws Exception { DeviceSpec deviceSpec = mergeSpecs(sdkVersion(19), abis("x86"), locales("en-US"), density(HDPI)); bundleSerializer.writeToDisk(createLdpiHdpiAppBundle(), bundlePath); BuildApksCommand command = BuildApksCommand.builder() .setBundlePath(bundlePath) .setOutputFile(outputFilePath) .setDeviceSpec(deviceSpec) .build(); Path apksArchive = command.execute(); ZipFile apksZipFile = new ZipFile(apksArchive.toFile()); assertThat(apksZipFile).containsExactlyEntries("toc.pb", "standalones/standalone-hdpi.apk"); BuildApksResult result = extractTocFromApkSetFile(apksZipFile, outputDir); assertThat(result.getVariantList()).hasSize(1); Variant variant = result.getVariant(0); assertThat(variant.getApkSetList()).hasSize(1); ApkSet apkSet = variant.getApkSet(0); // One standalone APK. assertThat(apkSet.getApkDescriptionList()).hasSize(1); assertThat(apkNamesInSet(apkSet)).containsExactly("standalones/standalone-hdpi.apk"); }