use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class DumpManagerTest method createBundle.
private static void createBundle(Path bundlePath, ResourceTable resourceTable, BundleConfig bundleConfig) throws IOException {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app")).setResourceTable(resourceTable)).setBundleConfig(bundleConfig).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
}
use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class DumpManagerTest method dumpManifest_withXPath_multipleValues.
@Test
public void dumpManifest_withXPath_multipleValues() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app", withMetadataValue("key1", "value1"), withMetadataValue("key2", "value2")))).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.MANIFEST).setXPathExpression("/manifest/application/meta-data/@android:value").setOutputStream(new PrintStream(outputStream)).build().execute();
assertThat(new String(outputStream.toByteArray(), UTF_8)).isEqualTo(String.format("value1%n" + "value2%n"));
}
use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class DumpCommandTest method createBundleWithResourceTable.
private static void createBundleWithResourceTable(Path bundlePath, ResourceTable resourceTable) throws IOException {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app")).setResourceTable(resourceTable)).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
}
use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class CodeTransparencyValidatorTest method createBundle.
private void createBundle(Path path, CodeTransparency codeTransparency) throws Exception {
String transparencyPayload = JsonFormat.printer().print(codeTransparency);
AppBundleBuilder appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.test.app")).addFile(DEX_PATH, DEX_FILE_CONTENT).addFile(NATIVE_LIB_PATH, NATIVE_LIB_FILE_CONTENT)).addMetadataFile(BundleMetadata.BUNDLETOOL_NAMESPACE, BundleMetadata.TRANSPARENCY_SIGNED_FILE_NAME, CharSource.wrap(createJwsToken(transparencyPayload)).asByteSource(Charset.defaultCharset()));
new AppBundleSerializer().writeToDisk(appBundle.build(), path);
}
use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class TextureCompressionFormatParityValidatorTest method tcfsWithNoFallbackAndNoConfig_throws.
@Test
public void tcfsWithNoFallbackAndNoConfig_throws() throws Exception {
BundleModule moduleA = new BundleModuleBuilder("a").addFile("assets/textures#tcf_astc/level1.assets").addFile("assets/textures#tcf_etc2/level1.assets").setManifest(androidManifest("com.test.app")).build();
BundleModule moduleB = new BundleModuleBuilder("b").addFile("assets/other_textures#tcf_astc/astc_file.assets").addFile("assets/other_textures#tcf_etc2/etc2_file.assets").setManifest(androidManifest("com.test.app")).build();
AppBundle appBundle = new AppBundleBuilder().addModule(moduleA).addModule(moduleB).setBundleConfig(BundleConfigBuilder.create().addSplitDimension(Value.TEXTURE_COMPRESSION_FORMAT, /* negate= */
false).build()).build();
InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new TextureCompressionFormatParityValidator().validateBundle(appBundle));
assertThat(exception).hasMessageThat().contains("When a standalone or universal APK is built, the fallback texture folders (folders" + " without #tcf suffixes) will be used, but module 'a' has no such folders." + " Instead, it has folder(s) targeted for formats [ASTC, ETC2] (without fallback" + " directories). Either add missing folders or change the configuration for the" + " TEXTURE_COMPRESSION_FORMAT optimization to specify a default suffix" + " corresponding to the format to use in the standalone and universal APKs.");
}
Aggregations