use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class AndroidManifestTest method getIsIncludedInFusing_missingIncludeAttribute_forSplit_throws.
@Test
public void getIsIncludedInFusing_missingIncludeAttribute_forSplit_throws() {
// From Bundletool 0.3.4 onwards.
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlAttribute("split", "feature1"), xmlNode(xmlElement(DISTRIBUTION_NAMESPACE_URI, "module", xmlNode(xmlElement(DISTRIBUTION_NAMESPACE_URI, "fusing")))))), BUNDLE_TOOL_0_3_4);
InvalidBundleException exception = assertThrows(InvalidBundleException.class, androidManifest::getIsModuleIncludedInFusing);
assertThat(exception).hasMessageThat().isEqualTo("<fusing> element is missing the 'include' attribute (split: 'feature1').");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException in project bundletool by google.
the class ManifestDeliveryElementTest method deliveryElement_typoInChildElement_throws_fastFollowEnabled.
@Test
public void deliveryElement_typoInChildElement_throws_fastFollowEnabled() {
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= */
true));
assertThat(exception).hasMessageThat().contains("Expected <dist:delivery> element to contain only <dist:install-time>, " + "<dist:on-demand>, <dist:fast-follow> elements but found: 'instal-time' " + "with namespace URI: 'http://schemas.android.com/apk/distribution'");
}
use of com.android.tools.build.bundletool.model.exceptions.InvalidBundleException 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.tools.build.bundletool.model.exceptions.InvalidBundleException 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.tools.build.bundletool.model.exceptions.InvalidBundleException 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>");
}
Aggregations