use of com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI in project bundletool by google.
the class ScreenDensityResourcesSplitterTest method lowestDensityConfigsPinnedToMaster.
@Test
public void lowestDensityConfigsPinnedToMaster() throws Exception {
BundleModule testModule = new BundleModuleBuilder("testModule").addFile("res/drawable-mdpi/image.jpg").addFile("res/drawable-hdpi/image.jpg").addFile("res/drawable-mdpi/image2.jpg").addFile("res/drawable-hdpi/image2.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addDrawableResourceForMultipleDensities("image", ImmutableMap.of(/* mdpi */
160, "res/drawable-mdpi/image.jpg", /* hdpi */
240, "res/drawable-hdpi/image.jpg")).addDrawableResourceForMultipleDensities("image2", ImmutableMap.of(/* mdpi */
160, "res/drawable-mdpi/image2.jpg", /* hdpi */
240, "res/drawable-hdpi/image2.jpg")).build()).setManifest(androidManifest("com.test.app")).build();
Predicate<ResourceId> pinnedLowDensityResourcesPredicate = resourceId -> resourceId.getFullResourceId() == 0x7f010000;
ScreenDensityResourcesSplitter splitter = new ScreenDensityResourcesSplitter(BundleToolVersion.getCurrentVersion(), NO_RESOURCES_PINNED_TO_MASTER, pinnedLowDensityResourcesPredicate, /* pinLowestBucketOfStylesToMaster= */
false);
ImmutableCollection<ModuleSplit> densitySplits = splitter.split(ModuleSplit.forResources(testModule));
ModuleSplit masterSplit = densitySplits.stream().filter(split -> split.isMasterSplit()).collect(onlyElement());
assertThat(extractPaths(masterSplit.getEntries())).containsExactly("res/drawable-mdpi/image.jpg");
ImmutableList<ModuleSplit> configSplits = densitySplits.stream().filter(split -> !split.isMasterSplit()).collect(toImmutableList());
assertThat(configSplits).isNotEmpty();
for (ModuleSplit configSplit : configSplits) {
assertThat(extractPaths(configSplit.getEntries())).doesNotContain("res/drawable-mdpi/image.jpg");
}
}
Aggregations