use of com.android.tools.build.bundletool.io.AppBundleSerializer 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.io.AppBundleSerializer 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.io.AppBundleSerializer 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.io.AppBundleSerializer in project bundletool by google.
the class BuildApksValidationTest method splits_textureDefaultSuffixNotPresentInAssetPacks.
@Test
public void splits_textureDefaultSuffixNotPresentInAssetPacks() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.test.app")).setResourceTable(resourceTableWithTestLabel("Test feature"))).addModule("feature_tcf_assets", builder -> builder.addFile("assets/textures/untargeted_texture.dat").addFile("assets/textures#tcf_etc1/etc1_texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures", assetsDirectoryTargeting(alternativeTextureCompressionTargeting(ETC1_RGB8))), targetedAssetsDirectory("assets/textures#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(ETC1_RGB8))))).setManifest(androidManifestForFeature("com.test.app", withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).setBundleConfig(BundleConfigBuilder.create().addSplitDimension(Value.TEXTURE_COMPRESSION_FORMAT, /* negate= */
false, /* stripSuffix= */
false, /* defaultSuffix= */
"astc").build()).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).build();
// ASTC format is not present in one module with TCF targeting, so we'll
// consider the bundle invalid as the configuration specified that this is the default
// format to use for generating standalone or universal APKs.
InvalidBundleException exception = assertThrows(InvalidBundleException.class, command::execute);
assertThat(exception).hasMessageThat().contains("the texture folders for format 'ASTC' will be used, but module 'feature_tcf_assets'" + " has no such folders");
}
use of com.android.tools.build.bundletool.io.AppBundleSerializer in project bundletool by google.
the class BuildApksValidationTest method buildApksCommand_appTargetingPreL_failsGeneratingInstant.
@Test
public void buildApksCommand_appTargetingPreL_failsGeneratingInstant() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.app", withInstant(true), withMaxSdkVersion(20)))).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).build();
Throwable exception = assertThrows(InvalidBundleException.class, command::execute);
assertThat(exception).hasMessageThat().contains("maxSdkVersion (20) is less than minimum sdk allowed for instant apps (21).");
}
Aggregations