use of com.android.tools.build.bundletool.io.AppBundleSerializer in project bundletool by google.
the class BuildApksValidationTest method splits_textureFallbackNotPresentInAssetPacks.
@Test
public void splits_textureFallbackNotPresentInAssetPacks() 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#tcf_atc/atc_texture.dat").addFile("assets/textures#tcf_etc1/etc1_texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures#tcf_atc", assetsDirectoryTargeting(textureCompressionTargeting(ATC))), 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).build()).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).build();
// Splitting by texture compression format is activated, but the textures in
// one module don't include a fallback folder, used for standalone and universal
// APKs, so we'll consider the bundle invalid:
InvalidBundleException exception = assertThrows(InvalidBundleException.class, command::execute);
assertThat(exception).hasMessageThat().contains("the fallback texture folders (folders without #tcf suffixes) 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 createAppBundle.
private static void createAppBundle(Path path) throws IOException {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app")).build()).build();
new AppBundleSerializer().writeToDisk(appBundle, path);
}
use of com.android.tools.build.bundletool.io.AppBundleSerializer in project bundletool by google.
the class DumpManagerTest method dumpManifest_withXPath_noNamespaceDeclaration.
@Test
public void dumpManifest_withXPath_noNamespaceDeclaration() throws Exception {
XmlNode manifestWithoutNamespaceDeclaration = androidManifest("com.app", withDebuggableAttribute(true), manifestElement -> manifestElement.getProto().clearNamespaceDeclaration());
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(manifestWithoutNamespaceDeclaration)).build();
new AppBundleSerializer().writeToDisk(appBundle, bundlePath);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.MANIFEST).setXPathExpression("/manifest/application/@android:debuggable").setOutputStream(new PrintStream(outputStream)).build().execute();
assertThat(new String(outputStream.toByteArray(), UTF_8).trim()).isEqualTo("true");
}
use of com.android.tools.build.bundletool.io.AppBundleSerializer in project bundletool by google.
the class DumpManagerTest method dumpManifest_withXPath_nodeResult.
@Test
public void dumpManifest_withXPath_nodeResult() 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 dumpCommand = DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.MANIFEST).setXPathExpression("/manifest/application/meta-data").setOutputStream(new PrintStream(outputStream)).build();
assertThrows(UnsupportedOperationException.class, () -> dumpCommand.execute());
}
use of com.android.tools.build.bundletool.io.AppBundleSerializer 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);
}
Aggregations