use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setMinSdkVersion_existingAttribute_adjusted.
@Test
public void setMinSdkVersion_existingAttribute_adjusted() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("uses-sdk", xmlDecimalIntegerAttribute(ANDROID_NAMESPACE_URI, "minSdkVersion", MIN_SDK_VERSION_RESOURCE_ID, 1))))));
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 setHasCode_false.
@Test
public void setHasCode_false() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setHasCode(false).save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.hasElement()).isTrue();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getChildCount()).isEqualTo(1);
XmlNode applicationNode = manifestElement.getChild(0);
assertThat(applicationNode.hasElement()).isTrue();
XmlElement applicationElement = manifestElement.getChild(0).getElement();
assertThat(applicationElement.getAttributeList()).containsExactly(xmlBooleanAttribute(ANDROID_NAMESPACE_URI, "hasCode", HAS_CODE_RESOURCE_ID, false));
assertThat(applicationElement.getChildList()).isEmpty();
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setSplitId.
@Test
public void setSplitId() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setSplitId("feature1.config.x86").save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.hasElement()).isTrue();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getAttributeList()).containsExactly(xmlAttribute("split", "feature1.config.x86"));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setFeatureSplit_forDynamicSplit_duplicateSplitId.
/**
* Tests regression where we didn't handle properly manifests with already populated split id.
*/
@Test
public void setFeatureSplit_forDynamicSplit_duplicateSplitId() throws Exception {
AndroidManifest androidManifest = AndroidManifest.create(xmlNode(xmlElement("manifest", ImmutableList.of(xmlAttribute("split", "feature1"), xmlAttribute("package", "com.test.app"), xmlAttribute("split", "feature1")), 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"), xmlAttribute("package", "com.test.app"), xmlAttribute("split", "feature1"));
}
use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestEditorTest method setTargetSandboxVersion.
@Test
public void setTargetSandboxVersion() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setTargetSandboxVersion(2).save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.hasElement()).isTrue();
XmlElement manifestElement = manifestRoot.getElement();
assertThat(manifestElement.getName()).isEqualTo("manifest");
assertThat(manifestElement.getAttributeList()).containsExactly(xmlDecimalIntegerAttribute(ANDROID_NAMESPACE_URI, "targetSandboxVersion", TARGET_SANDBOX_VERSION_RESOURCE_ID, 2));
}
Aggregations