Search in sources :

Example 81 with BuildApksResult

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

the class ApkMatcherTest method splitApk_conditionalModule_deviceNotEligible.

@Test
public void splitApk_conditionalModule_deviceNotEligible() {
    DeviceSpec device = mergeSpecs(deviceWithSdk(21), deviceFeatures("reqGlEsVersion=0x30000"));
    ZipPath baseApk = ZipPath.create("base-master.apk");
    ZipPath feature1Apk = ZipPath.create("ar-master.apk");
    ZipPath feature2Apk = ZipPath.create("opengl-master.apk");
    ZipPath feature3Apk = ZipPath.create("high_end-master.apk");
    BuildApksResult buildApksResult = buildApksResult(createVariant(variantSdkTargeting(21), splitApkSet(/* moduleName= */
    "base", splitApkDescription(ApkTargeting.getDefaultInstance(), baseApk)), createConditionalApkSet(/* moduleName= */
    "ar", mergeModuleTargeting(moduleFeatureTargeting("android.hardware.camera.ar"), moduleMinSdkVersionTargeting(24)), splitApkDescription(ApkTargeting.getDefaultInstance(), feature1Apk)), createConditionalApkSet(/* moduleName= */
    "opengl", mergeModuleTargeting(moduleFeatureTargeting("android.hardware.opengles.version", 0x30001), moduleMinSdkVersionTargeting(21)), splitApkDescription(ApkTargeting.getDefaultInstance(), feature2Apk)), createConditionalApkSet(/* moduleName= */
    "high_end", mergeModuleTargeting(moduleDeviceGroupsTargeting("highRam"), moduleMinSdkVersionTargeting(21)), splitApkDescription(ApkTargeting.getDefaultInstance(), feature3Apk))));
    assertThat(new ApkMatcher(device).getMatchingApks(buildApksResult)).containsExactly(baseMatchedApk(baseApk));
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 82 with BuildApksResult

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

the class ApkMatcherTest method apkDoesntMatch_abiSplit_betterAlternative.

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

Example 83 with BuildApksResult

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

the class ApkMatcherTest method apkNoMatch_screenDensitySplit_betterAlternative.

@Test
public void apkNoMatch_screenDensitySplit_betterAlternative() {
    ZipPath apk = ZipPath.create("sample.apk");
    BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(Versions.ANDROID_L_API_VERSION)), apkDensityTargeting(HDPI, ImmutableSet.of(XXXHDPI)), apk));
    assertThat(new ApkMatcher(lDeviceWithDensity(XXHDPI)).getMatchingApks(buildApksResult)).isEmpty();
}
Also used : BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 84 with BuildApksResult

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

the class ApkMatcherTest method apkMatch_textureSplit_betterAlternative.

@Test
public void apkMatch_textureSplit_betterAlternative() {
    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", "GL_IMG_texture_compression_pvrtc")).getMatchingApks(buildApksResult)).isEmpty();
}
Also used : BuildApksResult(com.android.bundle.Commands.BuildApksResult) ZipPath(com.android.tools.build.bundletool.model.ZipPath) Test(org.junit.Test)

Example 85 with BuildApksResult

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

the class ApkMatcherTest method apkMatch_screenDensitySplit.

// Density splits.
@Test
public void apkMatch_screenDensitySplit() {
    ZipPath apk = ZipPath.create("sample.apk");
    BuildApksResult buildApksResult = buildApksResult(oneApkSplitApkVariant(variantSdkTargeting(sdkVersionFrom(Versions.ANDROID_L_API_VERSION)), apkDensityTargeting(HDPI), apk));
    assertThat(new ApkMatcher(lDeviceWithDensity(HDPI)).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)

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