Search in sources :

Example 11 with XmlAttribute

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

the class ManifestEditorTest method copyPermissionGroups.

@Test
public void copyPermissionGroups() throws Exception {
    XmlElement permisisonGroupElement = xmlElement("permission-group", xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, "group.1"));
    AndroidManifest manifestWithPermissionGroups = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(permisisonGroupElement))));
    AndroidManifest manifestToUpdate = AndroidManifest.create(androidManifest("com.test.app"));
    AndroidManifest updatedManifest = manifestToUpdate.toEditor().copyPermissionGroups(manifestWithPermissionGroups).save();
    ImmutableList<XmlElement> copiedPermissionGroups = updatedManifest.getManifestRoot().getProto().getElement().getChildList().stream().map(XmlNode::getElement).filter(childElement -> childElement.getName().equals("permission-group")).collect(toImmutableList());
    assertThat(copiedPermissionGroups).containsExactly(permisisonGroupElement);
}
Also used : ManifestProtoUtils.xmlBooleanAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlBooleanAttribute) VERSION_CODE_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.VERSION_CODE_RESOURCE_ID) ManifestProtoUtils.withSplitNameActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameActivity) DESCRIPTION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_RESOURCE_ID) ManifestProtoUtils.xmlDecimalIntegerAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlDecimalIntegerAttribute) SHARED_USER_ID_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_ID_RESOURCE_ID) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) TARGET_SANDBOX_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.TARGET_SANDBOX_VERSION_RESOURCE_ID) ManifestProtoUtils.withSplitNameProvider(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameProvider) ManifestProtoUtils.xmlAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlAttribute) XmlAttribute(com.android.aapt.Resources.XmlAttribute) DATA_EXTRACTION_RULES_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_RESOURCE_ID) XmlProtoAttribute(com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoAttribute) PROVIDER_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.PROVIDER_ELEMENT_NAME) NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.NAME_RESOURCE_ID) SPLIT_NAME_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SPLIT_NAME_ATTRIBUTE_NAME) TextFormat(com.google.protobuf.TextFormat) SPLIT_NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SPLIT_NAME_RESOURCE_ID) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) DATA_EXTRACTION_RULES_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_ATTRIBUTE_NAME) ManifestProtoUtils.xmlElement(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlElement) DESCRIPTION_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_ATTRIBUTE_NAME) LABEL_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.LABEL_ATTRIBUTE_NAME) VALUE_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.VALUE_RESOURCE_ID) FULL_BACKUP_CONTENT_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_ATTRIBUTE_NAME) LOCALE_CONFIG_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.LOCALE_CONFIG_RESOURCE_ID) FULL_BACKUP_ONLY_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_RESOURCE_ID) ManifestProtoUtils.withOnDemandAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withOnDemandAttribute) ManifestProtoUtils.xmlResourceReferenceAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlResourceReferenceAttribute) HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME) LOCALE_CONFIG_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.LOCALE_CONFIG_ATTRIBUTE_NAME) IS_GAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.IS_GAME_RESOURCE_ID) ICON_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.ICON_RESOURCE_ID) LABEL_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.LABEL_RESOURCE_ID) ICON_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ICON_ATTRIBUTE_NAME) Iterables(com.google.common.collect.Iterables) Activity(com.android.tools.build.bundletool.model.manifestelements.Activity) ALLOW_BACKUP_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_ATTRIBUTE_NAME) RunWith(org.junit.runner.RunWith) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) ACTIVITY_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ACTIVITY_ELEMENT_NAME) IS_GAME_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.IS_GAME_ATTRIBUTE_NAME) MAX_SDK_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.MAX_SDK_VERSION_RESOURCE_ID) ManifestProtoUtils.withSplitNameService(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameService) XmlProtoElement(com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoElement) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ManifestProtoUtils.xmlNode(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlNode) MIN_SDK_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.MIN_SDK_VERSION_RESOURCE_ID) IS_FEATURE_SPLIT_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.IS_FEATURE_SPLIT_RESOURCE_ID) SHARED_USER_LABEL_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_LABEL_ATTRIBUTE_NAME) TARGET_SDK_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.TARGET_SDK_VERSION_RESOURCE_ID) Receiver(com.android.tools.build.bundletool.model.manifestelements.Receiver) TestData(com.android.tools.build.bundletool.TestData) Test(org.junit.Test) FULL_BACKUP_CONTENT_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_RESOURCE_ID) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) HAS_FRAGILE_USER_DATA_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_RESOURCE_ID) SHARED_USER_LABEL_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_LABEL_RESOURCE_ID) SHARED_USER_ID_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_ID_ATTRIBUTE_NAME) XmlNode(com.android.aapt.Resources.XmlNode) IS_SPLIT_REQUIRED_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.IS_SPLIT_REQUIRED_ATTRIBUTE_NAME) SERVICE_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SERVICE_ELEMENT_NAME) ManifestProtoUtils.withMainActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMainActivity) FULL_BACKUP_ONLY_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_ATTRIBUTE_NAME) HAS_CODE_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.HAS_CODE_RESOURCE_ID) XmlElement(com.android.aapt.Resources.XmlElement) IS_SPLIT_REQUIRED_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.IS_SPLIT_REQUIRED_RESOURCE_ID) ALLOW_BACKUP_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_RESOURCE_ID) NAME_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.NAME_ATTRIBUTE_NAME) XmlNode(com.android.aapt.Resources.XmlNode) XmlElement(com.android.aapt.Resources.XmlElement) Test(org.junit.Test)

