Search in sources :

Example 36 with DeviceSpec

use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.

the class DeviceSpecUtilsTest method deviceSpecFromTargetingBuilder_setDeviceTier.

@Test
public void deviceSpecFromTargetingBuilder_setDeviceTier() {
    DeviceSpec deviceSpec = new DeviceSpecFromTargetingBuilder(DeviceSpec.getDefaultInstance()).setDeviceTier(deviceTierTargeting(/* value= */
    2, /* alternatives= */
    ImmutableList.of(1))).build();
    assertThat(deviceSpec.getDeviceTier().getValue()).isEqualTo(2);
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) DeviceSpecFromTargetingBuilder(com.android.tools.build.bundletool.device.DeviceSpecUtils.DeviceSpecFromTargetingBuilder) Test(org.junit.Test)

Example 37 with DeviceSpec

use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.

the class ModuleMatcherTest method matchesModuleTargeting_negative_wrongDeviceTier.

@Test
public void matchesModuleTargeting_negative_wrongDeviceTier() {
    ModuleTargeting targeting = mergeModuleTargeting(moduleMinSdkVersionTargeting(21), moduleFeatureTargeting("feature1"), moduleDeviceGroupsTargeting("highRam"));
    DeviceSpec deviceSpec = mergeSpecs(deviceWithSdk(22), deviceGroups("lowRam"));
    ModuleMatcher moduleMatcher = new ModuleMatcher(deviceSpec);
    assertThat(moduleMatcher.matchesModuleTargeting(targeting)).isFalse();
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) TargetingUtils.mergeModuleTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting) ModuleTargeting(com.android.bundle.Targeting.ModuleTargeting) Test(org.junit.Test)

Example 38 with DeviceSpec

use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.

the class ModuleMatcherTest method matchesModuleTargeting_negative_sdkTooLow.

@Test
public void matchesModuleTargeting_negative_sdkTooLow() {
    ModuleTargeting targeting = mergeModuleTargeting(moduleMinSdkVersionTargeting(21), moduleFeatureTargeting("feature1"));
    DeviceSpec deviceSpecLowSdk = mergeSpecs(deviceWithSdk(19), deviceFeatures("feature1", "feature2"));
    ModuleMatcher moduleMatcher = new ModuleMatcher(deviceSpecLowSdk);
    assertThat(moduleMatcher.matchesModuleTargeting(targeting)).isFalse();
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) TargetingUtils.mergeModuleTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting) ModuleTargeting(com.android.bundle.Targeting.ModuleTargeting) Test(org.junit.Test)

Example 39 with DeviceSpec

use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.

the class ModuleMatcherTest method matchesModuleTargeting_negative_openGlVersionTooLow.

@Test
public void matchesModuleTargeting_negative_openGlVersionTooLow() {
    ModuleTargeting targeting = mergeModuleTargeting(moduleMinSdkVersionTargeting(21), moduleFeatureTargeting(CONDITIONAL_MODULES_OPEN_GL_NAME, 0x30001));
    DeviceSpec deviceSpec = mergeSpecs(deviceWithSdk(22), deviceFeatures("reqGlEsVersion=0x30000"));
    ModuleMatcher moduleMatcher = new ModuleMatcher(deviceSpec);
    assertThat(moduleMatcher.matchesModuleTargeting(targeting)).isFalse();
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) TargetingUtils.mergeModuleTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting) ModuleTargeting(com.android.bundle.Targeting.ModuleTargeting) Test(org.junit.Test)

Example 40 with DeviceSpec

use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.

the class ModuleMatcherTest method matchesModuleTargeting_positive.

@Test
public void matchesModuleTargeting_positive() {
    ModuleTargeting targeting = mergeModuleTargeting(moduleMinSdkVersionTargeting(21), moduleFeatureTargeting("feature1"), moduleFeatureTargeting(CONDITIONAL_MODULES_OPEN_GL_NAME, 0x30001), moduleDeviceGroupsTargeting("highRam"));
    DeviceSpec deviceSpec = mergeSpecs(deviceWithSdk(22), deviceFeatures("feature1", "feature2", "reqGlEsVersion=0x30002"), deviceGroups("highRam"));
    ModuleMatcher moduleMatcher = new ModuleMatcher(deviceSpec);
    assertThat(moduleMatcher.matchesModuleTargeting(targeting)).isTrue();
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) TargetingUtils.mergeModuleTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting) ModuleTargeting(com.android.bundle.Targeting.ModuleTargeting) Test(org.junit.Test)

Aggregations

DeviceSpec (com.android.bundle.Devices.DeviceSpec)124 Test (org.junit.Test)113 Path (java.nio.file.Path)71 BuildApksResult (com.android.bundle.Commands.BuildApksResult)68 ZipPath (com.android.tools.build.bundletool.model.ZipPath)64 FakeAdbServer (com.android.tools.build.bundletool.testing.FakeAdbServer)19 FlagParser (com.android.tools.build.bundletool.flags.FlagParser)18 AdbServer (com.android.tools.build.bundletool.device.AdbServer)15 ImmutableSet (com.google.common.collect.ImmutableSet)14 Theory (org.junit.experimental.theories.Theory)13 IncompatibleDeviceException (com.android.tools.build.bundletool.model.exceptions.IncompatibleDeviceException)12 Variant (com.android.bundle.Commands.Variant)11 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)11 ZipFile (java.util.zip.ZipFile)11 ApkSet (com.android.bundle.Commands.ApkSet)10 ImmutableList (com.google.common.collect.ImmutableList)9 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 SystemEnvironmentProvider (com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider)7 PrintStream (java.io.PrintStream)7