use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class ModuleSplitterTest method resolvesSplitIdSuffixes_singleVariant.
/**
* Tests that modules belonging to same variant with potentially same splitId, are resolved to
* different splitIds.
*/
@Test
public void resolvesSplitIdSuffixes_singleVariant() throws Exception {
// Note: this test will be extended once we add support for new directory groups.
ModuleSplit assetsSplit1 = ModuleSplit.builder().setModuleName(BundleModuleName.create("base")).setEntries(ImmutableList.of()).setApkTargeting(apkTextureTargeting(textureCompressionTargeting(ATC, ImmutableSet.of(S3TC)))).setMasterSplit(false).setAndroidManifest(AndroidManifest.create(androidManifest("com.test.app"))).setVariantTargeting(VariantTargeting.getDefaultInstance()).build();
ModuleSplit assetsSplit2 = ModuleSplit.builder().setModuleName(BundleModuleName.create("base")).setEntries(ImmutableList.of()).setApkTargeting(apkTextureTargeting(textureCompressionTargeting(ATC, ImmutableSet.of(ETC1_RGB8)))).setMasterSplit(false).setAndroidManifest(AndroidManifest.create(androidManifest("com.test.app"))).setVariantTargeting(VariantTargeting.getDefaultInstance()).build();
BundleModule bundleModule = new BundleModuleBuilder("base").setManifest(androidManifest("com.test.app")).build();
ModuleSplitter moduleSplitter = ModuleSplitter.createForTest(bundleModule, BUNDLETOOL_VERSION);
assetsSplit1 = moduleSplitter.writeSplitIdInManifest(assetsSplit1);
assetsSplit2 = moduleSplitter.writeSplitIdInManifest(assetsSplit2);
assertThat(assetsSplit1.getAndroidManifest().getSplitId()).hasValue("config.atc");
assertThat(assetsSplit2.getAndroidManifest().getSplitId()).hasValue("config.atc_2");
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class ModuleSplitterTest method splitNameRemovedForInstalledSplit.
@Test
public void splitNameRemovedForInstalledSplit() throws Exception {
XmlNode manifest = androidManifest("com.test.app", withMainActivity("MainActivity"), withSplitNameActivity("FooActivity", "foo"));
BundleModule bundleModule = new BundleModuleBuilder("testModule").setManifest(manifest).build();
ImmutableList<ModuleSplit> moduleSplits = ModuleSplitter.createForTest(bundleModule, BUNDLETOOL_VERSION).splitModule();
assertThat(moduleSplits).hasSize(1);
ModuleSplit masterSplit = moduleSplits.get(0);
ImmutableList<XmlElement> activities = masterSplit.getAndroidManifest().getManifestRoot().getElement().getChildElement("application").getChildrenElements(ACTIVITY_ELEMENT_NAME).map(XmlProtoElement::getProto).collect(toImmutableList());
assertThat(activities).hasSize(2);
XmlElement activityElement = activities.get(1);
assertThat(activityElement.getAttributeList()).containsExactly(xmlAttribute(ANDROID_NAMESPACE_URI, "name", NAME_RESOURCE_ID, "FooActivity"));
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class ModuleSplitterTest method addingLibraryPlaceholders_baseModule.
@Test
public void addingLibraryPlaceholders_baseModule() throws Exception {
BundleModule baseModule = new BundleModuleBuilder("base").addFile("dex/classes.dex").setManifest(androidManifest("com.test.app")).build();
ModuleSplitter moduleSplitter = ModuleSplitter.createNoStamp(baseModule, BUNDLETOOL_VERSION, APP_BUNDLE, ApkGenerationConfiguration.builder().setAbisForPlaceholderLibs(ImmutableSet.of(toAbi(AbiAlias.X86), toAbi(AbiAlias.ARM64_V8A))).build(), lPlusVariantTargeting(), ImmutableSet.of("base"));
ImmutableList<ModuleSplit> splits = moduleSplitter.splitModule();
assertThat(splits).hasSize(1);
ModuleSplit masterSplit = splits.get(0);
assertThat(masterSplit.isMasterSplit()).isTrue();
assertThat(extractPaths(masterSplit.getEntries())).containsExactly("dex/classes.dex", "lib/x86/libplaceholder.so", "lib/arm64-v8a/libplaceholder.so");
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class NativeLibrariesCompressionSplitterTest method otherEntriesCompressionUnchanged.
@Test
public void otherEntriesCompressionUnchanged() throws Exception {
NativeLibrariesCompressionSplitter nativeLibrariesCompressionSplitter = createSplitterWithEnabledUncompressedLibraries();
BundleModule bundleModule = new BundleModuleBuilder("testModule").addFile("lib/x86_64/libsome.so").addFile("assets/leftover.txt").addFile("dex/classes.dex").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(AbiAlias.X86_64)))).setManifest(androidManifest("com.test.app")).build();
ImmutableCollection<ModuleSplit> splits = nativeLibrariesCompressionSplitter.split(ModuleSplit.forModule(bundleModule, variantSdkTargeting(ANDROID_M_API_VERSION)));
assertThat(splits).hasSize(1);
assertThat(splits).hasSize(1);
ModuleSplit moduleSplit = Iterables.getOnlyElement(splits);
assertThat(moduleSplit.getVariantTargeting()).isEqualTo(variantSdkTargeting(ANDROID_M_API_VERSION));
assertThat(extractPaths(moduleSplit.getEntries())).containsExactly("lib/x86_64/libsome.so", "assets/leftover.txt", "dex/classes.dex");
assertThat(moduleSplit.isMasterSplit()).isTrue();
assertThat(getEntry(moduleSplit.getEntries(), "lib/x86_64/libsome.so").getForceUncompressed()).isTrue();
assertThat(getEntry(moduleSplit.getEntries(), "assets/leftover.txt").getForceUncompressed()).isFalse();
assertThat(getEntry(moduleSplit.getEntries(), "dex/classes.dex").getForceUncompressed()).isFalse();
assertThat(moduleSplit.getApkTargeting()).isEqualToDefaultInstance();
assertThat(compareManifestMutators(moduleSplit.getMasterManifestMutators(), withExtractNativeLibs(false))).isTrue();
}
use of com.android.tools.build.bundletool.testing.BundleModuleBuilder in project bundletool by google.
the class NativeLibsCompressionVariantGeneratorTest method variantsWithoutNativeLibs.
@Test
public void variantsWithoutNativeLibs() throws Exception {
NativeLibsCompressionVariantGenerator nativeLibsCompressionVariantGenerator = new NativeLibsCompressionVariantGenerator(ApkGenerationConfiguration.builder().setEnableUncompressedNativeLibraries(true).build());
BundleModule bundleModule = new BundleModuleBuilder("testModule").addFile("assets/leftover.txt").addFile("dex/classes.dex").setManifest(androidManifest("com.test.app")).build();
ImmutableCollection<VariantTargeting> splits = nativeLibsCompressionVariantGenerator.generate(bundleModule).collect(toImmutableList());
assertThat(splits).isEmpty();
}
Aggregations