use of com.android.tools.build.bundletool.model.SourceStamp.StampType in project bundletool by google.
the class ModuleSplitterTest method testModuleSplitter_nativeSplit_addsNoStamp.
@Test
public void testModuleSplitter_nativeSplit_addsNoStamp() throws Exception {
String stampSource = "https://www.example.com";
StampType stampType = StampType.STAMP_TYPE_DISTRIBUTION_APK;
NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting("x86")));
BundleModule testModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeConfig).addFile("lib/x86/liba.so").build();
ModuleSplitter moduleSplitter = ModuleSplitter.create(testModule, BUNDLETOOL_VERSION, APP_BUNDLE, ApkGenerationConfiguration.builder().setOptimizationDimensions(ImmutableSet.of(ABI)).setEnableUncompressedNativeLibraries(true).build(), lPlusVariantTargeting(), ImmutableSet.of("testModule"), Optional.of(stampSource), stampType);
List<ModuleSplit> splits = moduleSplitter.splitModule();
// Base + x86 splits
assertThat(splits).hasSize(2);
ModuleSplit x86Split = splits.stream().filter(split -> split.getApkTargeting().hasAbiTargeting()).findFirst().get();
assertThat(x86Split.getAndroidManifest().getMetadataValue(STAMP_TYPE_METADATA_KEY)).isEmpty();
assertThat(x86Split.getAndroidManifest().getMetadataValue(STAMP_SOURCE_METADATA_KEY)).isEmpty();
}
use of com.android.tools.build.bundletool.model.SourceStamp.StampType in project bundletool by google.
the class ModuleSplitTest method testMasterBaseSplit_containsStamp.
@Test
public void testMasterBaseSplit_containsStamp() throws Exception {
ModuleSplit masterSplit = ModuleSplit.builder().setModuleName(BundleModuleName.create("base")).setApkTargeting(ApkTargeting.getDefaultInstance()).setVariantTargeting(lPlusVariantTargeting()).setAndroidManifest(AndroidManifest.create(androidManifest("com.test.app"))).setMasterSplit(true).build();
SourceStamp sourceStamp = SourceStamp.builder().setSource("https://www.example.com").setSigningConfiguration(stampSigningConfig).build();
StampType stampType = StampType.STAMP_TYPE_DISTRIBUTION_APK;
masterSplit = masterSplit.writeSourceStampInManifest(sourceStamp.getSource(), stampType);
assertThat(masterSplit.getAndroidManifest().getMetadataValue(STAMP_TYPE_METADATA_KEY)).hasValue(stampType.toString());
assertThat(masterSplit.getAndroidManifest().getMetadataValue(STAMP_SOURCE_METADATA_KEY)).hasValue(sourceStamp.getSource());
}
use of com.android.tools.build.bundletool.model.SourceStamp.StampType in project bundletool by google.
the class ModuleSplitTest method testNonMasterBaseSplit_doesNotContainStamp.
@Test
public void testNonMasterBaseSplit_doesNotContainStamp() throws Exception {
ModuleSplit abiSplit = ModuleSplit.builder().setModuleName(BundleModuleName.create("base")).setAndroidManifest(AndroidManifest.create(androidManifest("com.test.app"))).setVariantTargeting(lPlusVariantTargeting()).setApkTargeting(apkAbiTargeting(ImmutableSet.of(AbiAlias.X86), ImmutableSet.of(AbiAlias.X86))).setMasterSplit(false).build();
SourceStamp sourceStamp = SourceStamp.builder().setSource("https://www.example.com").setSigningConfiguration(stampSigningConfig).build();
StampType stampType = StampType.STAMP_TYPE_DISTRIBUTION_APK;
abiSplit = abiSplit.writeSourceStampInManifest(sourceStamp.getSource(), stampType);
assertThat(abiSplit.getAndroidManifest().getMetadataValue(STAMP_TYPE_METADATA_KEY)).isEmpty();
assertThat(abiSplit.getAndroidManifest().getMetadataValue(STAMP_SOURCE_METADATA_KEY)).isEmpty();
}
use of com.android.tools.build.bundletool.model.SourceStamp.StampType in project bundletool by google.
the class ModuleSplitTest method testStampSource_invalidUrl.
@Test
public void testStampSource_invalidUrl() throws Exception {
ModuleSplit masterSplit = ModuleSplit.builder().setModuleName(BundleModuleName.create("base")).setApkTargeting(ApkTargeting.getDefaultInstance()).setVariantTargeting(lPlusVariantTargeting()).setAndroidManifest(AndroidManifest.create(androidManifest("com.test.app"))).setMasterSplit(true).build();
SourceStamp sourceStamp = SourceStamp.builder().setSource("test-source").setSigningConfiguration(stampSigningConfig).build();
StampType stampType = StampType.STAMP_TYPE_DISTRIBUTION_APK;
Exception exception = assertThrows(IllegalArgumentException.class, () -> masterSplit.writeSourceStampInManifest(sourceStamp.getSource(), stampType));
assertThat(exception).hasMessageThat().contains("Invalid stamp source. Stamp sources should be URLs.");
}
use of com.android.tools.build.bundletool.model.SourceStamp.StampType in project bundletool by google.
the class ModuleSplitterTest method testModuleSplitter_baseSplit_addsStamp.
@Test
public void testModuleSplitter_baseSplit_addsStamp() throws Exception {
String stampSource = "https://www.example.com";
StampType stampType = StampType.STAMP_TYPE_DISTRIBUTION_APK;
BundleModule bundleModule = new BundleModuleBuilder("base").setManifest(androidManifest("com.test.app")).build();
ModuleSplitter moduleSplitter = ModuleSplitter.create(bundleModule, BUNDLETOOL_VERSION, APP_BUNDLE, ApkGenerationConfiguration.getDefaultInstance(), lPlusVariantTargeting(), ImmutableSet.of("base"), Optional.of(stampSource), stampType);
List<ModuleSplit> splits = moduleSplitter.splitModule();
// Base split
assertThat(splits).hasSize(1);
ModuleSplit baseSplit = getOnlyElement(splits);
assertThat(baseSplit.getAndroidManifest().getMetadataValue(STAMP_TYPE_METADATA_KEY)).hasValue(stampType.toString());
assertThat(baseSplit.getAndroidManifest().getMetadataValue(STAMP_SOURCE_METADATA_KEY)).hasValue(stampSource);
}
Aggregations