use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildSdkApksManagerTest method sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded.
@Test
public void sdkManifestMutation_patchVersionNotSet_defaultPatchVersionAdded() throws Exception {
SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withSdkLibraryElement("20"))).build()).build();
execute(sdkBundle);
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
Variant variant = result.getVariant(0);
ApkDescription apkDescription = variant.getApkSet(0).getApkDescription(0);
File apkFile = extractFromApkSetFile(apkSetFile, apkDescription.getPath(), tmpDir);
AndroidManifest manifest = extractAndroidManifest(apkFile, tmpDir);
assertThat(manifest.getMetadataValue(SDK_PATCH_VERSION_ATTRIBUTE_NAME)).hasValue(DEFAULT_SDK_PATCH_VERSION);
}
use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildSdkApksManagerTest method tocIsCorrect.
@Test
public void tocIsCorrect() throws Exception {
execute(new SdkBundleBuilder().build());
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
assertThat(result.getVariantCount()).isEqualTo(1);
assertThat(result.getPackageName()).isEqualTo(PACKAGE_NAME);
assertThat(result.getBundletool().getVersion()).isEqualTo(DEFAULT_BUNDLE_CONFIG.getBundletool().getVersion());
}
use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildApksCommandTest method sdkBundleHasInvalidManifestEntry_sdkBundleValidationFails.
@Test
public void sdkBundleHasInvalidManifestEntry_sdkBundleValidationFails() throws Exception {
new SdkBundleSerializer().writeToDisk(new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest("package.name", withMinSdkVersion(32), // Major version must be a long.
withSdkLibraryElement("MajorVersionNotLong"))).build()).build(), sdkBundlePath1);
createAppBundle(bundlePath);
BuildApksCommand command = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--sdk-bundles=" + sdkBundlePath1), fakeAdbServer);
Exception e = assertThrows(InvalidBundleException.class, command::execute);
assertThat(e).hasMessageThat().contains("SDK Major version in <" + SDK_LIBRARY_ELEMENT_NAME + "> cannot be parsed to a Long.");
}
Aggregations