use of com.android.tools.build.bundletool.testing.BundleModuleBuilder 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.testing.BundleModuleBuilder 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.testing.BundleModuleBuilder 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.testing.BundleModuleBuilder 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();
}
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class SanitizerNativeLibrariesSplitterTest method splittingNoSanitizerLib.
@Test
public void splittingNoSanitizerLib() throws Exception {
NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/arm64-v8a", nativeDirectoryTargeting(ARM64_V8A)), targetedNativeDirectory("lib/arm64-v8a-hwasan", nativeDirectoryTargeting(ARM64_V8A, HWADDRESS)));
BundleModule bundleModule = new BundleModuleBuilder("testModule").setNativeConfig(nativeConfig).addFile("lib/arm64-v8a/libtest.so").setManifest(androidManifest("com.test.app")).build();
SanitizerNativeLibrariesSplitter sanitizerNativeLibrariesSplitter = new SanitizerNativeLibrariesSplitter();
ModuleSplit mainSplit = ModuleSplit.forNativeLibraries(bundleModule).toBuilder().setApkTargeting(apkAbiTargeting(ARM64_V8A)).setMasterSplit(false).build();
ImmutableCollection<ModuleSplit> splits = sanitizerNativeLibrariesSplitter.split(mainSplit);
assertThat(splits).hasSize(1);
ModuleSplit nonHwasanSplit = splits.asList().get(0);
assertThat(nonHwasanSplit.getApkTargeting()).isEqualTo(apkAbiTargeting(ARM64_V8A));
assertThat(extractPaths(nonHwasanSplit.getEntries())).containsExactly("lib/arm64-v8a/libtest.so");
}
Aggregations