use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method assertOnlyMetadataElement.
private static void assertOnlyMetadataElement(AndroidManifest manifest, String name, XmlAttribute valueAttr) {
XmlElement applicationElement = getApplicationElement(manifest);
assertThat(applicationElement.getChildCount()).isEqualTo(1);
XmlNode metadataNode = applicationElement.getChild(0);
XmlElement metadataElement = metadataNode.getElement();
assertThat(metadataElement.getName()).isEqualTo("meta-data");
assertThat(metadataElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, name), valueAttr);
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method removeSplitNameService.
@Test
public void removeSplitNameService() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withSplitNameService("FooService", "foo")));
AndroidManifest editedManifest = manifest.toEditor().removeSplitName().save();
ImmutableList<XmlElement> services = editedManifest.getManifestElement().getChildElement("application").getChildrenElements(SERVICE_ELEMENT_NAME).map(XmlProtoElement::getProto).collect(toImmutableList());
assertThat(services).hasSize(1);
XmlElement serviceElement = Iterables.getOnlyElement(services);
assertThat(serviceElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID, "FooService"));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setFeatureSplit_forNonBaseSplit.
@Test
public void setFeatureSplit_forNonBaseSplit() throws Exception {
AndroidManifest androidManifest = createManifestWithApplicationElement();
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 removeUnknownSplits_keepsKnownSplits.
@Test
public void removeUnknownSplits_keepsKnownSplits() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withSplitNameProvider("FooProvider", "foo")));
AndroidManifest editedManifest = manifest.toEditor().removeUnknownSplitComponents(ImmutableSet.of("foo")).save();
ImmutableList<XmlElement> providers = editedManifest.getManifestElement().getChildElement("application").getChildrenElements(PROVIDER_ELEMENT_NAME).map(XmlProtoElement::getProto).collect(toImmutableList());
assertThat(providers).hasSize(1);
XmlElement providerElement = Iterables.getOnlyElement(providers);
assertThat(providerElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, NAME_ATTRIBUTE_NAME, NAME_RESOURCE_ID, "FooProvider"), xmlAttribute(ANDROID_NAMESPACE_URI, SPLIT_NAME_ATTRIBUTE_NAME, SPLIT_NAME_RESOURCE_ID, "foo"));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method removeSplitAndIsFeatureSplit_forBaseSplit.
@Test
public void removeSplitAndIsFeatureSplit_forBaseSplit() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", ImmutableList.of(xmlAttribute("split", "differentSplit"), xmlBooleanAttribute(ANDROID_NAMESPACE_URI, "isFeatureSplit", IS_FEATURE_SPLIT_RESOURCE_ID, true)), xmlNode(xmlElement("application")))));
AndroidManifest editedManifest = androidManifest.toEditor().setSplitIdForFeatureSplit("").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()).isEmpty();
}
Aggregations