@Test public void testSplitsDontHaveBundleConfigFiles() throws Exception { BundleModule bundleModule = new BundleModuleBuilder("testModule") .addFile("assets/dict.dat") .setManifest(androidManifest("com.test.app")) .setNativeConfig(NativeLibraries.getDefaultInstance()) .setAssetsConfig(Assets.getDefaultInstance()) .build(); ImmutableList<ModuleSplit> splits = createAbiAndDensitySplitter(bundleModule).splitModule(); assertThat(splits.stream().map(ModuleSplit::getSplitType).distinct().collect(toImmutableSet())) .containsExactly(SplitType.SPLIT); assertThat( splits .stream() .map(ModuleSplit::getVariantTargeting) .distinct() .collect(toImmutableSet())) .containsExactly(lPlusVariantTargeting()); assertThat(splits).isNotEmpty(); for (ModuleSplit split : splits) { ImmutableSet<ZipPath> pathEntries = split.getEntries().stream().map(ModuleEntry::getPath).collect(toImmutableSet()); assertThat(pathEntries).doesNotContain(ZipPath.create("native.pb")); assertThat(pathEntries).doesNotContain(ZipPath.create("assets.pb")); } }
androidManifest("com.test.app", withSplitId("moduleX"))) .addFileWithProtoContent( ZipPath.create("moduleX/assets.pb"), Assets.getDefaultInstance()) .addFileWithProtoContent( ZipPath.create("moduleX/native.pb"), NativeLibraries.getDefaultInstance())
@Test public void differentAssetsConfig_ok() throws Exception { String filePath = "assets.pb"; byte[] fileContentA = Assets.getDefaultInstance().toByteArray(); byte[] fileContentB = Assets.newBuilder() .addDirectory(TargetedAssetsDirectory.getDefaultInstance()) .build() .toByteArray(); assertThat(fileContentA).isNotEqualTo(fileContentB); BundleModule moduleA = new BundleModuleBuilder("a") .addFile(filePath, fileContentA) .setManifest(androidManifest("com.test.app")) .build(); BundleModule moduleB = new BundleModuleBuilder("b") .addFile(filePath, fileContentB) .setManifest(androidManifest("com.test.app")) .build(); new EntryClashValidator().validateAllModules(ImmutableList.of(moduleA, moduleB)); }
@Test public void specialFiles_areNotStoredAsEntries() throws Exception { BundleModule bundleModule = BundleModule.builder() .setName(BundleModuleName.create("testModule")) .setBundleConfig(DEFAULT_BUNDLE_CONFIG) .addEntry( InMemoryModuleEntry.ofFile( "manifest/AndroidManifest.xml", androidManifest("com.test.app").toByteArray())) .addEntry( InMemoryModuleEntry.ofFile("assets.pb", Assets.getDefaultInstance().toByteArray())) .addEntry( InMemoryModuleEntry.ofFile( "native.pb", NativeLibraries.getDefaultInstance().toByteArray())) .addEntry( InMemoryModuleEntry.ofFile( "resources.pb", ResourceTable.getDefaultInstance().toByteArray())) .build(); assertThat(bundleModule.getEntries()).isEmpty(); }