Search in sources :

Example 1 with LDPI

use of com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI in project bundletool by google.

the class ScreenDensityResourcesSplitterTest method lowestDensityConfigsPinnedToMaster_mixedConfigsInSameDensityBucket.

@Test
public void lowestDensityConfigsPinnedToMaster_mixedConfigsInSameDensityBucket() throws Exception {
    BundleModule testModule = new BundleModuleBuilder("testModule").addFile("res/drawable-ldpi/image.jpg").addFile("res/drawable-ldpi-v21/image.jpg").addFile("res/drawable-ldpi-v24/image.jpg").addFile("res/drawable-xxhdpi/image.jpg").addFile("res/drawable-xxhdpi-v21/image.jpg").addFile("res/drawable-xxhdpi-v24/image.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addFileResourceForMultipleConfigs("drawable", "image", ImmutableMap.<Configuration, String>builder().put(mergeConfigs(LDPI), "res/drawable-ldpi/image.jpg").put(mergeConfigs(LDPI, sdk(21)), "res/drawable-ldpi-v21/image.jpg").put(mergeConfigs(LDPI, sdk(24)), "res/drawable-ldpi-v24/image.jpg").put(mergeConfigs(XXXHDPI), "res/drawable-xxhdpi/image.jpg").put(mergeConfigs(XXHDPI, sdk(21)), "res/drawable-xxhdpi-v21/image.jpg").put(mergeConfigs(XXHDPI, sdk(24)), "res/drawable-xxhdpi-v24/image.jpg").build()).build()).setManifest(androidManifest("com.test.app")).build();
    // 0x7f010000 is the "drawable/image" resource.
    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-ldpi/image.jpg", "res/drawable-ldpi-v21/image.jpg", "res/drawable-ldpi-v24/image.jpg");
    ImmutableList<ModuleSplit> configSplits = densitySplits.stream().filter(split -> !split.isMasterSplit()).collect(toImmutableList());
    assertThat(configSplits).isNotEmpty();
    for (ModuleSplit configSplit : configSplits) {
        assertThat(extractPaths(configSplit.getEntries())).containsNoneOf("res/drawable-ldpi/image.jpg", "res/drawable-ldpi-v21/image.jpg", "res/drawable-ldpi-v24/image.jpg");
    }
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) ImmutableCollection(com.google.common.collect.ImmutableCollection) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ManifestMutator.withSplitsRequired(com.android.tools.build.bundletool.model.ManifestMutator.withSplitsRequired) Item(com.android.aapt.Resources.Item) LDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.LDPI_VALUE) TVDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.TVDPI) ResourceId(com.android.tools.build.bundletool.model.ResourceId) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) Version(com.android.tools.build.bundletool.model.version.Version) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) XXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXHDPI) ResourceTable(com.android.aapt.Resources.ResourceTable) Theory(org.junit.experimental.theories.Theory) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) ImmutableSet(com.google.common.collect.ImmutableSet) ConfigValue(com.android.aapt.Resources.ConfigValue) ImmutableMap(com.google.common.collect.ImmutableMap) XXXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXXHDPI) Predicate(java.util.function.Predicate) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Collection(java.util.Collection) DEFAULT_DENSITY_BUCKETS(com.android.tools.build.bundletool.splitters.ScreenDensityResourcesSplitter.DEFAULT_DENSITY_BUCKETS) ResourcesTableFactory.sdk(com.android.tools.build.bundletool.testing.ResourcesTableFactory.sdk) XXXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXXHDPI_VALUE) Collectors(java.util.stream.Collectors) ScreenDensity(com.android.bundle.Targeting.ScreenDensity) Sets(com.google.common.collect.Sets) FromDataPoints(org.junit.experimental.theories.FromDataPoints) ByteString(com.google.protobuf.ByteString) List(java.util.List) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) Optional(java.util.Optional) DataPoints(org.junit.experimental.theories.DataPoints) DEFAULT_DENSITY_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.DEFAULT_DENSITY_VALUE) MDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.MDPI) Value(com.android.aapt.Resources.Value) RunWith(org.junit.runner.RunWith) MDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.MDPI_VALUE) TestUtils.extractPaths(com.android.tools.build.bundletool.testing.TestUtils.extractPaths) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) TruthResourceTable.assertThat(com.android.tools.build.bundletool.testing.truth.resources.TruthResourceTable.assertThat) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) Theories(org.junit.experimental.theories.Theories) TVDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.TVDPI_VALUE) ResourcesTableFactory.mergeConfigs(com.android.tools.build.bundletool.testing.ResourcesTableFactory.mergeConfigs) Truth8(com.google.common.truth.Truth8) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Predicates(com.google.common.base.Predicates) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ResourcesTableFactory._560DPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory._560DPI) ManifestProtoUtils.compareManifestMutators(com.android.tools.build.bundletool.testing.ManifestProtoUtils.compareManifestMutators) LDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI) HDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.HDPI_VALUE) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) HDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI) TestCase.fail(junit.framework.TestCase.fail) XXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXHDPI_VALUE) TargetingUtils.assertForNonDefaultSplits(com.android.tools.build.bundletool.testing.TargetingUtils.assertForNonDefaultSplits) Test(org.junit.Test) XHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XHDPI) Truth.assertThat(com.google.common.truth.Truth.assertThat) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) TargetingUtils.apkDensityTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDensityTargeting) ResourcesTableFactory.forDpi(com.android.tools.build.bundletool.testing.ResourcesTableFactory.forDpi) StringPool(com.android.aapt.Resources.StringPool) XHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XHDPI_VALUE) TargetingUtils.assertForSingleDefaultSplit(com.android.tools.build.bundletool.testing.TargetingUtils.assertForSingleDefaultSplit) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) ResourceId(com.android.tools.build.bundletool.model.ResourceId) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) ByteString(com.google.protobuf.ByteString) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 2 with LDPI

