Search in sources :

Example 71 with BuildApksResult

use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.

the class ApkMatcherTest method apexVariantMatch_matchesRightVariant.

@Test
public void apexVariantMatch_matchesRightVariant() {
    ZipPath x86Apk = ZipPath.create("standalone-x86.apk");
    ZipPath x64X86Apk = ZipPath.create("standalone-x86_64.x86.apk");
    ImmutableSet<ImmutableSet<AbiAlias>> x86Set = ImmutableSet.of(ImmutableSet.of(X86));
    ImmutableSet<ImmutableSet<AbiAlias>> x64X86Set = ImmutableSet.of(ImmutableSet.of(X86_64, X86));
    MultiAbiTargeting x86Targeting = multiAbiTargeting(x86Set, x64X86Set);
    MultiAbiTargeting x64X86Targeting = multiAbiTargeting(x64X86Set, x86Set);
    BuildApksResult buildApksResult = BuildApksResult.newBuilder().addVariant(multiAbiTargetingApexVariant(x86Targeting, x86Apk)).addVariant(multiAbiTargetingApexVariant(x64X86Targeting, x64X86Apk)).setBundletool(Bundletool.newBuilder().setVersion(BundleToolVersion.getCurrentVersion().toString())).build();
    assertThat(new ApkMatcher(abis("x86")).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(x86Apk));
    assertThat(new ApkMatcher(abis("x86_64", "x86")).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(x64X86Apk));
    assertThat(new ApkMatcher(abis("x86_64", "x86", "armeabi-v7a")).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(x64X86Apk));
    // Other device specs don't affect the matching variant.
    assertThat(new ApkMatcher(deviceWith(26, ImmutableList.of("x86"), HDPI)).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(x86Apk));
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) MultiAbiTargeting(com.android.bundle.Targeting.MultiAbiTargeting) Test(org.junit.Test)

Example 72 with BuildApksResult

use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.

the class ApkMatcherTest method apkMatch_textureSplit_fallback.

@Test
public void apkMatch_textureSplit_fallback() {
    ZipPath apk = ZipPath.create("master-other_tcf.apk");
    BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(Versions.ANDROID_L_API_VERSION)), apkTextureTargeting(ImmutableSet.of(), ImmutableSet.of(ATC, PVRTC)), apk));
    assertThat(new ApkMatcher(lDevice()).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
}
Also used : BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 73 with BuildApksResult

use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.

the class ApkMatcherTest method apkMatch_abiSplit.

// APK targeting tests.
// ABI splits.
@Test
public void apkMatch_abiSplit() {
    ZipPath apk = ZipPath.create("sample.apk");
    BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(Versions.ANDROID_L_API_VERSION)), apkAbiTargeting(X86), apk));
    assertThat(new ApkMatcher(lDeviceWithAbis("x86_64", "x86")).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
}
Also used : BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 74 with BuildApksResult

use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.

the class ApkMatcherTest method apkMatch_abiSplit_noBetterAlternative.

@Test
public void apkMatch_abiSplit_noBetterAlternative() {
    ZipPath apk = ZipPath.create("sample.apk");
    BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(Versions.ANDROID_L_API_VERSION)), apkAbiTargeting(X86, ImmutableSet.of(ARM64_V8A, ARMEABI)), apk));
    assertThat(new ApkMatcher(lDeviceWithAbis("x86_64", "x86", "arm64-v8a")).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(apk));
}
Also used : BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 75 with BuildApksResult

use of com.android.bundle.Commands.BuildApksResult in project bundletool by google.

the class ApkMatcherTest method textureVariant_preL_incompatibleDevice.

@Test
public void textureVariant_preL_incompatibleDevice() {
    ZipPath apk = ZipPath.create("master-etc1_rgb8.apk");
    BuildApksResult buildApksResult = buildApksResult(standaloneVariant(mergeVariantTargeting(variantSdkTargeting(sdkVersionFrom(1), ImmutableSet.of(sdkVersionFrom(21))), variantTextureTargeting(ATC)), ApkTargeting.getDefaultInstance(), apk));
    IncompatibleDeviceException exception = assertThrows(IncompatibleDeviceException.class, () -> new ApkMatcher(preLDeviceWithGlExtensions("GL_OES_compressed_ETC1_RGB8_texture")).getMatchingApks(buildApksResult));
    assertThat(exception).hasMessageThat().contains("The app doesn't support texture compression formats of the device. Device formats:" + " [ETC1_RGB8], app formats: [ATC]");
}
Also used : BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) IncompatibleDeviceException(com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException) Test(org.junit.Test)

Aggregations

BuildApksResult (com.android.bundle.Commands.BuildApksResult)282 Test (org.junit.Test)276 ZipPath (com.android.tools.build.bundletool.model.ZipPath)234 Path (java.nio.file.Path)180 Variant (com.android.bundle.Commands.Variant)120 ZipFile (java.util.zip.ZipFile)109 AppBundle (com.android.tools.build.bundletool.model.AppBundle)96 AppBundleBuilder (com.android.tools.build.bundletool.testing.AppBundleBuilder)93 ImmutableSet (com.google.common.collect.ImmutableSet)88 FakeAdbServer (com.android.tools.build.bundletool.testing.FakeAdbServer)87 Theory (org.junit.experimental.theories.Theory)86 ApkSet (com.android.bundle.Commands.ApkSet)84 AdbServer (com.android.tools.build.bundletool.device.AdbServer)84 ApkDescription (com.android.bundle.Commands.ApkDescription)82 ApkSetUtils.extractFromApkSetFile (com.android.tools.build.bundletool.testing.ApkSetUtils.extractFromApkSetFile)78 ApkSetUtils.extractTocFromApkSetFile (com.android.tools.build.bundletool.testing.ApkSetUtils.extractTocFromApkSetFile)78 File (java.io.File)78 AssetSliceSet (com.android.bundle.Commands.AssetSliceSet)77 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)77 IOException (java.io.IOException)76