use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpecFlags_inJavaViaProtos_equivalent.
@Test
public void deviceSpecFlags_inJavaViaProtos_equivalent() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
DeviceSpec deviceSpec = deviceWithSdk(28);
Path deviceSpecPath = createDeviceSpecFile(deviceSpec, tmpDir.resolve("device.json"));
BuildApksCommand commandViaFlags = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--device-spec=" + deviceSpecPath), new PrintStream(output), systemEnvironmentProvider, fakeAdbServer);
BuildApksCommand.Builder commandViaBuilder = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).setExecutorServiceInternal(commandViaFlags.getExecutorService()).setExecutorServiceCreatedByBundleTool(true).setOutputPrintStream(commandViaFlags.getOutputPrintStream().get());
DebugKeystoreUtils.getDebugSigningConfiguration(systemEnvironmentProvider).ifPresent(commandViaBuilder::setSigningConfiguration);
assertThat(commandViaBuilder.build()).isEqualTo(commandViaFlags);
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpecL_bundleTargetsPreL_throws.
@Test
public void deviceSpecL_bundleTargetsPreL_throws() throws Exception {
bundleSerializer.writeToDisk(createMaxSdkBundle(/* KitKat */
19), bundlePath);
DeviceSpec deviceSpec = lDeviceWithDensity(XHDPI);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpec).build();
Throwable exception = assertThrows(IncompatibleDeviceException.class, command::execute);
assertThat(exception).hasMessageThat().contains("App Bundle targets pre-L devices, but the device has SDK version " + "higher or equal to L.");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class BuildApksDeviceSpecTest method deviceSpecFlags_inJavaViaFiles_equivalent.
@Test
public void deviceSpecFlags_inJavaViaFiles_equivalent() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
DeviceSpec deviceSpec = deviceWithSdk(28);
Path deviceSpecPath = createDeviceSpecFile(deviceSpec, tmpDir.resolve("device.json"));
BuildApksCommand commandViaFlags = BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--device-spec=" + deviceSpecPath), new PrintStream(output), systemEnvironmentProvider, fakeAdbServer);
BuildApksCommand.Builder commandViaBuilder = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setDeviceSpec(deviceSpecPath).setExecutorServiceInternal(commandViaFlags.getExecutorService()).setExecutorServiceCreatedByBundleTool(true).setOutputPrintStream(commandViaFlags.getOutputPrintStream().get());
DebugKeystoreUtils.getDebugSigningConfiguration(systemEnvironmentProvider).ifPresent(commandViaBuilder::setSigningConfiguration);
assertThat(commandViaBuilder.build()).isEqualTo(commandViaFlags);
}
use of com.android.bundle.Devices.DeviceSpec 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.bundle.Devices.DeviceSpec in project bundletool by google.
the class InstallApksCommandTest method badSdkVersionDevice_throws.
@Test
public void badSdkVersionDevice_throws() throws Exception {
DeviceSpec deviceSpec = mergeSpecs(sdkVersion(1), density(480), abis("x86_64", "x86"), locales("en-US"));
FakeDevice fakeDevice = FakeDevice.fromDeviceSpec(DEVICE_ID, DeviceState.ONLINE, deviceSpec);
AdbServer adbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of(fakeDevice));
InstallApksCommand command = InstallApksCommand.builder().setApksArchivePath(simpleApksPath).setAdbPath(adbPath).setAdbServer(adbServer).build();
Throwable exception = assertThrows(IllegalStateException.class, () -> command.execute());
assertThat(exception).hasMessageThat().contains("Error retrieving device SDK version");
}
Aggregations