use of com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI in project bundletool by google.

the class ScreenDensityResourcesSplitterTest method manifestMutatorToRequireSplits_registered_whenDensityResourcesPresent.

@Test
public void manifestMutatorToRequireSplits_registered_whenDensityResourcesPresent() throws Exception {
    BundleModule testModule = new BundleModuleBuilder("testModule").addFile("res/drawable-mdpi/image.jpg").addFile("res/drawable-hdpi/image.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addDrawableResourceForMultipleDensities("image", ImmutableMap.of(MDPI_VALUE, "res/drawable-ldpi/image.jpg", HDPI_VALUE, "res/drawable-dpi/image.jpg")).build()).setManifest(androidManifest("com.test.app")).build();
    ImmutableCollection<ModuleSplit> densitySplits = splitter.split(ModuleSplit.forResources(testModule));
    ImmutableList<ModuleSplit> configSplits = densitySplits.stream().filter(split -> !split.isMasterSplit()).collect(toImmutableList());
    assertThat(configSplits).isNotEmpty();
    for (ModuleSplit configSplit : configSplits) {
        assertThat(compareManifestMutators(configSplit.getMasterManifestMutators(), withSplitsRequired(true))).isTrue();
    }
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) ImmutableCollection(com.google.common.collect.ImmutableCollection) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ManifestMutator.withSplitsRequired(com.android.tools.build.bundletool.model.ManifestMutator.withSplitsRequired) Item(com.android.aapt.Resources.Item) LDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.LDPI_VALUE) TVDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.TVDPI) ResourceId(com.android.tools.build.bundletool.model.ResourceId) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) Version(com.android.tools.build.bundletool.model.version.Version) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) XXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXHDPI) ResourceTable(com.android.aapt.Resources.ResourceTable) Theory(org.junit.experimental.theories.Theory) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) ImmutableSet(com.google.common.collect.ImmutableSet) ConfigValue(com.android.aapt.Resources.ConfigValue) ImmutableMap(com.google.common.collect.ImmutableMap) XXXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXXHDPI) Predicate(java.util.function.Predicate) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Collection(java.util.Collection) DEFAULT_DENSITY_BUCKETS(com.android.tools.build.bundletool.splitters.ScreenDensityResourcesSplitter.DEFAULT_DENSITY_BUCKETS) ResourcesTableFactory.sdk(com.android.tools.build.bundletool.testing.ResourcesTableFactory.sdk) XXXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXXHDPI_VALUE) Collectors(java.util.stream.Collectors) ScreenDensity(com.android.bundle.Targeting.ScreenDensity) Sets(com.google.common.collect.Sets) FromDataPoints(org.junit.experimental.theories.FromDataPoints) ByteString(com.google.protobuf.ByteString) List(java.util.List) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) Optional(java.util.Optional) DataPoints(org.junit.experimental.theories.DataPoints) DEFAULT_DENSITY_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.DEFAULT_DENSITY_VALUE) MDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.MDPI) Value(com.android.aapt.Resources.Value) RunWith(org.junit.runner.RunWith) MDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.MDPI_VALUE) TestUtils.extractPaths(com.android.tools.build.bundletool.testing.TestUtils.extractPaths) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) TruthResourceTable.assertThat(com.android.tools.build.bundletool.testing.truth.resources.TruthResourceTable.assertThat) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) Theories(org.junit.experimental.theories.Theories) TVDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.TVDPI_VALUE) ResourcesTableFactory.mergeConfigs(com.android.tools.build.bundletool.testing.ResourcesTableFactory.mergeConfigs) Truth8(com.google.common.truth.Truth8) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Predicates(com.google.common.base.Predicates) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ResourcesTableFactory._560DPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory._560DPI) ManifestProtoUtils.compareManifestMutators(com.android.tools.build.bundletool.testing.ManifestProtoUtils.compareManifestMutators) LDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI) HDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.HDPI_VALUE) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) HDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI) TestCase.fail(junit.framework.TestCase.fail) XXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXHDPI_VALUE) TargetingUtils.assertForNonDefaultSplits(com.android.tools.build.bundletool.testing.TargetingUtils.assertForNonDefaultSplits) Test(org.junit.Test) XHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XHDPI) Truth.assertThat(com.google.common.truth.Truth.assertThat) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) TargetingUtils.apkDensityTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDensityTargeting) ResourcesTableFactory.forDpi(com.android.tools.build.bundletool.testing.ResourcesTableFactory.forDpi) StringPool(com.android.aapt.Resources.StringPool) XHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XHDPI_VALUE) TargetingUtils.assertForSingleDefaultSplit(com.android.tools.build.bundletool.testing.TargetingUtils.assertForSingleDefaultSplit) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 3 with LDPI

use of com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI in project bundletool by google.

the class ScreenDensityResourcesSplitterTest method lowestDensityConfigsPinnedToMaster_masterCoversRangeOfDensities.

