use of com.android.aapt.Resources.XmlElement in project bundletool by google.
the class ManifestProtoUtilsTest method splitNameAttributeAddedToActivity.
@Test
public void splitNameAttributeAddedToActivity() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "foo")));
ImmutableList<XmlElement> activities = manifest.getManifestRoot().getElement().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_ATTRIBUTE_NAME, NAME_RESOURCE_ID, "FooActivity"), 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 ManifestProtoUtilsTest method splitNameAttributeAddedToService.
@Test
public void splitNameAttributeAddedToService() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withSplitNameService("FooService", "foo")));
ImmutableList<XmlElement> services = manifest.getManifestRoot().getElement().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"), 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 ModuleSplitterTest method splitNameRemovedForInstalledSplit.
@Test
public void splitNameRemovedForInstalledSplit() throws Exception {
XmlNode manifest = androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "foo"));
BundleModule bundleModule = new BundleModuleBuilder("testModule").setManifest(manifest).build();
ImmutableList<ModuleSplit> moduleSplits = ModuleSplitter.createForTest(bundleModule, BUNDLETOOL_VERSION).splitModule();
assertThat(moduleSplits).hasSize(1);
ModuleSplit masterSplit = moduleSplits.get(0);
ImmutableList<XmlElement> activities = masterSplit.getAndroidManifest().getManifestRoot().getElement().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"));
}
use of com.android.aapt.Resources.XmlElement 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.XmlElement in project bundletool by google.
the class ManifestEditorTest method removeSplitNameProvider.
@Test
public void removeSplitNameProvider() {
AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withSplitNameProvider("FooProvider", "foo")));
AndroidManifest editedManifest = manifest.toEditor().removeSplitName().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"));
}
Aggregations