Example 12 with XmlAttribute

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

the class ManifestEditorTest method copyPermissions.

@Test
public void copyPermissions() throws Exception {
    XmlElement permisisonElement = xmlElement("permission", xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, "SEND_SMS"));
    AndroidManifest manifestWithPermissions = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(permisisonElement))));
    AndroidManifest manifestToUpdate = AndroidManifest.create(androidManifest("com.test.app"));
    AndroidManifest updatedManifest = manifestToUpdate.toEditor().copyPermissions(manifestWithPermissions).save();
    ImmutableList<XmlElement> copiedPermissions = updatedManifest.getManifestRoot().getProto().getElement().getChildList().stream().map(XmlNode::getElement).filter(childElement -> childElement.getName().equals("permission")).collect(toImmutableList());
    assertThat(copiedPermissions).containsExactly(permisisonElement);
}
Also used : ManifestProtoUtils.xmlBooleanAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlBooleanAttribute) VERSION_CODE_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.VERSION_CODE_RESOURCE_ID) ManifestProtoUtils.withSplitNameActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameActivity) DESCRIPTION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_RESOURCE_ID) ManifestProtoUtils.xmlDecimalIntegerAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlDecimalIntegerAttribute) SHARED_USER_ID_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_ID_RESOURCE_ID) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) TARGET_SANDBOX_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.TARGET_SANDBOX_VERSION_RESOURCE_ID) ManifestProtoUtils.withSplitNameProvider(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameProvider) ManifestProtoUtils.xmlAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlAttribute) XmlAttribute(com.android.aapt.Resources.XmlAttribute) DATA_EXTRACTION_RULES_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_RESOURCE_ID) XmlProtoAttribute(com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoAttribute) PROVIDER_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.PROVIDER_ELEMENT_NAME) NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.NAME_RESOURCE_ID) SPLIT_NAME_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SPLIT_NAME_ATTRIBUTE_NAME) TextFormat(com.google.protobuf.TextFormat) SPLIT_NAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SPLIT_NAME_RESOURCE_ID) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) DATA_EXTRACTION_RULES_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_ATTRIBUTE_NAME) ManifestProtoUtils.xmlElement(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlElement) DESCRIPTION_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_ATTRIBUTE_NAME) LABEL_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.LABEL_ATTRIBUTE_NAME) VALUE_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.VALUE_RESOURCE_ID) FULL_BACKUP_CONTENT_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_ATTRIBUTE_NAME) LOCALE_CONFIG_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.LOCALE_CONFIG_RESOURCE_ID) FULL_BACKUP_ONLY_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_RESOURCE_ID) ManifestProtoUtils.withOnDemandAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withOnDemandAttribute) ManifestProtoUtils.xmlResourceReferenceAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlResourceReferenceAttribute) HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME) LOCALE_CONFIG_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.LOCALE_CONFIG_ATTRIBUTE_NAME) IS_GAME_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.IS_GAME_RESOURCE_ID) ICON_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.ICON_RESOURCE_ID) LABEL_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.LABEL_RESOURCE_ID) ICON_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ICON_ATTRIBUTE_NAME) Iterables(com.google.common.collect.Iterables) Activity(com.android.tools.build.bundletool.model.manifestelements.Activity) ALLOW_BACKUP_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_ATTRIBUTE_NAME) RunWith(org.junit.runner.RunWith) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) ACTIVITY_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.ACTIVITY_ELEMENT_NAME) IS_GAME_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.IS_GAME_ATTRIBUTE_NAME) MAX_SDK_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.MAX_SDK_VERSION_RESOURCE_ID) ManifestProtoUtils.withSplitNameService(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameService) XmlProtoElement(com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoElement) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ManifestProtoUtils.xmlNode(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlNode) MIN_SDK_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.MIN_SDK_VERSION_RESOURCE_ID) IS_FEATURE_SPLIT_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.IS_FEATURE_SPLIT_RESOURCE_ID) SHARED_USER_LABEL_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_LABEL_ATTRIBUTE_NAME) TARGET_SDK_VERSION_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.TARGET_SDK_VERSION_RESOURCE_ID) Receiver(com.android.tools.build.bundletool.model.manifestelements.Receiver) TestData(com.android.tools.build.bundletool.TestData) Test(org.junit.Test) FULL_BACKUP_CONTENT_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_RESOURCE_ID) JUnit4(org.junit.runners.JUnit4) Truth.assertThat(com.google.common.truth.Truth.assertThat) HAS_FRAGILE_USER_DATA_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_RESOURCE_ID) SHARED_USER_LABEL_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_LABEL_RESOURCE_ID) SHARED_USER_ID_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SHARED_USER_ID_ATTRIBUTE_NAME) XmlNode(com.android.aapt.Resources.XmlNode) IS_SPLIT_REQUIRED_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.IS_SPLIT_REQUIRED_ATTRIBUTE_NAME) SERVICE_ELEMENT_NAME(com.android.tools.build.bundletool.model.AndroidManifest.SERVICE_ELEMENT_NAME) ManifestProtoUtils.withMainActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMainActivity) FULL_BACKUP_ONLY_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_ATTRIBUTE_NAME) HAS_CODE_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.HAS_CODE_RESOURCE_ID) XmlElement(com.android.aapt.Resources.XmlElement) IS_SPLIT_REQUIRED_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.IS_SPLIT_REQUIRED_RESOURCE_ID) ALLOW_BACKUP_RESOURCE_ID(com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_RESOURCE_ID) NAME_ATTRIBUTE_NAME(com.android.tools.build.bundletool.model.AndroidManifest.NAME_ATTRIBUTE_NAME) XmlNode(com.android.aapt.Resources.XmlNode) XmlElement(com.android.aapt.Resources.XmlElement) Test(org.junit.Test)

