use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method noDeviceId_oneConnectedDevice_sdk26_fine.
@Test
public void noDeviceId_oneConnectedDevice_sdk26_fine() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(createUsbEnabledDevice("a", /* sdkVersion= */
26, /* locale= */
"pt-PT")));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceSpec spec = new DeviceAnalyzer(fakeAdbServer).getDeviceSpec(Optional.empty());
assertThat(spec.getScreenDensity()).isEqualTo(480);
assertThat(spec.getSupportedAbisList()).containsExactly("armeabi");
assertThat(spec.getSdkVersion()).isEqualTo(26);
assertThat(spec.getSupportedLocalesList()).containsExactly("pt-PT");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method extractsDeviceFeatures.
@Test
public void extractsDeviceFeatures() {
FakeDevice fakeDevice = FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(density(240), locales("en-US"), abis("x86"), sdkVersion(21), deviceFeatures("com.feature1", "com.feature2")));
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(fakeDevice));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
DeviceSpec deviceSpec = analyzer.getDeviceSpec(Optional.empty());
assertThat(deviceSpec.getDeviceFeaturesList()).containsExactly("com.feature1", "com.feature2");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method deviceWithBadDensity_throws.
@Test
public void deviceWithBadDensity_throws() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(density(-1), locales("en-US"), abis("armeabi"), sdkVersion(21)))));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
Throwable exception = assertThrows(IllegalStateException.class, () -> analyzer.getDeviceSpec(Optional.empty()));
assertThat(exception).hasMessageThat().contains("Error retrieving device density. Please try again.");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method deviceId_multipleConnectedDevices_noMatch.
@Test
public void deviceId_multipleConnectedDevices_noMatch() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(createUsbEnabledDevice("a"), createUsbEnabledDevice("b", /* sdkVersion= */
23, /* locale= */
"ja-JP")));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
Throwable exception = assertThrows(CommandExecutionException.class, () -> analyzer.getDeviceSpec(Optional.of("non_existent_id")));
assertThat(exception).hasMessageThat().contains("Unable to find the requested device.");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class BuildApksConnectedDeviceTest method connectedDeviceN_bundleTargetsLtoM.
@Test
public void connectedDeviceN_bundleTargetsLtoM() throws Exception {
fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of(FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(sdkVersion(/* Nougat */
25), abis("x86"), locales("en-US"), density(DensityAlias.XHDPI)))));
bundleSerializer.writeToDisk(createMinMaxSdkAppBundle(/* Lollipop */
21, /* Marshmallow */
23), bundlePath);
BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setGenerateOnlyForConnectedDevice(true).setAdbPath(sdkDirPath.resolve("platform-tools").resolve("adb")).setAdbServer(fakeAdbServer).build();
Throwable exception = assertThrows(IncompatibleDeviceException.class, command::execute);
assertThat(exception).hasMessageThat().contains("Max SDK version of the App Bundle is lower than SDK version of the device");
}
Aggregations