@Test
public void lowestDensityConfigsPinnedToMaster_masterCoversRangeOfDensities() throws Exception {
    BundleModule testModule = new BundleModuleBuilder("testModule").addFile("res/drawable-ldpi/image.jpg").addFile("res/drawable-xxxhdpi/image.jpg").addFile("res/drawable-ldpi/other.jpg").addFile("res/drawable-mdpi/other.jpg").addFile("res/drawable-tvdpi/other.jpg").addFile("res/drawable-xhdpi/other.jpg").addFile("res/drawable-xxhdpi/other.jpg").addFile("res/drawable-xxxhdpi/other.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addDrawableResourceForMultipleDensities("image", ImmutableMap.of(/* ldpi */
    120, "res/drawable-ldpi/image.jpg", /* xxxhdpi */
    640, "res/drawable-xxxhdpi/image.jpg")).addDrawableResourceForMultipleDensities("other", ImmutableMap.<Integer, String>builder().put(/* ldpi */
    120, "res/drawable-ldpi/other.jpg").put(/* mdpi */
    160, "res/drawable-mdpi/other.jpg").put(/* tvdpi */
    213, "res/drawable-tvdpi/other.jpg").put(/* hdpi */
    240, "res/drawable-hdpi/other.jpg").put(/* xhdpi */
    320, "res/drawable-xhdpi/other.jpg").put(/* xxhdpi */
    480, "res/drawable-xxhdpi/other.jpg").put(/* xxxhdpi */
    640, "res/drawable-xxxhdpi/image.jpg").build()).build()).setManifest(androidManifest("com.test.app")).build();
    // 0x7f010000 is the "drawable/image" resource.
    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));
    ImmutableList<ModuleSplit> configSplits = densitySplits.stream().filter(split -> !split.isMasterSplit()).collect(toImmutableList());
    assertThat(configSplits).isNotEmpty();
    for (ModuleSplit configSplit : configSplits) {
        DensityAlias targetDensity = configSplit.getApkTargeting().getScreenDensityTargeting().getValue(0).getDensityAlias();
        switch(targetDensity) {
            case LDPI:
            case MDPI:
                // Devices <= MDPI are covered by the LDPI config.
                assertThat(extractPaths(configSplit.getEntries())).doesNotContain("res/drawable-xxxhdpi/image.jpg");
                break;
            default:
                // Devices > MDPI are covered by the XXXHDPI config.
                assertThat(extractPaths(configSplit.getEntries())).contains("res/drawable-xxxhdpi/image.jpg");
        }
    }
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) ImmutableCollection(com.google.common.collect.ImmutableCollection) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ManifestMutator.withSplitsRequired(com.android.tools.build.bundletool.model.ManifestMutator.withSplitsRequired) Item(com.android.aapt.Resources.Item) LDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.LDPI_VALUE) TVDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.TVDPI) ResourceId(com.android.tools.build.bundletool.model.ResourceId) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) Version(com.android.tools.build.bundletool.model.version.Version) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) XXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXHDPI) ResourceTable(com.android.aapt.Resources.ResourceTable) Theory(org.junit.experimental.theories.Theory) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) ImmutableSet(com.google.common.collect.ImmutableSet) ConfigValue(com.android.aapt.Resources.ConfigValue) ImmutableMap(com.google.common.collect.ImmutableMap) XXXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXXHDPI) Predicate(java.util.function.Predicate) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Collection(java.util.Collection) DEFAULT_DENSITY_BUCKETS(com.android.tools.build.bundletool.splitters.ScreenDensityResourcesSplitter.DEFAULT_DENSITY_BUCKETS) ResourcesTableFactory.sdk(com.android.tools.build.bundletool.testing.ResourcesTableFactory.sdk) XXXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXXHDPI_VALUE) Collectors(java.util.stream.Collectors) ScreenDensity(com.android.bundle.Targeting.ScreenDensity) Sets(com.google.common.collect.Sets) FromDataPoints(org.junit.experimental.theories.FromDataPoints) ByteString(com.google.protobuf.ByteString) List(java.util.List) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) Optional(java.util.Optional) DataPoints(org.junit.experimental.theories.DataPoints) DEFAULT_DENSITY_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.DEFAULT_DENSITY_VALUE) MDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.MDPI) Value(com.android.aapt.Resources.Value) RunWith(org.junit.runner.RunWith) MDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.MDPI_VALUE) TestUtils.extractPaths(com.android.tools.build.bundletool.testing.TestUtils.extractPaths) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) TruthResourceTable.assertThat(com.android.tools.build.bundletool.testing.truth.resources.TruthResourceTable.assertThat) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) Theories(org.junit.experimental.theories.Theories) TVDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.TVDPI_VALUE) ResourcesTableFactory.mergeConfigs(com.android.tools.build.bundletool.testing.ResourcesTableFactory.mergeConfigs) Truth8(com.google.common.truth.Truth8) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Predicates(com.google.common.base.Predicates) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ResourcesTableFactory._560DPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory._560DPI) ManifestProtoUtils.compareManifestMutators(com.android.tools.build.bundletool.testing.ManifestProtoUtils.compareManifestMutators) LDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI) HDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.HDPI_VALUE) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) HDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI) TestCase.fail(junit.framework.TestCase.fail) XXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXHDPI_VALUE) TargetingUtils.assertForNonDefaultSplits(com.android.tools.build.bundletool.testing.TargetingUtils.assertForNonDefaultSplits) Test(org.junit.Test) XHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XHDPI) Truth.assertThat(com.google.common.truth.Truth.assertThat) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) TargetingUtils.apkDensityTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDensityTargeting) ResourcesTableFactory.forDpi(com.android.tools.build.bundletool.testing.ResourcesTableFactory.forDpi) StringPool(com.android.aapt.Resources.StringPool) XHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XHDPI_VALUE) TargetingUtils.assertForSingleDefaultSplit(com.android.tools.build.bundletool.testing.TargetingUtils.assertForSingleDefaultSplit) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) ResourceId(com.android.tools.build.bundletool.model.ResourceId) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 4 with LDPI

use of com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI in project bundletool by google.

