Search in sources :

Example 16 with ModuleTargeting

use of com.android.bundle.Targeting.ModuleTargeting in project bundletool by google.

the class ModuleConditionsTest method toTargeting_mixedConditions.

@Test
public void toTargeting_mixedConditions() {
    ModuleConditions moduleConditions = ModuleConditions.builder().addDeviceFeatureCondition(DeviceFeatureCondition.create("com.feature1")).addDeviceFeatureCondition(DeviceFeatureCondition.create("com.feature2")).setMinSdkVersion(24).setUserCountriesCondition(UserCountriesCondition.create(ImmutableList.of("FR"), /* exclude= */
    false)).setDeviceGroupsCondition(DeviceGroupsCondition.create(ImmutableSet.of("group1"))).build();
    ModuleTargeting moduleTargeting = moduleConditions.toTargeting();
    assertThat(moduleTargeting).ignoringRepeatedFieldOrder().isEqualTo(mergeModuleTargeting(moduleFeatureTargeting("com.feature1"), moduleFeatureTargeting("com.feature2"), moduleMinSdkVersionTargeting(24), moduleIncludeCountriesTargeting("FR"), moduleDeviceGroupsTargeting("group1")));
}
Also used : TargetingUtils.mergeModuleTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting) ModuleTargeting(com.android.bundle.Targeting.ModuleTargeting) Test(org.junit.Test)

Example 17 with ModuleTargeting

use of com.android.bundle.Targeting.ModuleTargeting in project bundletool by google.

the class BundleModuleTest method moduleTargeting_moduleMinSdkVersion_minSdkConditionPreferred.

@Test
public void moduleTargeting_moduleMinSdkVersion_minSdkConditionPreferred() {
    BundleModule bundleModule = createMinimalModuleBuilder().setAndroidManifestProto(androidManifest("com.test.app", withMinSdkVersion(24), withMinSdkCondition(28), withFeatureCondition("com.feature1"))).build();
    ModuleTargeting moduleTargeting = bundleModule.getModuleMetadata().getTargeting();
    assertThat(moduleTargeting).ignoringRepeatedFieldOrder().isEqualTo(mergeModuleTargeting(moduleFeatureTargeting("com.feature1"), moduleMinSdkVersionTargeting(28)));
}
Also used : TargetingUtils.mergeModuleTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting) ModuleTargeting(com.android.bundle.Targeting.ModuleTargeting) Test(org.junit.Test)

Example 18 with ModuleTargeting

use of com.android.bundle.Targeting.ModuleTargeting in project bundletool by google.

the class BundleModuleTest method moduleTargeting_moduleMinSdkVersionInherited.

@Test
public void moduleTargeting_moduleMinSdkVersionInherited() {
    BundleModule bundleModule = createMinimalModuleBuilder().setAndroidManifestProto(androidManifest("com.test.app", withMinSdkVersion(24), withFeatureCondition("com.feature1"))).build();
    ModuleTargeting moduleTargeting = bundleModule.getModuleMetadata().getTargeting();
    assertThat(moduleTargeting).ignoringRepeatedFieldOrder().isEqualTo(mergeModuleTargeting(moduleFeatureTargeting("com.feature1"), moduleMinSdkVersionTargeting(24)));
}
Also used : TargetingUtils.mergeModuleTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting) ModuleTargeting(com.android.bundle.Targeting.ModuleTargeting) Test(org.junit.Test)

Aggregations

ModuleTargeting (com.android.bundle.Targeting.ModuleTargeting)18 TargetingUtils.mergeModuleTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.mergeModuleTargeting)18 Test (org.junit.Test)18 DeviceSpec (com.android.bundle.Devices.DeviceSpec)5