use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class AdbRunnerTest method installApks_withDeviceId_disconnectedDevice_throws.
@Test
public void installApks_withDeviceId_disconnectedDevice_throws() {
FakeDevice disconnectedDevice = FakeDevice.inDisconnectedState("device2", DeviceState.UNAUTHORIZED);
AdbServer testAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of(FakeDevice.fromDeviceSpec("device1", DeviceState.ONLINE, lDeviceWithLocales("en-US")), disconnectedDevice));
testAdbServer.init(Paths.get("/test/adb"));
AdbRunner adbRunner = new AdbRunner(testAdbServer);
disconnectedDevice.setInstallApksSideEffect((apks, installOptions) -> {
throw CommandExecutionException.builder().withInternalMessage("Enable USB debugging on the connected device.").build();
});
Throwable exception = assertThrows(CommandExecutionException.class, () -> adbRunner.run(device -> device.installApks(ImmutableList.of(apkPath), DEFAULT_INSTALL_OPTIONS), "device2"));
assertThat(exception).hasMessageThat().contains("Enable USB debugging on the connected device.");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method deviceWithBadAbis_throws.
@Test
public void deviceWithBadAbis_throws() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(density(240), locales("en-US"), abis(), 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 ABIs. Please try again.");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method deviceIdMatch_otherUnsupportedState_throws.
@Test
public void deviceIdMatch_otherUnsupportedState_throws() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(FakeDevice.inDisconnectedState("a", DeviceState.BOOTLOADER)));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceAnalyzer analyzer = new DeviceAnalyzer(fakeAdbServer);
Throwable exception = assertThrows(CommandExecutionException.class, () -> analyzer.getDeviceSpec(Optional.of("a")));
assertThat(exception).hasMessageThat().contains("Unable to connect to the device (device state: 'BOOTLOADER')");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method deviceWithBadSdkVersion_throws.
@Test
public void deviceWithBadSdkVersion_throws() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, mergeSpecs(density(240), locales("en-US"), abis("armeabi"), sdkVersion(1)))));
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 SDK version. Please try again.");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method deviceId_multipleConnectedDevices_match.
@Test
public void deviceId_multipleConnectedDevices_match() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(createUsbEnabledDevice("a"), createUsbEnabledDevice("b", /* sdkVersion= */
23, /* locale= */
"pt-BR")));
fakeAdbServer.init(Paths.get("path/to/adb"));
DeviceSpec spec = new DeviceAnalyzer(fakeAdbServer).getDeviceSpec(Optional.of("b"));
assertThat(spec.getScreenDensity()).isEqualTo(480);
assertThat(spec.getSupportedAbisList()).containsExactly("armeabi");
assertThat(spec.getSdkVersion()).isEqualTo(23);
assertThat(spec.getSupportedLocalesList()).containsExactly("pt-BR");
}
Aggregations