use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildSdkApksManagerTest method manifestIsMutated.
@Test
public void manifestIsMutated() throws Exception {
Integer versionCode = 1253;
execute(new SdkBundleBuilder().setVersionCode(versionCode).build());
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.getMinSdkVersion()).hasValue(SDK_SANDBOX_MIN_VERSION);
assertThat(manifest.getManifestRoot().getElement().getAndroidAttribute(VERSION_NAME_RESOURCE_ID).get().getValueAsString()).isEqualTo("15.0.5");
assertThat(manifest.getManifestRoot().getElement().getAndroidAttribute(VERSION_CODE_RESOURCE_ID).get().getValueAsDecimalInteger()).isEqualTo(versionCode);
}
use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildSdkApksManagerTest method sdkVersionInformationIsSet.
@Test
public void sdkVersionInformationIsSet() throws Exception {
SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withSdkLibraryElement("100"), withMetadataValue(SDK_PATCH_VERSION_ATTRIBUTE_NAME, "132"))).build()).setVersionCode(99).build();
execute(sdkBundle);
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
SdkVersionInformation version = result.getVersion();
assertThat(version.getVersionCode()).isEqualTo(99);
assertThat(version.getMajor()).isEqualTo(100);
assertThat(version.getPatch()).isEqualTo(132);
}
use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildSdkApksManagerTest method apksSigned.
@Test
public void apksSigned() throws Exception {
execute(new SdkBundleBuilder().build());
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);
ApkVerifier.Result verifierResult = new ApkVerifier.Builder(apkFile).build().verify();
assertThat(verifierResult.isVerified()).isTrue();
assertThat(verifierResult.getSignerCertificates()).containsExactly(certificate);
}
use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildSdkApksManagerTest method sdkManifestMutation_highMinSdkVersion_minSdkVersionUnchanged.
@Test
public void sdkManifestMutation_highMinSdkVersion_minSdkVersionUnchanged() throws Exception {
SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withMinSdkVersion(SDK_SANDBOX_MIN_VERSION + 5), withSdkLibraryElement("20"), withMetadataValue(SDK_PATCH_VERSION_ATTRIBUTE_NAME, "12"))).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.getMinSdkVersion()).hasValue(SDK_SANDBOX_MIN_VERSION + 5);
}
use of com.android.tools.build.bundletool.testing.SdkBundleBuilder in project bundletool by google.
the class BuildSdkApksManagerTest method sdkPatchVersionIsSetToDefaultValue.
@Test
public void sdkPatchVersionIsSetToDefaultValue() throws Exception {
SdkBundle sdkBundle = new SdkBundleBuilder().setModule(new BundleModuleBuilder("base").setManifest(androidManifest(PACKAGE_NAME, withSdkLibraryElement("1181894"))).build()).build();
execute(sdkBundle);
ZipFile apkSetFile = new ZipFile(outputFilePath.toFile());
BuildSdkApksResult result = extractTocFromSdkApkSetFile(apkSetFile, tmpDir);
SdkVersionInformation version = result.getVersion();
assertThat(version.getPatch()).isEqualTo(Long.parseLong(DEFAULT_SDK_PATCH_VERSION));
}
Aggregations