Search in sources :

Example 16 with DensityAlias

use of com.android.bundle.Targeting.ScreenDensity.DensityAlias 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 17 with DensityAlias

use of com.android.bundle.Targeting.ScreenDensity.DensityAlias in project bundletool by google.

the class ScreenDensityResourcesSplitterTest method picksTheResourceForExactDensity.

@Test
public void picksTheResourceForExactDensity() throws Exception {
    ResourceTable table = new ResourceTableBuilder().addPackage("com.test.app").addDrawableResourceForMultipleDensities("image", ImmutableMap.<Integer, String>builder().put(LDPI_VALUE, "res/drawable-ldpi/image.jpg").put(MDPI_VALUE, "res/drawable-mdpi/image.jpg").put(TVDPI_VALUE, "res/drawable-tvdpi/image.jpg").put(HDPI_VALUE, "res/drawable-hdpi/image.jpg").put(XHDPI_VALUE, "res/drawable-xhdpi/image.jpg").put(XXHDPI_VALUE, "res/drawable-xxhdpi/image.jpg").put(XXXHDPI_VALUE, "res/drawable-xxxhdpi/image.jpg").build()).build();
    BundleModule testModule = new BundleModuleBuilder("testModule").addFile("res/drawable-ldpi/image.jpg").addFile("res/drawable-mdpi/image.jpg").addFile("res/drawable-tvdpi/image.jpg").addFile("res/drawable-hdpi/image.jpg").addFile("res/drawable-xhdpi/image.jpg").addFile("res/drawable-xxhdpi/image.jpg").addFile("res/drawable-xxxhdpi/image.jpg").setResourceTable(table).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));
    assertThat(densitySplits).hasSize(DEFAULT_DENSITY_BUCKETS.size() + 1);
    assertThat(densitySplits.stream().map(split -> split.getApkTargeting()).collect(toImmutableSet())).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))));
    for (ModuleSplit densitySplit : densitySplits) {
        assertThat(densitySplit.getResourceTable().isPresent()).isTrue();
        ResourceTable splitResourceTable = densitySplit.getResourceTable().get();
        // we are not verifying the default split in this test.
        if (densitySplit.getApkTargeting().equals(ApkTargeting.getDefaultInstance())) {
            continue;
        }
        assertThat(densitySplit.getApkTargeting().hasScreenDensityTargeting()).isTrue();
        switch(densitySplit.getApkTargeting().getScreenDensityTargeting().getValue(0).getDensityAlias()) {
            case LDPI:
                assertThat(splitResourceTable).containsResource("com.test.app:drawable/image").onlyWithConfigs(LDPI);
                break;
            case MDPI:
                assertThat(splitResourceTable).containsResource("com.test.app:drawable/image").onlyWithConfigs(MDPI);
                break;
            case TVDPI:
                assertThat(splitResourceTable).containsResource("com.test.app:drawable/image").onlyWithConfigs(TVDPI);
                break;
            case HDPI:
                assertThat(splitResourceTable).containsResource("com.test.app:drawable/image").onlyWithConfigs(HDPI);
                break;
            case XHDPI:
                assertThat(splitResourceTable).containsResource("com.test.app:drawable/image").onlyWithConfigs(XHDPI);
                break;
            case XXHDPI:
                assertThat(splitResourceTable).containsResource("com.test.app:drawable/image").onlyWithConfigs(XXHDPI);
                break;
            case XXXHDPI:
                assertThat(splitResourceTable).containsResource("com.test.app:drawable/image").onlyWithConfigs(XXXHDPI);
                break;
            default:
                break;
        }
    }
}
Also used : 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) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) ResourceTable(com.android.aapt.Resources.ResourceTable) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 18 with DensityAlias

use of com.android.bundle.Targeting.ScreenDensity.DensityAlias in project bundletool by google.

the class ModuleSplitterTest method testSplittingOnDensityAndLanguage_DensityPreferred.