Example 13 with XmlAttribute

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

the class XmlProtoElementBuilderTest method getAttributeIgnoringNamespace_duplicate.

@Test
public void getAttributeIgnoringNamespace_duplicate() {
    XmlAttribute attribute = XmlAttribute.newBuilder().setName("attribute").build();
    XmlElement protoElement = XmlElement.newBuilder().addAttribute(attribute).addAttribute(attribute).build();
    XmlProtoElementBuilder element = new XmlProtoElementBuilder(protoElement.toBuilder());
    XmlProtoAttributeBuilder fetchedAttribute = element.getAttributeIgnoringNamespace("attribute").get();
    assertThat(fetchedAttribute.getProto().build()).isEqualTo(attribute);
    assertThat(element.getProto().build()).isEqualTo(protoElement);
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) XmlElement(com.android.aapt.Resources.XmlElement) Test(org.junit.Test)

Example 14 with XmlAttribute

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

the class XmlProtoElementBuilderTest method getOrCreateAndroidAttribute_attributeDoesNotExist.

@Test
public void getOrCreateAndroidAttribute_attributeDoesNotExist() {
    XmlAttribute attributeNotAndroid = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").setResourceId(0x123).build();
    XmlAttribute attributeAndroid = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri(ANDROID_NAMESPACE_URI).setResourceId(0x123).build();
    XmlAttribute attributeNoNamespace = XmlAttribute.newBuilder().setName("attribute").setResourceId(0x123).build();
    XmlProtoElementBuilder element = new XmlProtoElementBuilder(XmlElement.newBuilder().addAttribute(attributeNotAndroid).addAttribute(attributeNoNamespace));
    XmlProtoAttributeBuilder fetchedAttribute = element.getOrCreateAndroidAttribute("attribute", 0x123);
    assertThat(fetchedAttribute.getProto().build()).isEqualTo(attributeAndroid);
    assertThat(element.getProto().build()).isEqualTo(XmlElement.newBuilder().addAttribute(attributeNotAndroid).addAttribute(attributeNoNamespace).addAttribute(attributeAndroid).build());
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) Test(org.junit.Test)

