use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.
the class SplitApksGeneratorTest method multipleModules_withOnlyBaseModuleWithNativeLibraries.
@Test
public void multipleModules_withOnlyBaseModuleWithNativeLibraries() throws Exception {
ImmutableList<BundleModule> bundleModule = ImmutableList.of(new BundleModuleBuilder("base").addFile("assets/leftover.txt").addFile("lib/x86_64/libsome.so").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(AbiAlias.X86_64)))).build(), new BundleModuleBuilder("test").addFile("assets/test.txt").setManifest(androidManifest("com.test.app")).build());
ImmutableList<ModuleSplit> moduleSplits = splitApksGenerator.generateSplits(bundleModule, ApkGenerationConfiguration.builder().setEnableUncompressedNativeLibraries(true).build());
VariantTargeting lVariantTargeting = variantMinSdkTargeting(/* minSdkVersion= */
ANDROID_L_API_VERSION, /* alternativeSdkVersions...= */
ANDROID_M_API_VERSION);
VariantTargeting mVariantTargeting = variantMinSdkTargeting(/* minSdkVersion= */
ANDROID_M_API_VERSION, /* alternativeSdkVersions...= */
ANDROID_L_API_VERSION);
// 2 splits for L and M variants.
assertThat(moduleSplits).hasSize(4);
assertThat(moduleSplits.stream().map(ModuleSplit::getVariantTargeting).collect(toImmutableSet())).containsExactly(lVariantTargeting, mVariantTargeting);
ModuleSplit baseLModule = getModuleSplit(moduleSplits, lVariantTargeting, "base");
assertThat(baseLModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(baseLModule.getEntries())).containsExactly("assets/leftover.txt", "lib/x86_64/libsome.so");
assertThat(getForceUncompressed(baseLModule, "lib/x86_64/libsome.so")).isFalse();
ModuleSplit testLModule = getModuleSplit(moduleSplits, lVariantTargeting, "test");
assertThat(testLModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(testLModule.getEntries())).containsExactly("assets/test.txt");
ModuleSplit baseMModule = getModuleSplit(moduleSplits, mVariantTargeting, "base");
assertThat(baseMModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(baseMModule.getEntries())).containsExactly("assets/leftover.txt", "lib/x86_64/libsome.so");
assertThat(getForceUncompressed(baseMModule, "lib/x86_64/libsome.so")).isTrue();
ModuleSplit testMModule = getModuleSplit(moduleSplits, mVariantTargeting, "test");
assertThat(testMModule.getSplitType()).isEqualTo(SplitType.SPLIT);
assertThat(extractPaths(testMModule.getEntries())).containsExactly("assets/test.txt");
}
use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.
the class SplitApksGeneratorTest method multipleModules_multipleVariants_withTransparency.
@Test
public void multipleModules_multipleVariants_withTransparency() throws Exception {
TestComponent.useTestModule(this, TestModule.builder().withBundleMetadata(BUNDLE_METADATA_WITH_TRANSPARENCY).build());
ImmutableList<BundleModule> bundleModule = ImmutableList.of(new BundleModuleBuilder("base").addFile("assets/leftover.txt").addFile("lib/x86_64/libsome.so").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(AbiAlias.X86_64)))).build(), new BundleModuleBuilder("test").addFile("assets/test.txt").setManifest(androidManifest("com.test.app")).build());
ImmutableList<ModuleSplit> moduleSplits = splitApksGenerator.generateSplits(bundleModule, ApkGenerationConfiguration.builder().setOptimizationDimensions(ImmutableSet.of(OptimizationDimension.ABI)).build());
ApkTargeting minSdkLTargeting = apkMinSdkTargeting(/* minSdkVersion= */
ANDROID_L_API_VERSION);
ApkTargeting minSdkLWithAbiTargeting = mergeApkTargeting(apkAbiTargeting(AbiAlias.X86_64), minSdkLTargeting);
// 1 main and 1 ABI split for base module + test module.
assertThat(moduleSplits).hasSize(3);
assertThat(moduleSplits.stream().map(ModuleSplit::getApkTargeting).collect(toImmutableSet())).containsExactly(minSdkLTargeting, minSdkLWithAbiTargeting);
ModuleSplit mainSplitOfBaseModule = getModuleSplit(moduleSplits, minSdkLTargeting, /* moduleName= */
"base");
assertThat(extractPaths(mainSplitOfBaseModule.getEntries())).containsExactly("assets/leftover.txt", "META-INF/code_transparency_signed.jwt");
ModuleSplit abiSplitOfBaseModule = getModuleSplit(moduleSplits, minSdkLWithAbiTargeting, /* moduleName= */
"base");
assertThat(extractPaths(abiSplitOfBaseModule.getEntries())).containsExactly("lib/x86_64/libsome.so");
ModuleSplit testModule = getModuleSplit(moduleSplits, minSdkLTargeting, /* moduleName= */
"test");
assertThat(extractPaths(testModule.getEntries())).containsExactly("assets/test.txt");
}
use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.
the class TextureCompressionFormatAssetsSplitterTest method multipleTexturesAndDefaultSplit.
@Test
public void multipleTexturesAndDefaultSplit() throws Exception {
BundleModule testModule = new BundleModuleBuilder("testModule").addFile("assets/images#tcf_etc1/image.jpg").addFile("assets/images#tcf_3dc/image.jpg").addFile("assets/file.txt").setAssetsConfig(assets(targetedAssetsDirectory("assets/images#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8, ImmutableSet.of(TextureCompressionFormatAlias.THREE_DC)))), targetedAssetsDirectory("assets/images#tcf_3dc", assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.THREE_DC, ImmutableSet.of(TextureCompressionFormatAlias.ETC1_RGB8)))), targetedAssetsDirectory("assets", AssetsDirectoryTargeting.getDefaultInstance()))).setManifest(androidManifest("com.test.app")).build();
ModuleSplit baseSplit = ModuleSplit.forAssets(testModule);
Collection<ModuleSplit> assetsSplits = TextureCompressionFormatAssetsSplitter.create(/* stripTargetingSuffix= */
false).split(baseSplit);
assertThat(assetsSplits).hasSize(3);
List<ModuleSplit> defaultSplits = getSplitsWithDefaultTargeting(assetsSplits);
assertThat(defaultSplits).hasSize(1);
assertThat(extractPaths(defaultSplits.get(0).findEntriesUnderPath(ASSETS_DIRECTORY))).containsExactly("assets/file.txt");
List<ModuleSplit> etc1Splits = getSplitsWithTargetingEqualTo(assetsSplits, apkTextureTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8, ImmutableSet.of(TextureCompressionFormatAlias.THREE_DC))));
assertThat(etc1Splits).hasSize(1);
assertThat(extractPaths(etc1Splits.get(0).findEntriesUnderPath(ASSETS_DIRECTORY))).containsExactly("assets/images#tcf_etc1/image.jpg");
List<ModuleSplit> threeDcSplits = getSplitsWithTargetingEqualTo(assetsSplits, apkTextureTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.THREE_DC, ImmutableSet.of(TextureCompressionFormatAlias.ETC1_RGB8))));
assertThat(threeDcSplits).hasSize(1);
assertThat(extractPaths(threeDcSplits.get(0).findEntriesUnderPath(ASSETS_DIRECTORY))).containsExactly("assets/images#tcf_3dc/image.jpg");
}
use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.
the class TextureCompressionFormatAssetsSplitterTest method manifestMutatorToRequireSplits_notRegistered_whenNoTcfSpecificAssets.
@Test
public void manifestMutatorToRequireSplits_notRegistered_whenNoTcfSpecificAssets() throws Exception {
BundleModule testModule = new BundleModuleBuilder("testModule").addFile("assets/other/file.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/other", AssetsDirectoryTargeting.getDefaultInstance()))).setManifest(androidManifest("com.test.app")).build();
ModuleSplit baseSplit = ModuleSplit.forAssets(testModule);
ImmutableCollection<ModuleSplit> assetsSplits = TextureCompressionFormatAssetsSplitter.create(/* stripTargetingSuffix= */
false).split(baseSplit);
assertThat(assetsSplits).hasSize(1);
assertThat(assetsSplits.asList().get(0).getMasterManifestMutators()).isEmpty();
}
use of com.android.tools.build.bundletool.model.BundleModule in project bundletool by google.
the class TextureCompressionFormatAssetsSplitterTest method manifestMutatorToRequireSplits_registered_whenTcfSpecificAssetsPresent.
@Test
public void manifestMutatorToRequireSplits_registered_whenTcfSpecificAssetsPresent() throws Exception {
BundleModule testModule = new BundleModuleBuilder("testModule").addFile("assets/images#tcf_etc1/image.jpg").setAssetsConfig(assets(targetedAssetsDirectory("assets/images#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(TextureCompressionFormatAlias.ETC1_RGB8, ImmutableSet.of(TextureCompressionFormatAlias.THREE_DC)))))).setManifest(androidManifest("com.test.app")).build();
ModuleSplit baseSplit = ModuleSplit.forAssets(testModule);
ImmutableCollection<ModuleSplit> assetsSplits = TextureCompressionFormatAssetsSplitter.create(/* stripTargetingSuffix= */
false).split(baseSplit);
ImmutableList<ModuleSplit> configSplits = assetsSplits.stream().filter(split -> !split.isMasterSplit()).collect(toImmutableList());
assertThat(configSplits).isNotEmpty();
for (ModuleSplit configSplit : configSplits) {
assertThat(compareManifestMutators(configSplit.getMasterManifestMutators(), withSplitsRequired(true))).isTrue();
}
}
Aggregations