Search in sources :

Example 11 with Value

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

the class XmlProtoPrintUtilsTest method getValueTypeAsString_compoundValue.

@Test
public void getValueTypeAsString_compoundValue() {
    Value colorValue = Value.newBuilder().setCompoundValue(CompoundValue.newBuilder().setArray(Array.getDefaultInstance())).build();
    assertThat(XmlProtoPrintUtils.getValueTypeAsString(colorValue)).isEqualTo("ARRAY");
}
Also used : Value(com.android.aapt.Resources.Value) CompoundValue(com.android.aapt.Resources.CompoundValue) Test(org.junit.Test)

Example 12 with Value

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

the class XmlProtoPrintUtilsTest method getValueTypeAsString_color.

@Test
public void getValueTypeAsString_color() {
    Value colorValue = Value.newBuilder().setItem(Item.newBuilder().setPrim(Primitive.newBuilder().setColorArgb4Value(0))).build();
    assertThat(XmlProtoPrintUtils.getValueTypeAsString(colorValue)).isEqualTo("COLOR_ARGB4");
}
Also used : Value(com.android.aapt.Resources.Value) CompoundValue(com.android.aapt.Resources.CompoundValue) Test(org.junit.Test)

Example 13 with Value

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

the class XmlProtoPrintUtilsTest method getValueTypeAsString_boolean.

@Test
public void getValueTypeAsString_boolean() {
    Value booleanValue = Value.newBuilder().setItem(Item.newBuilder().setPrim(Primitive.newBuilder().setBooleanValue(false))).build();
    assertThat(XmlProtoPrintUtils.getValueTypeAsString(booleanValue)).isEqualTo("BOOLEAN");
}
Also used : Value(com.android.aapt.Resources.Value) CompoundValue(com.android.aapt.Resources.CompoundValue) Test(org.junit.Test)

Example 14 with Value

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

the class ResourceAnalyzerTest method transitive_item_xmlFileWithResourceReference.

@Test
public void transitive_item_xmlFileWithResourceReference() throws Exception {
    // AndroidManifest --> 0x7f010001 (xml file) --> 0x7f020002 (string)
    XmlNode manifest = AndroidManifest.create(xmlNode(xmlElement("manifest", xmlNode(xmlElement("application", xmlResourceReferenceAttribute(NO_NAMESPACE_URI, "attr_pointing_to_xml", /* attrResourceId= */
    0x999999, /* valueResourceId= */
    0x7f010001)))))).getManifestRoot().getProto();
    XmlNode embeddedXmlFile = AndroidManifest.create(xmlNode(xmlElement("root", xmlResourceReferenceAttribute(ANDROID_NAMESPACE_URI, "name", /* attrResourceId= */
    0x999999, /* valueResourceId= */
    0x7f020002)))).getManifestRoot().getProto();
    ResourceTable resourceTable = resourceTable(pkg(0x7f, "com.test.app", type(0x01, "file", entry(0x0001, "xml_file", fileReference("res/xml/embedded.xml", FileReference.Type.PROTO_XML, DEFAULT_CONFIG))), type(0x02, "string", entry(0x0002, "name_str", value("hello", DEFAULT_CONFIG)), entry(0x0099, "not_referenced", value("", DEFAULT_CONFIG)))));
    AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(manifest).setResourceTable(resourceTable).addFile("res/xml/embedded.xml", embeddedXmlFile.toByteArray())).build();
    ImmutableSet<ResourceId> resourceIds = new ResourceAnalyzer(appBundle).findAllAppResourcesReachableFromBaseManifest();
    assertThat(resourceIds).containsExactly(ResourceId.create(0x7f010001), ResourceId.create(0x7f020002));
}
Also used : RawString(com.android.aapt.Resources.RawString) Value(com.android.aapt.Resources.Value) String(com.android.aapt.Resources.String) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) RunWith(org.junit.runner.RunWith) Primitive(com.android.aapt.Resources.Primitive) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) Symbol(com.android.aapt.Resources.Attribute.Symbol) ANDROID_NAMESPACE_URI(com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI) ManifestProtoUtils.xmlCompiledItemAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlCompiledItemAttribute) Item(com.android.aapt.Resources.Item) ResourceId(com.android.tools.build.bundletool.model.ResourceId) ImmutableList(com.google.common.collect.ImmutableList) Theories(org.junit.experimental.theories.Theories) ResourcesTableFactory.reference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.reference) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) Attribute(com.android.aapt.Resources.Attribute) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) ResourceTable(com.android.aapt.Resources.ResourceTable) Nullable(javax.annotation.Nullable) StyledString(com.android.aapt.Resources.StyledString) ManifestProtoUtils.xmlNode(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlNode) ImmutableSet(com.google.common.collect.ImmutableSet) Style(com.android.aapt.Resources.Style) ResourcesTableFactory.value(com.android.tools.build.bundletool.testing.ResourcesTableFactory.value) ConfigValue(com.android.aapt.Resources.ConfigValue) Reference(com.android.aapt.Resources.Reference) Test(org.junit.Test) NO_NAMESPACE_URI(com.android.tools.build.bundletool.model.AndroidManifest.NO_NAMESPACE_URI) ManifestProtoUtils.xmlElement(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlElement) Truth.assertThat(com.google.common.truth.Truth.assertThat) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) CompoundValue(com.android.aapt.Resources.CompoundValue) Id(com.android.aapt.Resources.Id) FileReference(com.android.aapt.Resources.FileReference) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ManifestProtoUtils.xmlResourceReferenceAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.xmlResourceReferenceAttribute) XmlNode(com.android.aapt.Resources.XmlNode) AppBundle(com.android.tools.build.bundletool.model.AppBundle) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) XmlNode(com.android.aapt.Resources.XmlNode) AppBundle(com.android.tools.build.bundletool.model.AppBundle) ResourceId(com.android.tools.build.bundletool.model.ResourceId) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ResourceTable(com.android.aapt.Resources.ResourceTable) Test(org.junit.Test)

Aggregations

CompoundValue (com.android.aapt.Resources.CompoundValue)14 Value (com.android.aapt.Resources.Value)14 Test (org.junit.Test)14 Configuration (com.android.aapt.ConfigurationOuterClass.Configuration)10 Attribute (com.android.aapt.Resources.Attribute)10 Symbol (com.android.aapt.Resources.Attribute.Symbol)10 ConfigValue (com.android.aapt.Resources.ConfigValue)10 FileReference (com.android.aapt.Resources.FileReference)10 Id (com.android.aapt.Resources.Id)10 Item (com.android.aapt.Resources.Item)10 Primitive (com.android.aapt.Resources.Primitive)10 RawString (com.android.aapt.Resources.RawString)10 Reference (com.android.aapt.Resources.Reference)10 ResourceTable (com.android.aapt.Resources.ResourceTable)10 String (com.android.aapt.Resources.String)10 Style (com.android.aapt.Resources.Style)10 StyledString (com.android.aapt.Resources.StyledString)10 XmlNode (com.android.aapt.Resources.XmlNode)10 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)10 ANDROID_NAMESPACE_URI (com.android.tools.build.bundletool.model.AndroidManifest.ANDROID_NAMESPACE_URI)10