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");
}
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");
}
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");
}
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));
}
Aggregations