use of com.android.aapt.Resources.XmlNode 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))));
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method doNotSetFeatureSplit_forBaseSplit.
@Test
public void doNotSetFeatureSplit_forBaseSplit() throws Exception {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setSplitIdForFeatureSplit("").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("application")));
// no split attribute and no isFeatureSplit attribute
assertThat(manifestElement.getAttributeList()).isEmpty();
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method getApplicationElement.
private static XmlElement getApplicationElement(AndroidManifest manifest) {
XmlNode manifestRoot = manifest.getManifestRoot().getProto();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getChildCount()).isEqualTo(1);
XmlNode applicationNode = manifestElement.getChild(0);
XmlElement applicationElement = applicationNode.getElement();
assertThat(applicationElement.getName()).isEqualTo("application");
return applicationElement;
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method copyPermissionGroups.
@Test
public void copyPermissionGroups() throws Exception {
XmlElement permisisonGroupElement = xmlElement("permission-group", xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, "group.1"));
AndroidManifest manifestWithPermissionGroups = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(permisisonGroupElement))));
AndroidManifest manifestToUpdate = AndroidManifest.create(androidManifest("com.test.app"));
AndroidManifest updatedManifest = manifestToUpdate.toEditor().copyPermissionGroups(manifestWithPermissionGroups).save();
ImmutableList<XmlElement> copiedPermissionGroups = updatedManifest.getManifestRoot().getProto().getElement().getChildList().stream().map(XmlNode::getElement).filter(childElement -> childElement.getName().equals("permission-group")).collect(toImmutableList());
assertThat(copiedPermissionGroups).containsExactly(permisisonGroupElement);
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method setPackage.
@Test
public void setPackage() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setPackage("com.test.app").save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.hasElement()).isTrue();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getAttributeList()).containsExactly(xmlAttribute("package", "com.test.app"));
}
Aggregations