use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.
the class XmlProtoElementBuilderTest method getOrCreateAttribute_attributeAlreadyExists.
@Test
public void getOrCreateAttribute_attributeAlreadyExists() {
XmlAttribute attribute = XmlAttribute.newBuilder().setName("attribute").build();
XmlElement protoElement = XmlElement.newBuilder().addAttribute(attribute).build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
XmlProtoAttributeBuilder fetchedAttribute = element.getOrCreateAttribute("attribute");
assertThat(fetchedAttribute.getProto().build()).isEqualTo(attribute);
assertThat(element.getProto().build()).isEqualTo(protoElement);
}
use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.
the class XmlProtoElementBuilderTest method getOrCreateAttribute_attributeDoesNotExist.
@Test
public void getOrCreateAttribute_attributeDoesNotExist() {
XmlAttribute attribute = XmlAttribute.newBuilder().setName("attribute").build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(XmlElement.newBuilder());
XmlProtoAttributeBuilder fetchedAttribute = element.getOrCreateAttribute("attribute");
assertThat(fetchedAttribute.getProto().build()).isEqualTo(attribute);
assertThat(element.getProto().build()).isEqualTo(XmlElement.newBuilder().addAttribute(attribute).build());
}
use of com.android.aapt.Resources.XmlAttribute 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.XmlAttribute in project bundletool by google.
the class XmlProtoElementTest method getAttribute_withNameAndNamespace.
@Test
public void getAttribute_withNameAndNamespace() {
XmlAttribute attribute1 = XmlAttribute.newBuilder().setName("attribute").build();
XmlAttribute attribute2 = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").build();
XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().setName("hello").addAttribute(attribute1).addAttribute(attribute2).build());
assertThat(element.getAttribute("namespace", "attribute")).hasValue(new XmlProtoAttribute(attribute2));
}
use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.
the class XmlProtoElementTest method getAttributeWihtResourceId.
@Test
public void getAttributeWihtResourceId() {
XmlAttribute attr1 = XmlAttribute.newBuilder().setName("attr1").setResourceId(0X123).build();
XmlAttribute attr2 = XmlAttribute.newBuilder().setName("attr2").setResourceId(0X456).build();
XmlAttribute attribute3 = XmlAttribute.newBuilder().setName("attribute3").build();
XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().addAttribute(attr1).addAttribute(attr2).addAttribute(attribute3).build());
assertThat(element.getAndroidAttribute(0x123)).hasValue(new XmlProtoAttribute(attr1));
assertThat(element.getAndroidAttribute(0x456)).hasValue(new XmlProtoAttribute(attr2));
}
Aggregations