commonApkGenerationConfiguration .toBuilder() .setForInstantAppVariants(true)
@Test public void splittingByCompression_preM_instantModule() throws Exception { NativeLibrariesCompressionSplitter nativeLibrariesCompressionSplitter = new NativeLibrariesCompressionSplitter( ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build()); ImmutableCollection<ModuleSplit> splits = nativeLibrariesCompressionSplitter.split( ModuleSplit.forNativeLibraries( createSingleLibraryModule("testModule", "x86", "lib/x86/libnoname.so"), lPlusVariantTargeting())); assertThat(splits).hasSize(1); ModuleSplit moduleSplit = Iterables.getOnlyElement(splits); assertThat(moduleSplit.getVariantTargeting()).isEqualTo(lPlusVariantTargeting()); assertThat(extractPaths(moduleSplit.getEntries())).containsExactly("lib/x86/libnoname.so"); assertThat(moduleSplit.isMasterSplit()).isTrue(); assertThat(moduleSplit.getApkTargeting()).isEqualToDefaultInstance(); assertThat(getShouldCompress(moduleSplit, "lib/x86/libnoname.so")).isFalse(); assertThat( compareManifestMutators( moduleSplit.getMasterManifestMutators(), withExtractNativeLibs(false))) .isTrue(); }
bundleModule, BUNDLETOOL_VERSION, ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build(), lPlusVariantTargeting(), ImmutableSet.of(),
.setEnableNativeLibraryCompressionSplitter(true) .setEnableDexCompressionSplitter(true) .setForInstantAppVariants(true) .build(), NO_RESOURCES_PINNED_TO_MASTER)
bundleModule, BUNDLETOOL_VERSION, ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build(), lPlusVariantTargeting(), ImmutableSet.of("testModule"),
@Test public void instantManifestChanges_keepsMinSdkVersion() throws Exception { BundleModule bundleModule = new BundleModuleBuilder("testModule") .setManifest(androidManifest("com.test.app", withMinSdkVersion(22), withInstant(true))) .build(); ImmutableList<ModuleSplit> moduleSplits = new ModuleSplitter( bundleModule, BUNDLETOOL_VERSION, ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build(), lPlusVariantTargeting(), ImmutableSet.of("testModule"), NO_RESOURCES_PINNED_TO_MASTER) .splitModule(); assertThat(moduleSplits).hasSize(1); ModuleSplit masterSplit = moduleSplits.get(0); assertThat(masterSplit.getVariantTargeting()).isEqualTo(lPlusVariantTargeting()); assertThat(masterSplit.isMasterSplit()).isTrue(); assertThat(masterSplit.getApkTargeting()).isEqualTo(apkMinSdkTargeting(21)); assertThat(masterSplit.getSplitType()).isEqualTo(SplitType.INSTANT); assertThat(masterSplit.getAndroidManifest().getTargetSandboxVersion()).hasValue(2); assertThat(masterSplit.getAndroidManifest().getMinSdkVersion()).hasValue(22); }
@Test public void instantManifestChanges_updatesMinSdkVersion() throws Exception { BundleModule bundleModule = new BundleModuleBuilder("testModule") .setManifest(androidManifest("com.test.app", withMinSdkVersion(19), withInstant(true))) .build(); ImmutableList<ModuleSplit> moduleSplits = new ModuleSplitter( bundleModule, BUNDLETOOL_VERSION, ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build(), lPlusVariantTargeting(), ImmutableSet.of("testModule"), NO_RESOURCES_PINNED_TO_MASTER) .splitModule(); assertThat(moduleSplits).hasSize(1); ModuleSplit masterSplit = moduleSplits.get(0); assertThat(masterSplit.getVariantTargeting()).isEqualTo(lPlusVariantTargeting()); assertThat(masterSplit.isMasterSplit()).isTrue(); assertThat(masterSplit.getApkTargeting()).isEqualTo(apkMinSdkTargeting(21)); assertThat(masterSplit.getSplitType()).isEqualTo(SplitType.INSTANT); assertThat(masterSplit.getAndroidManifest().getTargetSandboxVersion()).hasValue(2); assertThat(masterSplit.getAndroidManifest().getMinSdkVersion()).hasValue(21); }
@Test public void instantManifestChanges_addsMinSdkVersion() throws Exception { BundleModule bundleModule = new BundleModuleBuilder("testModule") .setManifest(androidManifest("com.test.app", withInstant(true))) .build(); ImmutableList<ModuleSplit> moduleSplits = new ModuleSplitter( bundleModule, BUNDLETOOL_VERSION, ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build(), lPlusVariantTargeting(), ImmutableSet.of("testModule"), NO_RESOURCES_PINNED_TO_MASTER) .splitModule(); assertThat(moduleSplits).hasSize(1); ModuleSplit masterSplit = moduleSplits.get(0); assertThat(masterSplit.getVariantTargeting()).isEqualTo(lPlusVariantTargeting()); assertThat(masterSplit.isMasterSplit()).isTrue(); assertThat(masterSplit.getApkTargeting()).isEqualTo(apkMinSdkTargeting(21)); assertThat(masterSplit.getSplitType()).isEqualTo(SplitType.INSTANT); assertThat(masterSplit.getAndroidManifest().getTargetSandboxVersion()).hasValue(2); assertThat(masterSplit.getAndroidManifest().getMinSdkVersion()).hasValue(21); }
@Test public void variantsWithNativeLibsDexFiles_withInstantModule_withNativeLibsAndDexOptimization() throws Exception { VariantGenerator variantGenerator = new VariantGenerator( createSingleLibraryDexModule(), ApkGenerationConfiguration.builder() .setForInstantAppVariants(true) .setEnableDexCompressionSplitter(true) .setEnableNativeLibraryCompressionSplitter(true) .build()); ImmutableCollection<VariantTargeting> splits = variantGenerator.generateVariants(); assertThat(splits).containsExactly(lPlusVariantTargeting()); }
@Test public void variantsWithNativeLibs_instantModule() throws Exception { NativeLibsCompressionVariantGenerator nativeLibsCompressionVariantGenerator = new NativeLibsCompressionVariantGenerator( ApkGenerationConfiguration.builder() .setForInstantAppVariants(true) .setEnableNativeLibraryCompressionSplitter(true) .build()); ImmutableCollection<VariantTargeting> splits = nativeLibsCompressionVariantGenerator.generate( createSingleLibraryModule("testModule", "x86", "lib/x86/libnoname.so")); assertThat(splits).isEmpty(); }
@Test public void variantsGeneration_withInstantModule_generatesNoVariant() throws Exception { DexCompressionVariantGenerator dexCompressionVariantGenerator = new DexCompressionVariantGenerator( ApkGenerationConfiguration.builder() .setForInstantAppVariants(true) .setEnableDexCompressionSplitter(true) .build()); ImmutableCollection<VariantTargeting> splits = dexCompressionVariantGenerator.generate(createModuleWithDexFile()); assertThat(splits).isEmpty(); }
@Test public void variantsWithNativeLibsDexFiles_withInstantModule_allOptimizationsDisabled() throws Exception { VariantGenerator variantGenerator = new VariantGenerator( createSingleLibraryDexModule(), ApkGenerationConfiguration.builder().setForInstantAppVariants(true).build()); ImmutableCollection<VariantTargeting> splits = variantGenerator.generateVariants(); assertThat(splits).containsExactly(lPlusVariantTargeting()); }