use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method apkMatch_screenDensitySplit_noBetterAlternative.
@Test
public void apkMatch_screenDensitySplit_noBetterAlternative() {
ZipPath apk = ZipPath.create("sample.apk");
BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(Versions.ANDROID_L_API_VERSION)), apkDensityTargeting(XXXHDPI, ImmutableSet.of(MDPI, HDPI)), apk));
assertThat(new ApkMatcher(lDeviceWithDensity(XXHDPI)).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
}
use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method ensureDensityAndAbiSplitIsMatchedPerEachModule_split.
@Test
public void ensureDensityAndAbiSplitIsMatchedPerEachModule_split() {
ZipPath baseMasterSplitApk = ZipPath.create("base-master.apk");
ZipPath baseX86SplitApk = ZipPath.create("base-x86.apk");
ZipPath baseMdpiSplitApk = ZipPath.create("base-mdpi.apk");
ZipPath baseHdpiSplitApk = ZipPath.create("base-hdpi.apk");
ZipPath screenMdpiApk = ZipPath.create("screen-mdpi.apk");
BuildApksResult buildApksResult = buildApksResult(splitApkVariant(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(sdkVersionFrom(1))), splitApkSet(/* moduleName= */
"base", splitApkDescription(ApkTargeting.getDefaultInstance(), baseMasterSplitApk), splitApkDescription(apkAbiTargeting(X86, ImmutableSet.of(X86_64)), baseX86SplitApk), splitApkDescription(apkDensityTargeting(MDPI, ImmutableSet.of(HDPI, XHDPI)), baseMdpiSplitApk), splitApkDescription(apkDensityTargeting(HDPI, ImmutableSet.of(MDPI, XHDPI)), baseHdpiSplitApk)), splitApkSet(/* moduleName= */
"screen", splitApkDescription(apkDensityTargeting(MDPI, ImmutableSet.of(HDPI)), screenMdpiApk))));
Optional<ImmutableSet<String>> allModules = Optional.of(ImmutableSet.of("base", "screen"));
assertThat(createSafeMatcher(mergeSpecs(density(MDPI), abis("x86")), allModules).getMatchingApks(buildApksResult)).containsExactly(matchedApk(baseMasterSplitApk, "base", INSTALL_TIME), matchedApk(baseX86SplitApk, "base", INSTALL_TIME), matchedApk(baseMdpiSplitApk, "base", INSTALL_TIME), matchedApk(screenMdpiApk, "screen", INSTALL_TIME));
IncompatibleDeviceException baseException = assertThrows(IncompatibleDeviceException.class, () -> createSafeMatcher(mergeSpecs(density(MDPI), abis("x86_64")), allModules).getMatchingApks(buildApksResult));
assertThat(baseException).hasMessageThat().isEqualTo("Missing APKs for [ABI] dimensions in the module 'base' for the provided device.");
IncompatibleDeviceException screenException = assertThrows(IncompatibleDeviceException.class, () -> createSafeMatcher(mergeSpecs(density(HDPI), abis("x86")), allModules).getMatchingApks(buildApksResult));
assertThat(screenException).hasMessageThat().isEqualTo("Missing APKs for [SCREEN_DENSITY] dimensions in the module 'screen' for the provided" + " device.");
IncompatibleDeviceException multipleDimensionsException = assertThrows(IncompatibleDeviceException.class, () -> createSafeMatcher(mergeSpecs(density(XHDPI), abis("x86_64")), allModules).getMatchingApks(buildApksResult));
assertThat(multipleDimensionsException).hasMessageThat().isEqualTo("Missing APKs for [ABI, SCREEN_DENSITY] dimensions in the module 'base' for the" + " provided device.");
}
use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method apkNoMatch_deviceDoesntMatchVariantValue_bothBetterAndNoBetterAlternatives.
@Test
public void apkNoMatch_deviceDoesntMatchVariantValue_bothBetterAndNoBetterAlternatives() {
ZipPath apk = ZipPath.create("sample.apk");
BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(21), ImmutableSet.of(sdkVersionFrom(1), sdkVersionFrom(23))), ApkTargeting.getDefaultInstance(), apk));
assertThat(new ApkMatcher(deviceWithSdk(19)).getMatchingApks(buildApksResult)).isEmpty();
}
use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method apkMatch_withModuleNameFiltering_instantApks_checksModuleName_isEmpty.
@Test
public void apkMatch_withModuleNameFiltering_instantApks_checksModuleName_isEmpty() {
DeviceSpec device = deviceWithSdk(21);
ZipPath apk = ZipPath.create("master-de-fr.apk");
BuildApksResult buildApksResult = buildApksResult(createVariant(VariantTargeting.getDefaultInstance(), splitApkSet(/* moduleName= */
"base", splitApkDescription(ApkTargeting.getDefaultInstance(), apk))));
Optional<ImmutableSet<String>> allModules = Optional.empty();
assertThat(createInstantMatcher(device, allModules).getMatchingApks(buildApksResult)).isEmpty();
Optional<ImmutableSet<String>> baseModuleOnly = Optional.of(ImmutableSet.of("base"));
assertThat(createInstantMatcher(device, baseModuleOnly).getMatchingApks(buildApksResult)).isEmpty();
Optional<ImmutableSet<String>> featureModuleOnly = Optional.of(ImmutableSet.of("feature"));
// No matching instant variant
assertThat(createInstantMatcher(device, featureModuleOnly).getMatchingApks(buildApksResult)).isEmpty();
}
use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method variantBetterAlternative_preL_abiShard.
@Test
public void variantBetterAlternative_preL_abiShard() {
ZipPath apk = ZipPath.create("sample.apk");
BuildApksResult buildApksResult = buildApksResult(standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantAbiTargeting(X86, ImmutableSet.of(ARMEABI_V7A, ARM64_V8A, X86_64))), ApkTargeting.getDefaultInstance(), apk));
assertThat(new ApkMatcher(deviceWith(19, ImmutableList.of("x86_64", "x86"), MDPI)).getMatchingApks(buildApksResult)).isEmpty();
}
Aggregations