.hasFile("base/manifest/AndroidManifest.xml") .withContent(manifest.toByteArray()); assertThat(bundle).hasFile("base/assets.pb").withContent(assetsConfig.toByteArray());
@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(); }
public BundleModuleBuilder setAssetsConfig(Assets assetsConfig) { addFile("assets.pb", assetsConfig.toByteArray()); return this; }
@Test public void correctAssetsProtoFile_parsedAndReturned() throws Exception { Assets assetsConfig = Assets.newBuilder() .addDirectory(TargetedAssetsDirectory.newBuilder().setPath("assets/data-armv6")) .build(); BundleModule bundleModule = createMinimalModuleBuilder() .addEntry(InMemoryModuleEntry.ofFile("assets.pb", assetsConfig.toByteArray())) .build(); assertThat(bundleModule.getAssetsConfig()).hasValue(assetsConfig); }