use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementBuilderTest method getOrCreateAttribute_withNamespace_attributeAlreadyExists.
@Test
public void getOrCreateAttribute_withNamespace_attributeAlreadyExists() {
XmlAttribute attribute = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").build();
XmlElement protoElement = XmlElement.newBuilder().addAttribute(attribute).build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
XmlProtoAttributeBuilder fetchedAttribute = element.getOrCreateAttribute("namespace", "attribute");
assertThat(fetchedAttribute.getProto().build()).isEqualTo(attribute);
assertThat(element.getProto().build()).isEqualTo(protoElement);
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementBuilderTest method getOrCreateChildElement_childDoesNotExist.
@Test
public void getOrCreateChildElement_childDoesNotExist() {
XmlElement protoElement = XmlElement.newBuilder().addChild(XmlNode.newBuilder().setElement(XmlElement.newBuilder().setName("hello").setNamespaceUri("namespace"))).build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
XmlProtoElementBuilder fetchedElement = element.getOrCreateChildElement("hello");
assertThat(fetchedElement.getProto().build()).isEqualTo(XmlElement.newBuilder().setName("hello").build());
assertThat(element.getProto().build()).isEqualTo(protoElement.toBuilder().addChild(XmlNode.newBuilder().setElement(XmlElement.newBuilder().setName("hello"))).build());
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementTest method getChildrenElements_withName.
@Test
public void getChildrenElements_withName() {
XmlElement childElement1 = XmlElement.newBuilder().setName("child").build();
XmlElement childElement2 = XmlElement.newBuilder().setName("child").addAttribute(XmlAttribute.newBuilder().setName("test")).build();
XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().addChild(XmlNode.newBuilder().setElement(childElement1)).addChild(XmlNode.newBuilder().setElement(XmlElement.newBuilder().setName("other"))).addChild(XmlNode.newBuilder().setElement(childElement2)).addChild(XmlNode.newBuilder().setElement(childElement1.toBuilder().setNamespaceUri("namespace"))).build());
assertThat(element.getChildrenElements("child")).containsExactly(new XmlProtoElement(childElement1), new XmlProtoElement(childElement2));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementTest method getChildElement_withNamespace_oneElement.
@Test
public void getChildElement_withNamespace_oneElement() {
XmlElement childElement = XmlElement.newBuilder().setName("child").setNamespaceUri("namespace").build();
XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().setName("hello").addChild(XmlNode.newBuilder().setElement(childElement)).build());
assertThat(element.getChildElement("namespace", "child")).isEqualTo(new XmlProtoElement(childElement));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementTest method getOptionalChildElement_oneElement.
@Test
public void getOptionalChildElement_oneElement() {
XmlElement childElement = XmlElement.newBuilder().setName("child").build();
XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().setName("hello").addChild(XmlNode.newBuilder().setElement(childElement)).build());
assertThat(element.getOptionalChildElement("child")).hasValue(new XmlProtoElement(childElement));
}
Aggregations