use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class ModuleMatcherTest method matchesModuleTargeting_negative_featureNotPresent.
@Test
public void matchesModuleTargeting_negative_featureNotPresent() {
ModuleTargeting targeting = mergeModuleTargeting(moduleMinSdkVersionTargeting(21), moduleFeatureTargeting("feature1"));
DeviceSpec deviceSpecNoFeature = mergeSpecs(deviceWithSdk(21), deviceFeatures("feature2"));
ModuleMatcher moduleMatcher = new ModuleMatcher(deviceSpecNoFeature);
assertThat(moduleMatcher.matchesModuleTargeting(targeting)).isFalse();
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class GetDeviceSpecCommandTest method oneDevice_badSdkVersion_throws.
@Test
public void oneDevice_badSdkVersion_throws() throws Exception {
DeviceSpec deviceSpec = mergeSpecs(sdkVersion(1), density(360), abis("x86_64", "x86"), locales("en-US"));
Path outputPath = tmp.getRoot().toPath().resolve("device.json");
// We set up a fake ADB server because the real one won't work on Forge.
GetDeviceSpecCommand command = GetDeviceSpecCommand.builder().setAdbPath(adbPath).setAdbServer(fakeServerOneDevice(deviceSpec)).setOutputPath(outputPath).build();
Throwable exception = assertThrows(IllegalStateException.class, () -> command.execute());
assertThat(exception).hasMessageThat().contains("Error retrieving device SDK version");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class GetDeviceSpecCommandTest method nonExistentParentDirectory_works.
@Test
public void nonExistentParentDirectory_works() {
DeviceSpec deviceSpec = mergeSpecs(sdkVersion(21), density(480), abis("x86"), locales("en-US"));
Path outputPath = tmp.getRoot().toPath().resolve("non-existent-parent-directory").resolve("device.json");
GetDeviceSpecCommand command = GetDeviceSpecCommand.builder().setAdbPath(adbPath).setAdbServer(fakeServerOneDevice(deviceSpec)).setOutputPath(outputPath).build();
assertThat(command.execute()).isEqualTo(deviceSpec);
assertThat(Files.exists(outputPath)).isTrue();
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class ExtractApksCommandTest method deviceSpecViaJavaApi_invalid_throws.
@Test
public void deviceSpecViaJavaApi_invalid_throws() throws Exception {
DeviceSpec invalidDeviceSpec = deviceWithSdk(-1);
BuildApksResult tableOfContentsProto = minimalApkSet();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
Throwable exception = assertThrows(InvalidDeviceSpecException.class, () -> ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(invalidDeviceSpec).build());
assertThat(exception).hasMessageThat().contains("Device spec SDK version");
}
use of com.android.bundle.Devices.DeviceSpec in project bundletool by google.
the class ExtractApksCommandTest method builderAndFlagsConstruction_inJavaViaProtos_equivalent.
@Test
public void builderAndFlagsConstruction_inJavaViaProtos_equivalent() throws Exception {
DeviceSpec deviceSpec = deviceWithSdk(21);
Path deviceSpecFile = createDeviceSpecFile(deviceSpec, tmpDir.resolve("device.json"));
BuildApksResult tableOfContentsProto = minimalApkSet();
Path apksArchiveFile = createApksArchiveFile(tableOfContentsProto, tmpDir.resolve("bundle.apks"));
ExtractApksCommand fromFlags = ExtractApksCommand.fromFlags(new FlagParser().parse("--device-spec=" + deviceSpecFile, "--apks=" + apksArchiveFile));
ExtractApksCommand fromBuilderApi = ExtractApksCommand.builder().setApksArchivePath(apksArchiveFile).setDeviceSpec(deviceSpec).build();
assertThat(fromFlags).isEqualTo(fromBuilderApi);
}
Aggregations