the class ScreenDensityResourcesSplitterTest method allSplitsPresentWithResourceTable.

@Test
public void allSplitsPresentWithResourceTable() throws Exception {
    BundleModule testModule = new BundleModuleBuilder("testModule").addFile("res/drawable-mdpi/image.jpg").addFile("res/drawable-hdpi/image.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addDrawableResourceForMultipleDensities("image", ImmutableMap.of(LDPI_VALUE, "res/drawable-ldpi/image.jpg", MDPI_VALUE, "res/drawable-mdpi/image.jpg")).build()).setManifest(androidManifest("com.test.app")).build();
    ImmutableSet<DensityAlias> densities = ImmutableSet.of(DensityAlias.LDPI, DensityAlias.MDPI, DensityAlias.TVDPI, DensityAlias.HDPI, DensityAlias.XHDPI, DensityAlias.XXHDPI, DensityAlias.XXXHDPI);
    ImmutableCollection<ModuleSplit> densitySplits = splitter.split(ModuleSplit.forResources(testModule));
    for (ModuleSplit resourceSplit : densitySplits) {
        assertThat(resourceSplit.getResourceTable().isPresent()).isTrue();
    }
    List<ApkTargeting> targeting = densitySplits.stream().map(split -> split.getApkTargeting()).collect(Collectors.toList());
    assertThat(targeting).ignoringRepeatedFieldOrder().containsExactly(ApkTargeting.getDefaultInstance(), apkDensityTargeting(DensityAlias.LDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.LDPI))), apkDensityTargeting(ImmutableSet.of(DensityAlias.MDPI), Sets.difference(densities, ImmutableSet.of(DensityAlias.MDPI))), apkDensityTargeting(ImmutableSet.of(DensityAlias.HDPI), Sets.difference(densities, ImmutableSet.of(DensityAlias.HDPI))), apkDensityTargeting(ImmutableSet.of(DensityAlias.XHDPI), Sets.difference(densities, ImmutableSet.of(DensityAlias.XHDPI))), apkDensityTargeting(ImmutableSet.of(DensityAlias.XXHDPI), Sets.difference(densities, ImmutableSet.of(DensityAlias.XXHDPI))), apkDensityTargeting(ImmutableSet.of(DensityAlias.XXXHDPI), Sets.difference(densities, ImmutableSet.of(DensityAlias.XXXHDPI))), apkDensityTargeting(ImmutableSet.of(DensityAlias.TVDPI), Sets.difference(densities, ImmutableSet.of(DensityAlias.TVDPI))));
}
Also used : ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) ImmutableCollection(com.google.common.collect.ImmutableCollection) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ManifestMutator.withSplitsRequired(com.android.tools.build.bundletool.model.ManifestMutator.withSplitsRequired) Item(com.android.aapt.Resources.Item) LDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.LDPI_VALUE) TVDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.TVDPI) ResourceId(com.android.tools.build.bundletool.model.ResourceId) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) ResourcesTableFactory.entry(com.android.tools.build.bundletool.testing.ResourcesTableFactory.entry) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) Version(com.android.tools.build.bundletool.model.version.Version) ResourcesTableFactory.type(com.android.tools.build.bundletool.testing.ResourcesTableFactory.type) XXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXHDPI) ResourceTable(com.android.aapt.Resources.ResourceTable) Theory(org.junit.experimental.theories.Theory) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) ImmutableSet(com.google.common.collect.ImmutableSet) ConfigValue(com.android.aapt.Resources.ConfigValue) ImmutableMap(com.google.common.collect.ImmutableMap) XXXHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XXXHDPI) Predicate(java.util.function.Predicate) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Collection(java.util.Collection) DEFAULT_DENSITY_BUCKETS(com.android.tools.build.bundletool.splitters.ScreenDensityResourcesSplitter.DEFAULT_DENSITY_BUCKETS) ResourcesTableFactory.sdk(com.android.tools.build.bundletool.testing.ResourcesTableFactory.sdk) XXXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXXHDPI_VALUE) Collectors(java.util.stream.Collectors) ScreenDensity(com.android.bundle.Targeting.ScreenDensity) Sets(com.google.common.collect.Sets) FromDataPoints(org.junit.experimental.theories.FromDataPoints) ByteString(com.google.protobuf.ByteString) List(java.util.List) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) Optional(java.util.Optional) DataPoints(org.junit.experimental.theories.DataPoints) DEFAULT_DENSITY_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.DEFAULT_DENSITY_VALUE) MDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.MDPI) Value(com.android.aapt.Resources.Value) RunWith(org.junit.runner.RunWith) MDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.MDPI_VALUE) TestUtils.extractPaths(com.android.tools.build.bundletool.testing.TestUtils.extractPaths) ResourcesTableFactory.resourceTable(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTable) TruthResourceTable.assertThat(com.android.tools.build.bundletool.testing.truth.resources.TruthResourceTable.assertThat) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) ImmutableList(com.google.common.collect.ImmutableList) Theories(org.junit.experimental.theories.Theories) TVDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.TVDPI_VALUE) ResourcesTableFactory.mergeConfigs(com.android.tools.build.bundletool.testing.ResourcesTableFactory.mergeConfigs) Truth8(com.google.common.truth.Truth8) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) Predicates(com.google.common.base.Predicates) ResourcesTableFactory.pkg(com.android.tools.build.bundletool.testing.ResourcesTableFactory.pkg) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) ResourcesTableFactory._560DPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory._560DPI) ManifestProtoUtils.compareManifestMutators(com.android.tools.build.bundletool.testing.ManifestProtoUtils.compareManifestMutators) LDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI) HDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.HDPI_VALUE) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) HDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.HDPI) TestCase.fail(junit.framework.TestCase.fail) XXHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XXHDPI_VALUE) TargetingUtils.assertForNonDefaultSplits(com.android.tools.build.bundletool.testing.TargetingUtils.assertForNonDefaultSplits) Test(org.junit.Test) XHDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.XHDPI) Truth.assertThat(com.google.common.truth.Truth.assertThat) ResourcesTableFactory.fileReference(com.android.tools.build.bundletool.testing.ResourcesTableFactory.fileReference) TargetingUtils.apkDensityTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkDensityTargeting) ResourcesTableFactory.forDpi(com.android.tools.build.bundletool.testing.ResourcesTableFactory.forDpi) StringPool(com.android.aapt.Resources.StringPool) XHDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.XHDPI_VALUE) TargetingUtils.assertForSingleDefaultSplit(com.android.tools.build.bundletool.testing.TargetingUtils.assertForSingleDefaultSplit) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) ApkTargeting(com.android.bundle.Targeting.ApkTargeting) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 5 with LDPI

