use of com.android.tools.build.bundletool.model.ZipPath in project bundletool by google.
the class ApkMatcherTest method apkMatch_withModuleNameFiltering_splitApks_moduleWithDependency.
@Test
public void apkMatch_withModuleNameFiltering_splitApks_moduleWithDependency() {
DeviceSpec device = deviceWithSdk(21);
ZipPath baseApk = ZipPath.create("master-base.apk");
ZipPath feature1Apk = ZipPath.create("master-feature1.apk");
ZipPath feature2Apk = ZipPath.create("master-feature2.apk");
BuildApksResult buildApksResult = buildApksResult(createVariant(VariantTargeting.getDefaultInstance(), splitApkSet(/* moduleName= */
"base", splitApkDescription(ApkTargeting.getDefaultInstance(), baseApk)), splitApkSet(/* moduleName= */
"feature1", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of(), splitApkDescription(ApkTargeting.getDefaultInstance(), feature1Apk)), splitApkSet(/* moduleName= */
"feature2", DeliveryType.ON_DEMAND, /* moduleDependencies= */
ImmutableList.of("feature1"), splitApkDescription(ApkTargeting.getDefaultInstance(), feature2Apk))));
// By default on-demand features are not installed.
Optional<ImmutableSet<String>> allModules = Optional.empty();
assertThat(createMatcher(device, allModules).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(baseApk));
Optional<ImmutableSet<String>> baseModuleOnly = Optional.of(ImmutableSet.of("base"));
assertThat(createMatcher(device, baseModuleOnly).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(baseApk));
Optional<ImmutableSet<String>> feature2ModuleOnly = Optional.of(ImmutableSet.of("feature2"));
assertThat(createMatcher(device, feature2ModuleOnly).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(baseApk), matchedApk(feature1Apk, /* moduleName=*/
"feature1", ON_DEMAND), matchedApk(feature2Apk, /* moduleName=*/
"feature2", ON_DEMAND));
Optional<ImmutableSet<String>> feature1ModuleOnly = Optional.of(ImmutableSet.of("feature1"));
assertThat(createMatcher(device, feature1ModuleOnly).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(baseApk), matchedApk(feature1Apk, /* moduleName=*/
"feature1", ON_DEMAND));
}
use of com.android.tools.build.bundletool.model.ZipPath 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.tools.build.bundletool.model.ZipPath 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.tools.build.bundletool.model.ZipPath 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.tools.build.bundletool.model.ZipPath 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();
}
Aggregations