@Test
public void testSplittingOnDensityAndLanguage_DensityPreferred() throws Exception {
    // This tests that we output only one dimension for splits and resources already split on
    // density are not split further on language.
    // Pure language targeted resources are going to be split on language though.
    BundleModule bundleModule = new BundleModuleBuilder("testModule").addFile("res/drawable-hdpi/image.jpg").addFile("res/drawable-fr-hdpi/image.jpg").addFile("res/drawable/image.jpg").setResourceTable(resourceTable(pkg(USER_PACKAGE_OFFSET, "com.test.app", type(0x01, "drawable", entry(0x01, "image", fileReference("res/drawable-fr-hdpi/image.jpg", mergeConfigs(locale("fr"), HDPI)), fileReference("res/drawable-hdpi/image.jpg", HDPI), fileReference("res/drawable/image.jpg", Configuration.getDefaultInstance()))), type(0x02, "strings", entry(0x01, "welcome_label", value("Hello", Configuration.getDefaultInstance()), value("Bienvenue", locale("fr"))))))).setManifest(androidManifest("com.test.app")).build();
    List<ModuleSplit> splits = createAbiDensityAndLanguageSplitter(bundleModule).splitModule();
    assertThat(splits.stream().map(ModuleSplit::getSplitType).distinct().collect(toImmutableSet())).containsExactly(SplitType.SPLIT);
    assertThat(splits.stream().map(ModuleSplit::getVariantTargeting).distinct().collect(toImmutableSet())).containsExactly(lPlusVariantTargeting());
    Map<String, ModuleSplit> splitsBySuffix = Maps.uniqueIndex(splits, ModuleSplit::getSuffix);
    // 7 density splits (ldpi, mdpi, tvdpi, hdpi, xhdpi, xxhdpi, xxxhdpi) + 1 language split
    // + 1 master split = 9 splits
    assertThat(splitsBySuffix.keySet()).containsExactly("ldpi", "mdpi", "tvdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi", "fr", "");
    ImmutableSet<DensityAlias> densities = ImmutableSet.of(DensityAlias.LDPI, DensityAlias.MDPI, DensityAlias.TVDPI, DensityAlias.HDPI, DensityAlias.XHDPI, DensityAlias.XXHDPI, DensityAlias.XXXHDPI);
    assertThat(splitsBySuffix.get("ldpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.LDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.LDPI)))));
    assertThat(splitsBySuffix.get("mdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.MDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.MDPI)))));
    assertThat(splitsBySuffix.get("tvdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.TVDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.TVDPI)))));
    assertThat(splitsBySuffix.get("hdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.HDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.HDPI)))));
    assertThat(splitsBySuffix.get("xhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.XHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XHDPI)))));
    assertThat(splitsBySuffix.get("xxhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.XXHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XXHDPI)))));
    assertThat(splitsBySuffix.get("xxxhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.XXXHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XXXHDPI)))));
    assertThat(splitsBySuffix.get("fr").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr")));
    assertThat(splitsBySuffix.get("").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(DEFAULT_MASTER_SPLIT_SDK_TARGETING);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 19 with DensityAlias

use of com.android.bundle.Targeting.ScreenDensity.DensityAlias in project bundletool by google.

the class ModuleSplitterTest method testSplittingOnDensityAndLanguage_inSameDirectory.

@Ignore("Re-enable when we support generating multiple dimension targeting splits.")
@Test
public void testSplittingOnDensityAndLanguage_inSameDirectory() throws Exception {
    BundleModule bundleModule = new BundleModuleBuilder("testModule").addFile("res/drawable-xhdpi/image.jpg").addFile("res/drawable-hdpi/image.jpg").addFile("res/drawable-fr-hdpi/image.jpg").addFile("res/drawable/image.jpg").setResourceTable(resourceTable(pkg(USER_PACKAGE_OFFSET, "com.test.app", type(0x01, "drawable", entry(0x01, "image", fileReference("res/drawable-xhdpi/image.jpg", XHDPI), fileReference("res/drawable-fr-hdpi/image.jpg", mergeConfigs(locale("fr"), HDPI)), fileReference("res/drawable-hdpi/image.jpg", HDPI), fileReference("res/drawable/image.jpg", Configuration.getDefaultInstance())))))).setManifest(androidManifest("com.test.app")).build();
    List<ModuleSplit> splits = createAbiDensityAndLanguageSplitter(bundleModule).splitModule();
    assertThat(splits.stream().map(ModuleSplit::getSplitType).distinct().collect(toImmutableSet())).containsExactly(SplitType.SPLIT);
    assertThat(splits.stream().map(ModuleSplit::getVariantTargeting).distinct().collect(toImmutableSet())).containsExactly(lPlusVariantTargeting());
    Map<String, ModuleSplit> splitsBySuffix = Maps.uniqueIndex(splits, ModuleSplit::getSuffix);
    // 7 density splits (ldpi, mdpi, tvdpi, hdpi, xhdpi, xxhdpi, xxxhdpi) x 2 language splits
    // (one default, one French) + 1 master split = 15
    assertThat(splitsBySuffix.keySet()).containsExactly("ldpi", "fr_ldpi", "mdpi", "fr_mdpi", "tvdpi", "fr_tvdpi", "hdpi", "fr_hdpi", "xhdpi", "fr_xhdpi", "xxhdpi", "fr_xxhdpi", "xxxhdpi", "fr_xxxhdpi", "");
    ImmutableSet<DensityAlias> densities = ImmutableSet.of(DensityAlias.LDPI, DensityAlias.MDPI, DensityAlias.TVDPI, DensityAlias.HDPI, DensityAlias.XHDPI, DensityAlias.XXHDPI, DensityAlias.XXXHDPI);
    assertThat(splitsBySuffix.get("ldpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.LDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.LDPI)))));
    assertThat(splitsBySuffix.get("fr_ldpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr"), apkDensityTargeting(DensityAlias.LDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.LDPI)))));
    assertThat(splitsBySuffix.get("mdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.MDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.MDPI)))));
    assertThat(splitsBySuffix.get("fr_mdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr"), apkDensityTargeting(DensityAlias.MDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.MDPI)))));
    assertThat(splitsBySuffix.get("tvdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.TVDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.TVDPI)))));
    assertThat(splitsBySuffix.get("fr_tvdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr"), apkDensityTargeting(DensityAlias.TVDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.TVDPI)))));
    assertThat(splitsBySuffix.get("hdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.HDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.HDPI)))));
    assertThat(splitsBySuffix.get("fr_hdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr"), apkDensityTargeting(DensityAlias.HDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.HDPI)))));
    assertThat(splitsBySuffix.get("xhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.XHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XHDPI)))));
    assertThat(splitsBySuffix.get("fr_xhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr"), apkDensityTargeting(DensityAlias.XHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XHDPI)))));
    assertThat(splitsBySuffix.get("xxhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.XXHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XXHDPI)))));
    assertThat(splitsBySuffix.get("fr_xxhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr"), apkDensityTargeting(DensityAlias.XXHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XXHDPI)))));
    assertThat(splitsBySuffix.get("xxxhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkDensityTargeting(DensityAlias.XXXHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XXXHDPI)))));
    assertThat(splitsBySuffix.get("fr_xxxhdpi").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkLanguageTargeting("fr"), apkDensityTargeting(DensityAlias.XXXHDPI, Sets.difference(densities, ImmutableSet.of(DensityAlias.XXXHDPI)))));
    assertThat(splitsBySuffix.get("").getApkTargeting()).ignoringRepeatedFieldOrder().isEqualTo(DEFAULT_MASTER_SPLIT_SDK_TARGETING);
}
Also used : BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) DensityAlias(com.android.bundle.Targeting.ScreenDensity.DensityAlias) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

DensityAlias (com.android.bundle.Targeting.ScreenDensity.DensityAlias)19 Test (org.junit.Test)17 ConfigValue (com.android.aapt.Resources.ConfigValue)12 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)10 BundleModule (com.android.tools.build.bundletool.model.BundleModule)8 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)8 ResourceTable (com.android.aapt.Resources.ResourceTable)5 ResourceTableBuilder (com.android.tools.build.bundletool.testing.ResourceTableBuilder)5 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)4 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 Configuration (com.android.aapt.ConfigurationOuterClass.Configuration)3 ScreenDensity (com.android.bundle.Targeting.ScreenDensity)3 ManifestMutator.withSplitsRequired (com.android.tools.build.bundletool.model.ManifestMutator.withSplitsRequired)3 ResourceId (com.android.tools.build.bundletool.model.ResourceId)3 DEFAULT_DENSITY_VALUE (com.android.tools.build.bundletool.model.utils.ResourcesUtils.DEFAULT_DENSITY_VALUE)3 Version (com.android.tools.build.bundletool.model.version.Version)3 ImmutableCollection (com.google.common.collect.ImmutableCollection)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 ImmutableSet (com.google.common.collect.ImmutableSet)3