use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestDeliveryElementTest method fastFollowElement_childElement_throws.
@Test
public void fastFollowElement_childElement_throws() {
XmlNode nodeWithTypo = createAndroidManifestWithDeliveryElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "delivery").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "fast-follow").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "conditions"))));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> ManifestDeliveryElement.fromManifestRootNode(nodeWithTypo, /* isFastFollowAllowed= */
true));
assertThat(exception).hasMessageThat().contains("Expected <dist:fast-follow> element to have no child elements but found: " + "'conditions' with namespace URI: " + "'http://schemas.android.com/apk/distribution'");
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestDeliveryElementTest method deliveryElement_typoInChildElement_throws.
@Test
public void deliveryElement_typoInChildElement_throws() {
XmlNode nodeWithTypo = createAndroidManifestWithDeliveryElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "delivery").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "instal-time")));
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> ManifestDeliveryElement.fromManifestRootNode(nodeWithTypo, /* isFastFollowAllowed= */
false));
assertThat(exception).hasMessageThat().contains("Expected <dist:delivery> element to contain only <dist:install-time>, " + "<dist:on-demand> elements but found: 'instal-time' with namespace URI: " + "'http://schemas.android.com/apk/distribution'");
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestDeliveryElementTest method userCountriesCondition_badCountryElementName_throws.
@Test
public void userCountriesCondition_badCountryElementName_throws() {
XmlNode manifest = createAndroidManifestWithConditions(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "user-countries").addChildElement(XmlProtoElementBuilder.create(DISTRIBUTION_NAMESPACE_URI, "country-typo").addAttribute(XmlProtoAttributeBuilder.create(DISTRIBUTION_NAMESPACE_URI, "code").setValueAsString("DE"))).build());
Optional<ManifestDeliveryElement> deliveryElement = ManifestDeliveryElement.fromManifestRootNode(manifest, /* isFastFollowAllowed= */
false);
assertThat(deliveryElement).isPresent();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> deliveryElement.get().getModuleConditions().getUserCountriesCondition());
assertThat(exception).hasMessageThat().contains("Expected only <dist:country> elements inside <dist:user-countries>");
}
use of com.android.aapt.Resources.XmlNode 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.aapt.Resources.XmlNode 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