use of com.android.aapt.Resources.XmlElement 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.XmlElement 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.XmlElement in project bundletool by google.
the class ManifestEditorTest method removeSplitNameActivity.
@Test
public void removeSplitNameActivity() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "foo")));
AndroidManifest editedManifest = manifest.toEditor().removeSplitName().save();
ImmutableList<XmlElement> activities = editedManifest.getManifestElement().getChildElement("application").getChildrenElements(ACTIVITY_ELEMENT_NAME).map(XmlProtoElement::getProto).collect(toImmutableList());
assertThat(activities).hasSize(2);
XmlElement activityElement = activities.get(1);
assertThat(activityElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID, "FooActivity"));
}
use of com.android.aapt.Resources.XmlElement 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.XmlElement 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