Search in sources :

Example 31 with DeviceSpec

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

the class DeviceFeatureMatcherTest method deviceFeaturePresent_match.

@Test
public void deviceFeaturePresent_match() {
    DeviceSpec deviceSpec = deviceFeatures("com.software.soft.feature1", "com.hardware.cool.feature", "com.hardware.even.cooler.feature");
    DeviceFeatureMatcher matcher = new DeviceFeatureMatcher(deviceSpec);
    assertThat(matcher.matchesTargeting(deviceFeatureTargetingList("com.hardware.cool.feature"))).isTrue();
    assertThat(matcher.matchesTargeting(deviceFeatureTargetingList("com.software.soft.feature1", "com.hardware.even.cooler.feature"))).isTrue();
    assertThat(matcher.matchesTargeting(ImmutableList.of())).isTrue();
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) Test(org.junit.Test)

Example 32 with DeviceSpec

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

the class DeviceFeatureMatcherTest method skipOpenGlFeature.

@Test
public void skipOpenGlFeature() {
    DeviceSpec deviceSpec = deviceFeatures("com.hardware.cool.feature");
    DeviceFeatureMatcher matcher = new DeviceFeatureMatcher(deviceSpec);
    ImmutableList<DeviceFeatureTargeting> deviceFeatureTargetings = ImmutableList.of(deviceFeatureTargeting(OpenGlFeatureMatcher.CONDITIONAL_MODULES_OPEN_GL_NAME, 0x30000), deviceFeatureTargeting("com.hardware.cool.feature"));
    assertThat(matcher.matchesTargeting(deviceFeatureTargetings)).isTrue();
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) DeviceFeatureTargeting(com.android.bundle.Targeting.DeviceFeatureTargeting) Test(org.junit.Test)

Example 33 with DeviceSpec

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

the class DeviceSpecParserTest method parsePartialDeviceSpec_acceptZeroSdk.

@Test
public void parsePartialDeviceSpec_acceptZeroSdk() throws Exception {
    DeviceSpec deviceSpec = DeviceSpecParser.parsePartialDeviceSpec(TestData.openReader("testdata/device/invalid_spec_sdk_zero.json"));
    assertThat(deviceSpec.getSupportedAbisList()).containsExactly("armeabi-v7a");
    assertThat(deviceSpec.getScreenDensity()).isEqualTo(411);
    assertThat(deviceSpec.getSdkVersion()).isEqualTo(0);
    assertThat(deviceSpec.getSupportedLocalesList()).containsExactly("en-US", "es-US");
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) Test(org.junit.Test)

Example 34 with DeviceSpec

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

the class DeviceSpecParserTest method parsePartialDeviceSpec_acceptEmptyAbi.

@Test
public void parsePartialDeviceSpec_acceptEmptyAbi() throws Exception {
    DeviceSpec deviceSpec = DeviceSpecParser.parsePartialDeviceSpec(TestData.openReader("testdata/device/invalid_spec_abi_empty.json"));
    assertThat(deviceSpec.getSupportedAbisList()).isEmpty();
    assertThat(deviceSpec.getScreenDensity()).isEqualTo(411);
    assertThat(deviceSpec.getSdkVersion()).isEqualTo(1);
    assertThat(deviceSpec.getSupportedLocalesList()).containsExactly("en-US", "es-US");
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) Test(org.junit.Test)

Example 35 with DeviceSpec

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

the class DeviceSpecUtilsTest method getDeviceSupportedTextureCompressionFormats.

@Test
public void getDeviceSupportedTextureCompressionFormats() {
    DeviceSpec deviceSpec = new DeviceSpecFromTargetingBuilder(DeviceSpec.getDefaultInstance()).setSupportedTextureCompressionFormats(textureCompressionTargeting(/* values= */
    ImmutableSet.of(TextureCompressionFormatAlias.ETC2, TextureCompressionFormatAlias.ASTC), /* alternatives= */
    ImmutableSet.of())).build();
    assertThat(DeviceSpecUtils.getDeviceSupportedTextureCompressionFormats(deviceSpec)).containsExactly(TextureCompressionFormatAlias.ETC2, TextureCompressionFormatAlias.ASTC);
}
Also used : DeviceSpec(com.android.bundle.Devices.DeviceSpec) DeviceSpecFromTargetingBuilder(com.android.tools.build.bundletool.device.DeviceSpecUtils.DeviceSpecFromTargetingBuilder) 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