use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setHasCode_true.
@Test
public void setHasCode_true() throws Exception {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setHasCode(true).save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.hasElement()).isTrue();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getChildCount()).isEqualTo(1);
XmlNode applicationNode = manifestElement.getChild(0);
assertThat(applicationNode.hasElement()).isTrue();
XmlElement applicationElement = manifestElement.getChild(0).getElement();
assertThat(applicationElement.getAttributeList()).containsExactly(xmlBooleanAttribute(ANDROID_NAMESPACE_URI, "hasCode", HAS_CODE_RESOURCE_ID, true));
assertThat(applicationElement.getChildList()).isEmpty();
}
use of com.android.aapt.Resources.XmlElement 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.XmlElement in project bundletool by google.
the class XmlProtoElementBuilderTest method removeAndroidAttribute_namespaceNotMatching.
@Test
public void removeAndroidAttribute_namespaceNotMatching() {
XmlElement protoElement = XmlElement.newBuilder().addAttribute(XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").setResourceId(0x123)).build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
element.removeAndroidAttribute(0x123);
assertThat(element.getProto().build()).isEqualTo(protoElement);
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementBuilderTest method addChildText.
@Test
public void addChildText() {
XmlElement protoElement = XmlElement.getDefaultInstance();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
element.addChildText("hello");
assertThat(element.getProto().build()).isEqualTo(protoElement.toBuilder().addChild(XmlNode.newBuilder().setText("hello")).build());
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementBuilderTest method removeAndroidAttribute_resourceNotMatching.
@Test
public void removeAndroidAttribute_resourceNotMatching() {
XmlElement protoElement = XmlElement.newBuilder().addAttribute(XmlAttribute.newBuilder().setName("attribute").setNamespaceUri(ANDROID_NAMESPACE_URI).setResourceId(0x1234)).build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
element.removeAndroidAttribute(0x123);
assertThat(element.getProto().build()).isEqualTo(protoElement);
}
Aggregations