use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method setVersionCode.
@Test
public void setVersionCode() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setVersionCode(123).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, "versionCode", VERSION_CODE_RESOURCE_ID, 123));
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method setSharedUserId.
@Test
public void setSharedUserId() {
AndroidManifest androidManifest = createManifestWithApplicationElement();
AndroidManifest editedManifest = androidManifest.toEditor().setSharedUserId("shared_user_id").save();
XmlNode manifestRoot = editedManifest.getManifestRoot().getProto();
assertThat(manifestRoot.getElement().getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, SHARED_USER_ID_ATTRIBUTE_NAME, SHARED_USER_ID_RESOURCE_ID, "shared_user_id"));
}
use of com.android.aapt.Resources.XmlNode in project bundletool by google.
the class ManifestEditorTest method addActivity.
@Test
public void addActivity() throws Exception {
Activity activity = Activity.builder().setName("activityName").build();
XmlNode activityXmlNode = XmlNode.newBuilder().setElement(activity.asXmlProtoElement().getProto()).build();
AndroidManifest androidManifest = AndroidManifest.create(androidManifest("com.test.app"));
AndroidManifest editedManifest = androidManifest.toEditor().addActivity(activity).save();
assertThat(getApplicationElement(editedManifest).getChildList()).containsExactly(activityXmlNode);
}
use of com.android.aapt.Resources.XmlNode 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.XmlNode in project bundletool by google.
the class BundleModuleTest method correctProtoManifestFile_parsedAndReturned.
@Test
public void correctProtoManifestFile_parsedAndReturned() throws Exception {
XmlNode manifestXml = androidManifest("com.test.app");
BundleModule bundleModule = BundleModule.builder().setName(BundleModuleName.create("testModule")).setBundleConfig(DEFAULT_BUNDLE_CONFIG).addEntry(createModuleEntryForFile("manifest/AndroidManifest.xml", manifestXml.toByteArray())).build();
assertThat(bundleModule.getAndroidManifest().getManifestRoot().getProto()).isEqualTo(manifestXml);
}
Aggregations