Search in sources :

Example 6 with XmlAttribute

use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.

the class XmlProtoElementTest method getAttributeIgnoringNamespace_withNamespace.

@Test
public void getAttributeIgnoringNamespace_withNamespace() {
    XmlAttribute attribute = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").build();
    XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().setName("hello").addAttribute(attribute).build());
    assertThat(element.getAttributeIgnoringNamespace("attribute")).hasValue(new XmlProtoAttribute(attribute));
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) Test(org.junit.Test)

Example 7 with XmlAttribute

use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.

the class XmlProtoElementTest method getAttributes.

@Test
public void getAttributes() {
    XmlAttribute attribute1 = XmlAttribute.newBuilder().setName("test").build();
    XmlAttribute attribute2 = XmlAttribute.newBuilder().setName("test2").build();
    XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().setName("hello").addAttribute(attribute1).addAttribute(attribute2).build());
    assertThat(element.getAttributes()).containsExactly(new XmlProtoAttribute(attribute1), new XmlProtoAttribute(attribute2));
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) Test(org.junit.Test)

Example 8 with XmlAttribute

use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.

the class XmlProtoElementTest method getAttributeIgnoringNamespace_withoutNamespace.

@Test
public void getAttributeIgnoringNamespace_withoutNamespace() {
    XmlAttribute attribute = XmlAttribute.newBuilder().setName("attribute").build();
    XmlProtoElement element = new XmlProtoElement(XmlElement.newBuilder().setName("hello").addAttribute(attribute).build());
    assertThat(element.getAttributeIgnoringNamespace("attribute")).hasValue(new XmlProtoAttribute(attribute));
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) Test(org.junit.Test)

Example 9 with XmlAttribute

use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.

the class XmlProtoElementBuilderTest method getOrCreateAttribute_withNamespace_attributeDiffersByNamespace.

@Test
public void getOrCreateAttribute_withNamespace_attributeDiffersByNamespace() {
    XmlAttribute attributeWithoutNamespace = XmlAttribute.newBuilder().setName("attribute").build();
    XmlAttribute attributeWithNamespace = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").build();
    XmlProtoElementBuilder element = new XmlProtoElementBuilder(XmlElement.newBuilder().addAttribute(attributeWithoutNamespace));
    XmlProtoAttributeBuilder fetchedAttribute = element.getOrCreateAttribute("namespace", "attribute");
    assertThat(fetchedAttribute.getProto().build()).isEqualTo(attributeWithNamespace);
    assertThat(element.getProto().build()).isEqualTo(XmlElement.newBuilder().addAttribute(attributeWithoutNamespace).addAttribute(attributeWithNamespace).build());
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) Test(org.junit.Test)

Example 10 with XmlAttribute

use of com.android.aapt.Resources.XmlAttribute in project bundletool by google.

the class XmlProtoElementBuilderTest method getOrCreateAttribute_withNamespace_attributeDoesNotExist.

@Test
public void getOrCreateAttribute_withNamespace_attributeDoesNotExist() {
    XmlAttribute attribute = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").build();
    XmlProtoElementBuilder element = new XmlProtoElementBuilder(XmlElement.newBuilder());
    XmlProtoAttributeBuilder fetchedAttribute = element.getOrCreateAttribute("namespace", "attribute");
    assertThat(fetchedAttribute.getProto().build()).isEqualTo(attribute);
    assertThat(element.getProto().build()).isEqualTo(XmlElement.newBuilder().addAttribute(attribute).build());
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) Test(org.junit.Test)

Aggregations

XmlAttribute (com.android.aapt.Resources.XmlAttribute)20 Test (org.junit.Test)20 XmlElement (com.android.aapt.Resources.XmlElement)8 XmlNode (com.android.aapt.Resources.XmlNode)2 TestData (com.android.tools.build.bundletool.TestData)2 ACTIVITY_ELEMENT_NAME (com.android.tools.build.bundletool.model.AndroidManifest.ACTIVITY_ELEMENT_NAME)2 ALLOW_BACKUP_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_ATTRIBUTE_NAME)2 ALLOW_BACKUP_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_RESOURCE_ID)2 DATA_EXTRACTION_RULES_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_ATTRIBUTE_NAME)2 DATA_EXTRACTION_RULES_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_RESOURCE_ID)2 DESCRIPTION_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_ATTRIBUTE_NAME)2 DESCRIPTION_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_RESOURCE_ID)2 FULL_BACKUP_CONTENT_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_ATTRIBUTE_NAME)2 FULL_BACKUP_CONTENT_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_RESOURCE_ID)2 FULL_BACKUP_ONLY_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_ATTRIBUTE_NAME)2 FULL_BACKUP_ONLY_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_RESOURCE_ID)2 HAS_CODE_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.HAS_CODE_RESOURCE_ID)2 HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME)2 HAS_FRAGILE_USER_DATA_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_RESOURCE_ID)2 ICON_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.ICON_ATTRIBUTE_NAME)2