use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setMinSdkVersion_nonExistingElement_created.
@Test
public void setMinSdkVersion_nonExistingElement_created() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest")));
AndroidManifest editedManifest = androidManifest.toEditor().setMinSdkVersion(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, "minSdkVersion", MIN_SDK_VERSION_RESOURCE_ID, 123))));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setFeatureSplitWithExistingSplit_forNonBaseSplit.
@Test
public void setFeatureSplitWithExistingSplit_forNonBaseSplit() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlAttribute("split", "differentSplit"), 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 setConfigForSplit.
@Test
public void setConfigForSplit() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setConfigForSplit("feature1").save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.hasElement()).isTrue();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getAttributeList()).containsExactly(xmlAttribute("configForSplit", "feature1"));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method copyPermissions.
@Test
public void copyPermissions() throws Exception {
XmlElement permisisonElement = xmlElement("permission", xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, "SEND_SMS"));
AndroidManifest manifestWithPermissions = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(permisisonElement))));
AndroidManifest manifestToUpdate = AndroidManifest.create(androidManifest("com.test.app"));
AndroidManifest updatedManifest = manifestToUpdate.toEditor().copyPermissions(manifestWithPermissions).save();
ImmutableList<XmlElement> copiedPermissions = updatedManifest.getManifestRoot().getProto().getElement().getChildList().stream().map(XmlNode::getElement).filter(childElement -> childElement.getName().equals("permission")).collect(toImmutableList());
assertThat(copiedPermissions).containsExactly(permisisonElement);
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ModuleSplitTest method splitNameRemoved.
@Test
public void splitNameRemoved() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "foo")));
ModuleSplit masterSplit = ModuleSplit.builder().setModuleName(BundleModuleName.create("base")).setApkTargeting(ApkTargeting.getDefaultInstance()).setVariantTargeting(lPlusVariantTargeting()).setMasterSplit(true).setAndroidManifest(manifest).build();
masterSplit = masterSplit.removeSplitName();
ImmutableList<XmlElement> activities = masterSplit.getAndroidManifest().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", NAME_RESOURCE_ID, "FooActivity"));
}
Aggregations