Search in sources :

Example 66 with XmlElement

use of com.android.aapt.Resources.XmlElement in project bundletool by google.

the class ModuleSplitterTest method nonInstantActivityRemovedForInstantManifest.

@Test
public void nonInstantActivityRemovedForInstantManifest() throws Exception {
    XmlNode manifest = androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "onDemandModule"));
    BundleModule bundleModule = new BundleModuleBuilder("onDemandModule").setManifest(manifest).build();
    ImmutableList<ModuleSplit> moduleSplits = ModuleSplitter.createNoStamp(bundleModule, BUNDLETOOL_VERSION, APP_BUNDLE, ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build(), lPlusVariantTargeting(), ImmutableSet.of()).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(1);
    XmlElement activityElement = activities.get(0);
    assertThat(activityElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, "MainActivity"));
}
Also used : XmlNode(com.android.aapt.Resources.XmlNode) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) XmlElement(com.android.aapt.Resources.XmlElement) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 67 with XmlElement

use of com.android.aapt.Resources.XmlElement in project bundletool by google.

the class ManifestProtoUtilsTest method splitNameAttributeAddedToProvider.

@Test
public void splitNameAttributeAddedToProvider() {
    AndroidManifest manifest = AndroidManifest.create(androidManifest("com.test.app", withSplitNameProvider("FooProvider", "foo")));
    ImmutableList<XmlElement> providers = manifest.getManifestRoot().getElement().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"), xmlAttribute(ANDROID_NAMESPACE_URI, SPLIT_NAME_ATTRIBUTE_NAME, SPLIT_NAME_RESOURCE_ID, "foo"));
}
Also used : XmlElement(com.android.aapt.Resources.XmlElement) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) Test(org.junit.Test)

Aggregations

XmlElement (com.android.aapt.Resources.XmlElement)67 Test (org.junit.Test)65 XmlNode (com.android.aapt.Resources.XmlNode)27 XmlAttribute (com.android.aapt.Resources.XmlAttribute)10 BundleModule (com.android.tools.build.bundletool.model.BundleModule)4 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)4 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)4 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 Truth.assertThat (com.google.common.truth.Truth.assertThat)4 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)4 ProtoTruth.assertThat (com.google.common.truth.extensions.proto.ProtoTruth.assertThat)4 RunWith (org.junit.runner.RunWith)4 JUnit4 (org.junit.runners.JUnit4)4 SourcePosition (com.android.aapt.Resources.SourcePosition)3 XmlNamespace (com.android.aapt.Resources.XmlNamespace)2 TestData (com.android.tools.build.bundletool.TestData)2 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)2 ACTIVITY_ELEMENT_NAME (com.android.tools.build.bundletool.model.AndroidManifest.ACTIVITY_ELEMENT_NAME)2 ALLOW_BACKUP_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_ATTRIBUTE_NAME)2