use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementBuilderTest method removeAndroidAttribute_noName.
@Test
public void removeAndroidAttribute_noName() {
XmlElement protoElement = XmlElement.newBuilder().addAttribute(XmlAttribute.newBuilder().setResourceId(0x123).setNamespaceUri(ANDROID_NAMESPACE_URI)).build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
element.removeAndroidAttribute(0x123);
assertThat(element.getProto().build()).isEqualToDefaultInstance();
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class XmlProtoElementBuilderTest method getOrCreateChildElement_childExists.
@Test
public void getOrCreateChildElement_childExists() {
XmlElement childElement = XmlElement.newBuilder().setName("hello").build();
XmlElement protoElement = XmlElement.newBuilder().addChild(XmlNode.newBuilder().setElement(childElement)).build();
XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
XmlProtoElementBuilder fetchedElement = element.getOrCreateChildElement("hello");
assertThat(fetchedElement.getProto().build()).isEqualTo(childElement);
assertThat(element.getProto().build()).isEqualTo(protoElement);
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setFeatureSplit_isFeatureAttributePresent.
@Test
public void setFeatureSplit_isFeatureAttributePresent() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlBooleanAttribute(ANDROID_NAMESPACE_URI, "isFeatureSplit", IS_FEATURE_SPLIT_RESOURCE_ID, false), xmlNode(xmlElement("application")))));
AndroidManifest editedManifest = androidManifest.toEditor().setSplitIdForFeatureSplit("feature1").save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.hasElement()).isTrue();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getChildList()).containsExactly(xmlNode(xmlElement("application")));
assertThat(manifestElement.getAttributeList()).containsExactly(xmlBooleanAttribute(ANDROID_NAMESPACE_URI, "isFeatureSplit", IS_FEATURE_SPLIT_RESOURCE_ID, true), xmlAttribute("split", "feature1"));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setMaxSdkVersion_nonExistingAttribute_created.
@Test
public void setMaxSdkVersion_nonExistingAttribute_created() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("uses-sdk")))));
AndroidManifest editedManifest = androidManifest.toEditor().setMaxSdkVersion(123).save();
XmlNode editedManifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(editedManifestRoot.hasElement()).isTrue();
XmlElement manifestElement = editedManifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getChildList()).containsExactly(xmlNode(xmlElement("uses-sdk", xmlDecimalIntegerAttribute(ANDROID_NAMESPACE_URI, "maxSdkVersion", MAX_SDK_VERSION_RESOURCE_ID, 123))));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setTargetSdkVersion_existingAttribute_adjusted.
@Test
public void setTargetSdkVersion_existingAttribute_adjusted() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("uses-sdk", xmlDecimalIntegerAttribute(ANDROID_NAMESPACE_URI, "targetSdkVersion", TARGET_SDK_VERSION_RESOURCE_ID, 1))))));
AndroidManifest editedManifest = androidManifest.toEditor().setTargetSdkVersion(123).save();
XmlNode editedManifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(editedManifestRoot.hasElement()).isTrue();
XmlElement manifestElement = editedManifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getChildList()).containsExactly(xmlNode(xmlElement("uses-sdk", xmlDecimalIntegerAttribute(ANDROID_NAMESPACE_URI, "targetSdkVersion", TARGET_SDK_VERSION_RESOURCE_ID, 123))));
}
Aggregations