Search in sources :

Example 1 with Source

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

the class ResourceTableMergerTest method sourcePools_equal_sourceReferencesPreserved.

@Test
public void sourcePools_equal_sourceReferencesPreserved() throws Exception {
    StringPool commonSourcePool = StringPool.newBuilder().setData(ByteString.copyFrom(DUMMY_BYTES)).build();
    Source source1 = Source.newBuilder().setPathIdx(42).build();
    Source source2 = Source.newBuilder().setPathIdx(24).build();
    ResourceTable table1 = resourceTable(commonSourcePool, pkg(0x01, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI, source1)))));
    ResourceTable table2 = resourceTable(commonSourcePool, pkg(0x02, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI, source2)))));
    ResourceTable merged = new ResourceTableMerger().merge(table1, table2);
    assertThat(merged).ignoringRepeatedFieldOrder().isEqualTo(resourceTable(commonSourcePool, pkg(0x01, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI, source1)))), pkg(0x02, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI, source2))))));
}
Also used : StringPool(com.android.aapt.Resources.StringPool) Source(com.android.aapt.Resources.Source) ResourceTable(com.android.aapt.Resources.ResourceTable) Test(org.junit.Test)

Example 2 with Source

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

the class ResourceTableMergerTest method sourcePools_different_sourceReferencesInSecondTableStripped.

@Test
public void sourcePools_different_sourceReferencesInSecondTableStripped() throws Exception {
    Source source1 = Source.newBuilder().setPathIdx(42).build();
    Source source2 = Source.newBuilder().setPathIdx(24).build();
    ResourceTable table1 = resourceTable(pkg(0x01, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI, source1)))));
    ResourceTable table2 = resourceTable(StringPool.newBuilder().setData(ByteString.copyFrom(DUMMY_BYTES)).build(), pkg(0x02, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI, source2)))));
    ResourceTable merged = new ResourceTableMerger().merge(table1, table2);
    assertThat(merged).ignoringRepeatedFieldOrder().isEqualTo(resourceTable(pkg(0x01, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI, source1)))), pkg(0x02, "package", type(0x11, "type", entry(0x21, "entry", value("ldpi", LDPI))))));
}
Also used : Source(com.android.aapt.Resources.Source) ResourceTable(com.android.aapt.Resources.ResourceTable) Test(org.junit.Test)

Aggregations

ResourceTable (com.android.aapt.Resources.ResourceTable)2 Source (com.android.aapt.Resources.Source)2 Test (org.junit.Test)2 StringPool (com.android.aapt.Resources.StringPool)1