use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method apkMatch_withModuleNameFiltering_standaloneApkMatches_throws.
@Test
public void apkMatch_withModuleNameFiltering_standaloneApkMatches_throws() {
DeviceSpec x86Device = lDeviceWithAbis("x86");
ZipPath apk = ZipPath.create("master-x86.apk");
BuildApksResult buildApksResult = buildApksResult(standaloneVariant(variantAbiTargeting(X86), apkAbiTargeting(X86), apk));
// Sanity-check that the device matches the standalone APK.
assertThat(new ApkMatcher(x86Device).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
Optional<ImmutableSet<String>> baseModuleOnly = Optional.of(ImmutableSet.of("base"));
InvalidCommandException exception = assertThrows(InvalidCommandException.class, () -> createMatcher(x86Device, baseModuleOnly).getMatchingApks(buildApksResult));
assertThat(exception).hasMessageThat().contains("Cannot restrict modules");
}
use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method apkMatch_withModuleNameFiltering_splitApks_checksModuleName.
// Module name filtering.
@Test
public void apkMatch_withModuleNameFiltering_splitApks_checksModuleName() {
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(createMatcher(device, allModules).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
Optional<ImmutableSet<String>> baseModuleOnly = Optional.of(ImmutableSet.of("base"));
assertThat(createMatcher(device, baseModuleOnly).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
Optional<ImmutableSet<String>> unknownModuleOnly = Optional.of(ImmutableSet.of("unknown_module"));
InvalidCommandException exception = assertThrows(InvalidCommandException.class, () -> createMatcher(device, unknownModuleOnly).getMatchingApks(buildApksResult));
assertThat(exception).hasMessageThat().contains("The APK Set archive does not contain the following modules: [unknown_module]");
}
use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method apkMatch_textureSplit_noBetterAlternative.
@Test
public void apkMatch_textureSplit_noBetterAlternative() {
ZipPath apk = ZipPath.create("master-etc1_rgb8.apk");
BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(Versions.ANDROID_L_API_VERSION)), apkTextureTargeting(ETC1_RGB8, ImmutableSet.of(ATC, PVRTC)), apk));
assertThat(new ApkMatcher(lDeviceWithGlExtensions("GL_OES_compressed_ETC1_RGB8_texture")).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
}
use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.
the class ApkMatcherTest method variantMatching_SdkAbiDensity.
@Test
public void variantMatching_SdkAbiDensity() {
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)), variantDensityTargeting(XHDPI, ImmutableSet.of(LDPI, XXHDPI))), ApkTargeting.getDefaultInstance(), apk));
assertThat(new ApkMatcher(deviceWith(19, ImmutableList.of("x86_64", "x86", "arm64-v8a"), HDPI)).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
}
use of com.android.bundle.Commands.BuildApksResult 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));
}
Aggregations