use of com.android.aapt.Resources.CompoundValue in project bundletool by google.
the class ResourceAnalyzer method transitiveClosure.
private ImmutableSet<ResourceId> transitiveClosure(ImmutableSet<ResourceId> anchorResources) throws IOException {
Set<ResourceId> referencedResources = new HashSet<>();
Queue<ResourceId> resourcesToInspect = new ArrayDeque<>();
resourcesToInspect.addAll(anchorResources);
while (!resourcesToInspect.isEmpty()) {
ResourceId resourceId = resourcesToInspect.remove();
if (referencedResources.contains(resourceId) || !baseModuleResourcesById.containsKey(resourceId)) {
continue;
}
referencedResources.add(resourceId);
ResourceTableEntry resourceEntry = baseModuleResourcesById.get(resourceId);
for (ConfigValue configValue : resourceEntry.getEntry().getConfigValueList()) {
switch(configValue.getValue().getValueCase()) {
case ITEM:
Item item = configValue.getValue().getItem();
resourcesToInspect.addAll(findAllReferencedAppResources(item));
break;
case COMPOUND_VALUE:
CompoundValue compoundValue = configValue.getValue().getCompoundValue();
resourcesToInspect.addAll(findAllReferencedAppResources(compoundValue));
break;
case VALUE_NOT_SET:
}
}
}
return ImmutableSet.copyOf(referencedResources);
}
use of com.android.aapt.Resources.CompoundValue in project bundletool by google.
the class ResourceTableMergerTest method stripSourceReferences_inOneofField_strips.
@Test
public void stripSourceReferences_inOneofField_strips() throws Exception {
CompoundValue withoutSource = CompoundValue.newBuilder().setStyle(Style.newBuilder().setParent(Reference.newBuilder().setName("dad")).addEntry(Style.Entry.newBuilder().setComment("comment"))).build();
CompoundValue.Builder withSourceBuilder = withoutSource.toBuilder();
withSourceBuilder.getStyleBuilder().setParentSource(Source.newBuilder().setPathIdx(42));
CompoundValue withSource = withSourceBuilder.build();
assertThat(withSource).isNotEqualTo(withoutSource);
CompoundValue.Builder stripped = withSource.toBuilder();
ResourceTableMerger.stripSourceReferences(stripped);
assertThat(stripped.build()).isEqualTo(withoutSource);
}
use of com.android.aapt.Resources.CompoundValue in project bundletool by google.
the class XmlProtoPrintUtilsTest method getCompoundValueAsString_style.
@Test
public void getCompoundValueAsString_style() {
CompoundValue compoundValue = CompoundValue.newBuilder().setStyle(Style.newBuilder().addEntry(Style.Entry.newBuilder().setItem(createItem("name1"))).addEntry(Style.Entry.newBuilder().setItem(createItem("name2")))).build();
assertThat(XmlProtoPrintUtils.getCompoundValueAsString(compoundValue)).isEqualTo("[\"name1\", \"name2\"]");
}
use of com.android.aapt.Resources.CompoundValue in project bundletool by google.
the class XmlProtoPrintUtilsTest method getCompoundValueAsString_array.
@Test
public void getCompoundValueAsString_array() {
CompoundValue compoundValue = CompoundValue.newBuilder().setArray(Array.newBuilder().addElement(Element.newBuilder().setItem(createItem("name1"))).addElement(Element.newBuilder().setItem(createItem("name2")))).build();
assertThat(XmlProtoPrintUtils.getCompoundValueAsString(compoundValue)).isEqualTo("[\"name1\", \"name2\"]");
}
use of com.android.aapt.Resources.CompoundValue in project bundletool by google.
the class XmlProtoPrintUtilsTest method getCompoundValueAsString_styleable.
@Test
public void getCompoundValueAsString_styleable() {
CompoundValue compoundValue = CompoundValue.newBuilder().setStyleable(Styleable.newBuilder().addEntry(Styleable.Entry.newBuilder().setAttr(createReference("name1"))).addEntry(Styleable.Entry.newBuilder().setAttr(createReference("name2")))).build();
assertThat(XmlProtoPrintUtils.getCompoundValueAsString(compoundValue)).isEqualTo("[@name1, @name2]");
}
Aggregations