use of com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI in project bundletool by google.

the class BuildApksManagerTest method buildApksCommand_universal_generatesSingleApkWithNoOptimizations.

@Test
public void buildApksCommand_universal_generatesSingleApkWithNoOptimizations() throws Exception {
    AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("lib/x86/libsome.so").addFile("lib/x86_64/libsome.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)))).addFile("res/drawable-ldpi/image.jpg").addFile("res/drawable-mdpi/image.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addFileResourceForMultipleConfigs("drawable", "image", ImmutableMap.of(LDPI, "res/drawable-ldpi/image.jpg", MDPI, "res/drawable-mdpi/image.jpg")).build()).setManifest(androidManifest("com.test.app"))).build();
    TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withApkBuildMode(UNIVERSAL).build());
    buildApksManager.execute();
    ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
    BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
    // Should not shard by any dimension and generate single APK with default targeting.
    assertThat(result.getVariantList()).hasSize(1);
    assertThat(splitApkVariants(result)).isEmpty();
    assertThat(standaloneApkVariants(result)).hasSize(1);
    Variant universalVariant = standaloneApkVariants(result).get(0);
    assertThat(universalVariant.getTargeting()).isEqualTo(UNRESTRICTED_VARIANT_TARGETING);
    assertThat(apkDescriptions(universalVariant)).hasSize(1);
    ApkDescription universalApk = apkDescriptions(universalVariant).get(0);
    assertThat(universalApk.getTargeting()).isEqualToDefaultInstance();
    // No ABI or density sharding.
    File universalApkFile = extractFromApkSetFile(apkSetFile, universalApk.getPath(), outputDir);
    try (ZipFile universalApkZipFile = new ZipFile(universalApkFile)) {
        assertThat(filesUnderPath(universalApkZipFile, ZipPath.create("lib"))).containsExactly("lib/x86/libsome.so", "lib/x86_64/libsome.so");
        // "res/xml/splits0.xml" is created by bundletool with list of generated splits.
        assertThat(filesUnderPath(universalApkZipFile, ZipPath.create("res"))).containsExactly("res/drawable-ldpi/image.jpg", "res/drawable-mdpi/image.jpg", "res/xml/splits0.xml");
    }
}
Also used : TEST_LABEL_RESOURCE_ID(com.android.tools.build.bundletool.testing.ResourcesTableFactory.TEST_LABEL_RESOURCE_ID) SYSTEM(com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.SYSTEM) ApkTargeting(com.android.bundle.Targeting.ApkTargeting) ApkSetUtils.parseTocFromFile(com.android.tools.build.bundletool.testing.ApkSetUtils.parseTocFromFile) TargetingUtils.alternativeLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.alternativeLanguageTargeting) Bundletool(com.android.bundle.Config.Bundletool) ARM64_V8A(com.android.bundle.Targeting.Abi.AbiAlias.ARM64_V8A) AssetModulesConfig(com.android.bundle.Config.AssetModulesConfig) Map(java.util.Map) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) TestUtils.filesUnderPath(com.android.tools.build.bundletool.testing.TestUtils.filesUnderPath) Path(java.nio.file.Path) SourceStamp(com.android.tools.build.bundletool.model.SourceStamp) ManifestProtoUtils.withTitle(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withTitle) TargetingUtils.nativeDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting) ASSETS_DIRECTORY(com.android.tools.build.bundletool.model.BundleModule.ASSETS_DIRECTORY) DIRECTORY(com.android.tools.build.bundletool.commands.BuildApksCommand.OutputFormat.DIRECTORY) DeviceFactory.sdkVersion(com.android.tools.build.bundletool.testing.DeviceFactory.sdkVersion) ApkSet(com.android.bundle.Commands.ApkSet) BundleConfig(com.android.bundle.Config.BundleConfig) TextureCompressionFormatTargeting(com.android.bundle.Targeting.TextureCompressionFormatTargeting) TargetingUtils.variantAbiTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.variantAbiTargeting) SystemApkOption(com.android.tools.build.bundletool.commands.BuildApksCommand.SystemApkOption) ManifestProtoUtils.androidManifestForFeature(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForFeature) TargetingUtils.assetsDirectoryTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.assetsDirectoryTargeting) CodeTransparency(com.android.bundle.CodeTransparencyOuterClass.CodeTransparency) SystemApkMetadata(com.android.bundle.Commands.SystemApkMetadata) STAMP_SOURCE_METADATA_KEY(com.android.tools.build.bundletool.model.SourceStamp.STAMP_SOURCE_METADATA_KEY) MDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.MDPI) ApexManifest(com.android.apex.ApexManifestProto.ApexManifest) ZipPath(com.android.tools.build.bundletool.model.ZipPath) ManifestProtoUtils.withInstantOnDemandDelivery(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstantOnDemandDelivery) RunWith(org.junit.runner.RunWith) MDPI_VALUE(com.android.tools.build.bundletool.model.utils.ResourcesUtils.MDPI_VALUE) SdkVersion(com.android.bundle.Targeting.SdkVersion) TEXTURE_COMPRESSION_FORMAT(com.android.tools.build.bundletool.model.OptimizationDimension.TEXTURE_COMPRESSION_FORMAT) DeviceFactory.mergeSpecs(com.android.tools.build.bundletool.testing.DeviceFactory.mergeSpecs) StandaloneApkMetadata(com.android.bundle.Commands.StandaloneApkMetadata) SigningConfiguration(com.android.tools.build.bundletool.model.SigningConfiguration) Theories(org.junit.experimental.theories.Theories) ResultUtils.instantApkVariants(com.android.tools.build.bundletool.model.utils.ResultUtils.instantApkVariants) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ApkDescription(com.android.bundle.Commands.ApkDescription) Before(org.junit.Before) X86(com.android.bundle.Targeting.Abi.AbiAlias.X86) USER_PACKAGE_OFFSET(com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET) AssetSliceSet(com.android.bundle.Commands.AssetSliceSet) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) IOException(java.io.IOException) Test(org.junit.Test) Correspondence(com.google.common.truth.Correspondence) ALL_MODULES_SHORTCUT(com.android.tools.build.bundletool.commands.ExtractApksCommand.ALL_MODULES_SHORTCUT) ResultUtils.apexApkVariants(com.android.tools.build.bundletool.model.utils.ResultUtils.apexApkVariants) AppBundle(com.android.tools.build.bundletool.model.AppBundle) CodeRelatedFile(com.android.bundle.CodeTransparencyOuterClass.CodeRelatedFile) X509Certificate(java.security.cert.X509Certificate) ManifestProtoUtils.withNativeActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withNativeActivity) ManifestProtoUtils.androidManifest(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest) AndroidManifest(com.android.tools.build.bundletool.model.AndroidManifest) Maps.transformValues(com.google.common.collect.Maps.transformValues) ManifestProtoUtils.withInstallLocation(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstallLocation) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) AssetsDirectoryTargeting(com.android.bundle.Targeting.AssetsDirectoryTargeting) TargetingUtils.languageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.languageTargeting) ManifestProtoUtils.withOnDemandDelivery(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withOnDemandDelivery) ZipFile(java.util.zip.ZipFile) ZipEntry(java.util.zip.ZipEntry) PERSISTENT(com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.PERSISTENT) ImmutableSet(com.google.common.collect.ImmutableSet) Collection(java.util.Collection) KeyStore(java.security.KeyStore) InstantMetadata(com.android.bundle.Commands.InstantMetadata) Collectors(java.util.stream.Collectors) ScreenDensity(com.android.bundle.Targeting.ScreenDensity) InvalidVersionCodeException(com.android.tools.build.bundletool.model.exceptions.InvalidVersionCodeException) DefaultTargetingValue(com.android.bundle.Commands.DefaultTargetingValue) ManifestProtoUtils.withOnDemandAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withOnDemandAttribute) CertificateHelper(com.android.tools.build.bundletool.model.utils.CertificateHelper) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ApkSetUtils(com.android.tools.build.bundletool.testing.ApkSetUtils) PermanentlyFusedModule(com.android.bundle.Commands.PermanentlyFusedModule) FilePreconditions(com.android.tools.build.bundletool.model.utils.files.FilePreconditions) ManifestProtoUtils.withMaxSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMaxSdkVersion) BundleType(com.android.bundle.Config.BundleConfig.BundleType) DeviceFactory.locales(com.android.tools.build.bundletool.testing.DeviceFactory.locales) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) TargetingUtils.alternativeTextureCompressionTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.alternativeTextureCompressionTargeting) TargetingUtils.variantSdkTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.variantSdkTargeting) ResultUtils.standaloneApkVariants(com.android.tools.build.bundletool.model.utils.ResultUtils.standaloneApkVariants) ApkModifier(com.android.tools.build.bundletool.model.ApkModifier) BundleConfigBuilder(com.android.tools.build.bundletool.testing.BundleConfigBuilder) Hashing(com.google.common.hash.Hashing) TargetingUtils.moduleDeviceGroupsTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.moduleDeviceGroupsTargeting) ManifestProtoUtils.withDeviceGroupsCondition(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withDeviceGroupsCondition) TargetingUtils.toAbi(com.android.tools.build.bundletool.testing.TargetingUtils.toAbi) Inject(javax.inject.Inject) ModuleMetadata(com.android.bundle.Commands.ModuleMetadata) ImmutableList(com.google.common.collect.ImmutableList) Charset(java.nio.charset.Charset) ManifestProtoUtils.withSplitNameService(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withSplitNameService) CharSource(com.google.common.io.CharSource) Truth8.assertThat(com.google.common.truth.Truth8.assertThat) LDPI(com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI) CertificateFactory(com.android.tools.build.bundletool.testing.CertificateFactory) TargetingUtils.sdkVersionFrom(com.android.tools.build.bundletool.testing.TargetingUtils.sdkVersionFrom) TestData(com.android.tools.build.bundletool.TestData) Truth.assertThat(com.google.common.truth.Truth.assertThat) FileUtils(com.android.tools.build.bundletool.testing.FileUtils) TargetingUtils.nativeLibraries(com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries) Ignore(org.junit.Ignore) InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) ApkVerifier(com.android.apksig.ApkVerifier) Configuration(com.android.aapt.ConfigurationOuterClass.Configuration) KeyPair(java.security.KeyPair) Value(com.android.bundle.Config.SplitDimension.Value) UNIVERSAL(com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.UNIVERSAL) ResourcesTableFactory.locale(com.android.tools.build.bundletool.testing.ResourcesTableFactory.locale) TargetingUtils.textureCompressionTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.textureCompressionTargeting) DeviceFactory.abis(com.android.tools.build.bundletool.testing.DeviceFactory.abis) TargetingUtils.variantMultiAbiTargetingFromAllTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.variantMultiAbiTargetingFromAllTargeting) DeliveryType(com.android.bundle.Commands.DeliveryType) ManifestProtoUtils.withUsesSplit(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withUsesSplit) ResourcesTableFactory.resourceTableWithTestLabel(com.android.tools.build.bundletool.testing.ResourcesTableFactory.resourceTableWithTestLabel) Version(com.android.tools.build.bundletool.model.version.Version) TruthZip(com.android.tools.build.bundletool.testing.truth.zip.TruthZip) Theory(org.junit.experimental.theories.Theory) KeyPairGenerator(java.security.KeyPairGenerator) ImmutableMultiset.toImmutableMultiset(com.google.common.collect.ImmutableMultiset.toImmutableMultiset) BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) ARMEABI_V7A(com.android.bundle.Targeting.Abi.AbiAlias.ARMEABI_V7A) LanguageTargeting(com.android.bundle.Targeting.LanguageTargeting) ManifestProtoUtils.withInstallTimeRemovableElement(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstallTimeRemovableElement) Executors(java.util.concurrent.Executors) ManifestProtoUtils.withMinSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withMinSdkVersion) ApexImages(com.android.bundle.Files.ApexImages) TargetingUtils.apexImageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apexImageTargeting) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) DeviceFactory.density(com.android.tools.build.bundletool.testing.DeviceFactory.density) TextureCompressionFormat(com.android.bundle.Targeting.TextureCompressionFormat) PrivateKey(java.security.PrivateKey) ByteStreams(com.google.common.io.ByteStreams) ManifestProtoUtils.withInstallTimeDelivery(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstallTimeDelivery) ResultUtils.systemApkVariants(com.android.tools.build.bundletool.model.utils.ResultUtils.systemApkVariants) DEVELOPMENT_SDK_VERSION(com.android.tools.build.bundletool.model.AndroidManifest.DEVELOPMENT_SDK_VERSION) TargetingUtils.targetedApexImage(com.android.tools.build.bundletool.testing.TargetingUtils.targetedApexImage) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) TruthZip.assertThat(com.android.tools.build.bundletool.testing.truth.zip.TruthZip.assertThat) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Iterables(com.google.common.collect.Iterables) Optimizations(com.android.bundle.Config.Optimizations) ATC(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ATC) TargetingUtils.textureCompressionFormat(com.android.tools.build.bundletool.testing.TargetingUtils.textureCompressionFormat) Component(dagger.Component) LANGUAGE(com.android.tools.build.bundletool.model.OptimizationDimension.LANGUAGE) ApkSetUtils.extractTocFromApkSetFile(com.android.tools.build.bundletool.testing.ApkSetUtils.extractTocFromApkSetFile) Closer(com.google.common.io.Closer) ImmutableMultiset(com.google.common.collect.ImmutableMultiset) AppBundleSerializer(com.android.tools.build.bundletool.io.AppBundleSerializer) ResultUtils.splitApkVariants(com.android.tools.build.bundletool.model.utils.ResultUtils.splitApkVariants) SplitApkMetadata(com.android.bundle.Commands.SplitApkMetadata) ANDROID_P_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_P_API_VERSION) ByteSource(com.google.common.io.ByteSource) CodeTransparencyTestUtils.createJwsToken(com.android.tools.build.bundletool.testing.CodeTransparencyTestUtils.createJwsToken) ANDROID_Q_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_Q_API_VERSION) VariantTargeting(com.android.bundle.Targeting.VariantTargeting) AdbServer(com.android.tools.build.bundletool.device.AdbServer) StandaloneConfig(com.android.bundle.Config.StandaloneConfig) Int32Value(com.google.protobuf.Int32Value) DeviceFactory.deviceTier(com.android.tools.build.bundletool.testing.DeviceFactory.deviceTier) Files(java.nio.file.Files) ANDROID_N_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_N_API_VERSION) TargetingUtils.targetedNativeDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedNativeDirectory) TestCase.fail(junit.framework.TestCase.fail) FileOutputStream(java.io.FileOutputStream) X86_64(com.android.bundle.Targeting.Abi.AbiAlias.X86_64) BundleMetadata(com.android.tools.build.bundletool.model.BundleMetadata) ANDROID_M_API_VERSION(com.android.tools.build.bundletool.model.utils.Versions.ANDROID_M_API_VERSION) TargetingUtils.assets(com.android.tools.build.bundletool.testing.TargetingUtils.assets) File(java.io.File) ApkSetUtils.extractFromApkSetFile(com.android.tools.build.bundletool.testing.ApkSetUtils.extractFromApkSetFile) ResultUtils.archivedApkVariants(com.android.tools.build.bundletool.model.utils.ResultUtils.archivedApkVariants) Paths(java.nio.file.Paths) FakeAdbServer(com.android.tools.build.bundletool.testing.FakeAdbServer) Abi(com.android.bundle.Targeting.Abi) TargetingUtils.sdkVersionTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.sdkVersionTargeting) ManifestProtoUtils.withAppIcon(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withAppIcon) Variant(com.android.bundle.Commands.Variant) TestUtils.extractAndroidManifest(com.android.tools.build.bundletool.testing.TestUtils.extractAndroidManifest) MoreCollectors.onlyElement(com.google.common.collect.MoreCollectors.onlyElement) ManifestProtoUtils.androidManifestForAssetModule(com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifestForAssetModule) TargetingUtils.mergeVariantTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.mergeVariantTargeting) ManifestProtoUtils.withDelivery(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withDelivery) TargetingUtils.deviceTierTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.deviceTierTargeting) TargetingUtils.targetedAssetsDirectory(com.android.tools.build.bundletool.testing.TargetingUtils.targetedAssetsDirectory) After(org.junit.After) ManifestProtoUtils.withTargetSdkVersion(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withTargetSdkVersion) ImmutableMap(com.google.common.collect.ImmutableMap) FromDataPoints(org.junit.experimental.theories.FromDataPoints) List(java.util.List) Certificate(java.security.cert.Certificate) INSTANT(com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.INSTANT) DataPoints(org.junit.experimental.theories.DataPoints) ABI(com.android.tools.build.bundletool.model.OptimizationDimension.ABI) ManifestProtoUtils.withCustomThemeActivity(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withCustomThemeActivity) TargetingUtils.apkLanguageTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkLanguageTargeting) TestModule(com.android.tools.build.bundletool.testing.TestModule) BeforeClass(org.junit.BeforeClass) TargetingUtils.apexImages(com.android.tools.build.bundletool.testing.TargetingUtils.apexImages) BuildApksResult(com.android.bundle.Commands.BuildApksResult) DeviceTierTargeting(com.android.bundle.Targeting.DeviceTierTargeting) SdkVersionTargeting(com.android.bundle.Targeting.SdkVersionTargeting) ProtoTruth.assertThat(com.google.common.truth.extensions.proto.ProtoTruth.assertThat) MIPS(com.android.bundle.Targeting.Abi.AbiAlias.MIPS) ManifestProtoUtils.withInstant(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withInstant) ARCHIVE(com.android.tools.build.bundletool.commands.BuildApksCommand.ApkBuildMode.ARCHIVE) Assert.assertNotNull(org.junit.Assert.assertNotNull) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) ManifestProtoUtils.withFusingAttribute(com.android.tools.build.bundletool.testing.ManifestProtoUtils.withFusingAttribute) TargetingUtils.apkMultiAbiTargetingFromAllTargeting(com.android.tools.build.bundletool.testing.TargetingUtils.apkMultiAbiTargetingFromAllTargeting) ETC1_RGB8(com.android.bundle.Targeting.TextureCompressionFormat.TextureCompressionFormatAlias.ETC1_RGB8) AssetModulesInfo(com.android.bundle.Commands.AssetModulesInfo) Maps(com.google.common.collect.Maps) AbiAlias(com.android.bundle.Targeting.Abi.AbiAlias) Rule(org.junit.Rule) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) Variant(com.android.bundle.Commands.Variant) AppBundle(com.android.tools.build.bundletool.model.AppBundle) ApkDescription(com.android.bundle.Commands.ApkDescription) ZipFile(java.util.zip.ZipFile) BuildApksResult(com.android.bundle.Commands.BuildApksResult) AppBundleBuilder(com.android.tools.build.bundletool.testing.AppBundleBuilder) ResourceTableBuilder(com.android.tools.build.bundletool.testing.ResourceTableBuilder) ApkSetUtils.parseTocFromFile(com.android.tools.build.bundletool.testing.ApkSetUtils.parseTocFromFile) CodeRelatedFile(com.android.bundle.CodeTransparencyOuterClass.CodeRelatedFile) ZipFile(java.util.zip.ZipFile) ApkSetUtils.extractTocFromApkSetFile(com.android.tools.build.bundletool.testing.ApkSetUtils.extractTocFromApkSetFile) File(java.io.File) ApkSetUtils.extractFromApkSetFile(com.android.tools.build.bundletool.testing.ApkSetUtils.extractFromApkSetFile) Test(org.junit.Test)

