Search in sources :

Example 1 with SourcePosition

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

the class XmlProtoElementBuilderTest method removeSourceDataRecursive.

@Test
public void removeSourceDataRecursive() {
    SourcePosition sourcePosition = SourcePosition.newBuilder().setLineNumber(12).setColumnNumber(32).build();
    XmlElement element = XmlElement.newBuilder().addAttribute(XmlAttribute.newBuilder().setSource(sourcePosition).setName("name1").setValue("value")).addAttribute(XmlAttribute.newBuilder().setSource(sourcePosition).setName("name2").setValue("value")).addNamespaceDeclaration(XmlNamespace.newBuilder().setSource(sourcePosition).setPrefix("pref").setUri("http://uri")).addChild(XmlNode.newBuilder().setElement(XmlElement.newBuilder().addAttribute(XmlAttribute.newBuilder().setSource(sourcePosition).setName("nested").setValue("another")))).addChild(XmlNode.newBuilder().setSource(sourcePosition).setText("Text1")).addChild(XmlNode.newBuilder().setSource(sourcePosition).setText("Text2")).build();
    XmlElement elementWithoutSource = new XmlProtoElementBuilder(element.toBuilder()).removeSourceDataRecursive().build().getProto();
    XmlElement expected = XmlElement.newBuilder().addAttribute(XmlAttribute.newBuilder().setName("name1").setValue("value")).addAttribute(XmlAttribute.newBuilder().setName("name2").setValue("value")).addNamespaceDeclaration(XmlNamespace.newBuilder().setPrefix("pref").setUri("http://uri")).addChild(XmlNode.newBuilder().setElement(XmlElement.newBuilder().addAttribute(XmlAttribute.newBuilder().setName("nested").setValue("another")))).addChild(XmlNode.newBuilder().setText("Text1")).addChild(XmlNode.newBuilder().setText("Text2")).build();
    assertThat(elementWithoutSource).isEqualTo(expected);
}
Also used : SourcePosition(com.android.aapt.Resources.SourcePosition) XmlElement(com.android.aapt.Resources.XmlElement) Test(org.junit.Test)

Aggregations

SourcePosition (com.android.aapt.Resources.SourcePosition)1 XmlElement (com.android.aapt.Resources.XmlElement)1 Test (org.junit.Test)1