Example 15 with XmlAttribute

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

the class XmlProtoElementBuilderTest method getOrCreateAttribute_attributeDiffersByNamespace.

@Test
public void getOrCreateAttribute_attributeDiffersByNamespace() {
    XmlAttribute attrWithoutNamespace = XmlAttribute.newBuilder().setName("attribute").build();
    XmlAttribute attrWithNamespace = XmlAttribute.newBuilder().setName("attribute").setNamespaceUri("namespace").build();
    XmlProtoElementBuilder element = new XmlProtoElementBuilder(XmlElement.newBuilder().addAttribute(attrWithNamespace));
    XmlProtoAttributeBuilder fetchedAttribute = element.getOrCreateAttribute("attribute");
    assertThat(fetchedAttribute.getProto().build()).isEqualTo(attrWithoutNamespace);
    assertThat(element.getProto().build()).isEqualTo(XmlElement.newBuilder().addAttribute(attrWithNamespace).addAttribute(attrWithoutNamespace).build());
}
Also used : XmlAttribute(com.android.aapt.Resources.XmlAttribute) Test(org.junit.Test)

Aggregations

XmlAttribute (com.android.aapt.Resources.XmlAttribute)20 Test (org.junit.Test)20 XmlElement (com.android.aapt.Resources.XmlElement)8 XmlNode (com.android.aapt.Resources.XmlNode)2 TestData (com.android.tools.build.bundletool.TestData)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 ALLOW_BACKUP_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.ALLOW_BACKUP_RESOURCE_ID)2 DATA_EXTRACTION_RULES_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_ATTRIBUTE_NAME)2 DATA_EXTRACTION_RULES_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.DATA_EXTRACTION_RULES_RESOURCE_ID)2 DESCRIPTION_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_ATTRIBUTE_NAME)2 DESCRIPTION_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.DESCRIPTION_RESOURCE_ID)2 FULL_BACKUP_CONTENT_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_ATTRIBUTE_NAME)2 FULL_BACKUP_CONTENT_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_CONTENT_RESOURCE_ID)2 FULL_BACKUP_ONLY_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_ATTRIBUTE_NAME)2 FULL_BACKUP_ONLY_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.FULL_BACKUP_ONLY_RESOURCE_ID)2 HAS_CODE_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.HAS_CODE_RESOURCE_ID)2 HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_ATTRIBUTE_NAME)2 HAS_FRAGILE_USER_DATA_RESOURCE_ID (com.android.tools.build.bundletool.model.AndroidManifest.HAS_FRAGILE_USER_DATA_RESOURCE_ID)2 ICON_ATTRIBUTE_NAME (com.android.tools.build.bundletool.model.AndroidManifest.ICON_ATTRIBUTE_NAME)2