use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method deviceFeatureCondition_missingNamespace_throws.
@Test
public void deviceFeatureCondition_missingNamespace_throws() {
XmlNode nodeWithTypo = createAndroidManifestWithDeliveryElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "delivery").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "install-time").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "conditions").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "device-feature").addAttribute(XmlProtoAttributeBuilder.create("name").setValueAsString("android.hardware.feature"))))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> ManifestDeliveryElement.fromManifestRootNode(nodeWithTypo, /* isFastFollowAllowed= */
false).get().getModuleConditions());
assertThat(exception).hasMessageThat().contains("Missing required 'dist:name' attribute in the 'device-feature' condition element.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method getModuleConditions_multipleMinSdkCondition_throws.
@Test
public void getModuleConditions_multipleMinSdkCondition_throws() {
Optional<ManifestDeliveryElement> element = ManifestDeliveryElement.fromManifestRootNode(androidManifest("com.test.app", withMinSdkCondition(24), withMinSdkCondition(28)), /* isFastFollowAllowed= */
false);
assertThat(element).isPresent();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> element.get().getModuleConditions());
assertThat(exception).hasMessageThat().contains("Multiple '<dist:min-sdk>' conditions are not supported.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method moduleConditions_wrongElementInsideDeviceGroupsCondition_throws.
@Test
public void moduleConditions_wrongElementInsideDeviceGroupsCondition_throws() {
XmlProtoElement badDeviceGroupCondition = XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "device-groups").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "wrong")).build();
Optional<ManifestDeliveryElement> element = ManifestDeliveryElement.fromManifestRootNode(createAndroidManifestWithConditions(badDeviceGroupCondition), /* isFastFollowAllowed= */
false);
assertThat(element).isPresent();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> element.get().getModuleConditions());
assertThat(exception).hasMessageThat().contains("Expected only '<dist:device-group>' elements inside '<dist:device-groups>', but found" + " 'wrong'");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method moduleConditions_wrongDeviceGroupName_throws.
@Test
public void moduleConditions_wrongDeviceGroupName_throws() {
Optional<ManifestDeliveryElement> element = ManifestDeliveryElement.fromManifestRootNode(androidManifest("com.test.app", withDeviceGroupsCondition(ImmutableList.of("group!!!"))), /* isFastFollowAllowed= */
false);
assertThat(element).isPresent();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> element.get().getModuleConditions());
assertThat(exception).hasMessageThat().isEqualTo("Device group names should start with a letter and contain only " + "letters, numbers and underscores. Found group named 'group!!!' in " + "'<dist:device-group>' element.");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method minSdkCondition_missingNamespace_throws.
@Test
public void minSdkCondition_missingNamespace_throws() {
XmlNode nodeWithTypo = createAndroidManifestWithDeliveryElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "delivery").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "install-time").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "conditions").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "min-sdk").addAttribute(XmlProtoAttributeBuilder.create("value").setValueAsDecimalInteger(21))))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> ManifestDeliveryElement.fromManifestRootNode(nodeWithTypo, /* isFastFollowAllowed= */
false).get().getModuleConditions());
assertThat(exception).hasMessageThat().contains("Missing required 'dist:value' attribute in the 'min-sdk' condition element.");
}
Aggregations