use of com.android.aapt.Resources.XmlNode 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.XmlNode 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));
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method setSharedUserLabel.
@Test
public void setSharedUserLabel() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setSharedUserLabel(0x12345678).save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.getElement().getAttributeList()).containsExactly(xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, SHARED_USER_LABEL_ATTRIBUTE_NAME, SHARED_USER_LABEL_RESOURCE_ID, 0x12345678));
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method setHasCode_true.
@Test
public void setHasCode_true() throws Exception {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setHasCode(true).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, true));
assertThat(applicationElement.getChildList()).isEmpty();
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class DumpManagerTest method dumpManifest_withXPath_noNamespaceDeclaration.
@Test
public void dumpManifest_withXPath_noNamespaceDeclaration() throws Exception {
XmlNode manifestWithoutNamespaceDeclaration = androidManifest("com.app", withDebuggableAttribute(true), manifestElement -> manifestElement.getProto().clearNamespaceDeclaration());
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(manifestWithoutNamespaceDeclaration)).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.MANIFEST).setXPathExpression("/manifest/application/@android:debuggable").setOutputStream(new PrintStream(outputStream)).build().execute();
assertThat(new String(outputStream.toByteArray(), UTF_8).trim()).isEqualTo("true");
}
Aggregations