use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpec_systemApkMode_partialDeviceSpecMissingDensity_throws.
@Test
@Theory
public void deviceSpec_systemApkMode_partialDeviceSpecMissingDensity_throws() throws Exception {
DeviceSpec deviceSpec = mergeSpecs(abis("arm64-v8a"));
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app"))).build();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand.Builder command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).setApkBuildMode(SYSTEM);
Throwable exception = assertThrows(InvalidCommandException.class, command::build);
assertThat(exception).hasMessageThat().contains("Device spec must have screen density and ABIs set when running with 'system' mode" + " flag.");
}
use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpec_systemApkMode_partialDeviceSpecMissingAbi_throws.
@Test
@Theory
public void deviceSpec_systemApkMode_partialDeviceSpecMissingAbi_throws() throws Exception {
DeviceSpec deviceSpec = mergeSpecs(density(DensityAlias.MDPI));
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app"))).build();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand.Builder command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).setApkBuildMode(SYSTEM);
Throwable exception = assertThrows(InvalidCommandException.class, command::build);
assertThat(exception).hasMessageThat().contains("Device spec must have screen density and ABIs set when running with 'system' mode" + " flag.");
}
use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class AddTransparencyCommandTest method createBundle.
private static void createBundle(Path path, boolean hasSharedUserId, int minSdkVersion) throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule(BASE_MODULE, module -> addCodeFilesToBundleModule(module, hasSharedUserId, minSdkVersion)).addModule(FEATURE_MODULE1, module -> addCodeFilesToBundleModule(module, hasSharedUserId, minSdkVersion)).addModule(FEATURE_MODULE2, module -> addCodeFilesToBundleModule(module, hasSharedUserId, minSdkVersion)).build();
new AppBundleSerializer().writeToDisk(appBundle, path);
}
use of com.android.tools.build.bundletool.testing.AppBundleBuilder in project bundletool by google.
the class BuildApksCommandTest method createAppBundle.
private void createAppBundle(Path path, Optional<CodeTransparency> codeTransparency) throws Exception {
AppBundleBuilder appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app")).build());
if (codeTransparency.isPresent()) {
appBundle.addMetadataFile(BundleMetadata.BUNDLETOOL_NAMESPACE, BundleMetadata.TRANSPARENCY_SIGNED_FILE_NAME, CharSource.wrap(createJwsToken(JsonFormat.printer().print(codeTransparency.get()))).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 BuildApksConnectedDeviceTest method connectedDevice_universalApk_throws.
@Test
public void connectedDevice_universalApk_throws() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", module -> module.setManifest(androidManifest("com.app"))).build();
bundleSerializer.writeToDisk(appBundle, bundlePath);
BuildApksCommand.Builder command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setGenerateOnlyForConnectedDevice(true).setApkBuildMode(UNIVERSAL).setAdbPath(sdkDirPath.resolve("platform-tools").resolve("adb")).setAdbServer(fakeAdbServer);
Throwable exception = assertThrows(InvalidCommandException.class, command::build);
assertThat(exception).hasMessageThat().contains("Optimizing for connected device only possible when running with 'default' mode flag.");
}
Aggregations