Aggregations

Configuration (com.android.aapt.ConfigurationOuterClass.Configuration)5 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)5 ScreenDensity (com.android.bundle.Targeting.ScreenDensity)5 DensityAlias (com.android.bundle.Targeting.ScreenDensity.DensityAlias)5 MDPI_VALUE (com.android.tools.build.bundletool.model.utils.ResourcesUtils.MDPI_VALUE)5 BundleToolVersion (com.android.tools.build.bundletool.model.version.BundleToolVersion)5 Version (com.android.tools.build.bundletool.model.version.Version)5 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)5 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)5 LDPI (com.android.tools.build.bundletool.testing.ResourcesTableFactory.LDPI)5 MDPI (com.android.tools.build.bundletool.testing.ResourcesTableFactory.MDPI)5 USER_PACKAGE_OFFSET (com.android.tools.build.bundletool.testing.ResourcesTableFactory.USER_PACKAGE_OFFSET)5 ConfigValue (com.android.aapt.Resources.ConfigValue)4 Item (com.android.aapt.Resources.Item)4 ResourceTable (com.android.aapt.Resources.ResourceTable)4 StringPool (com.android.aapt.Resources.StringPool)4 Value (com.android.aapt.Resources.Value)4 BundleModule (com.android.tools.build.bundletool.model.BundleModule)4 ManifestMutator.withSplitsRequired (com.android.tools.build.bundletool.model.ManifestMutator.withSplitsRequired)4 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)4