use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class DeviceAnalyzerTest method deviceIdMatch_debuggingNotEnabled_throws.
@Test
public void deviceIdMatch_debuggingNotEnabled_throws() {
FakeAdbServer fakeAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, /* devices= */
ImmutableList.of(FakeDevice.inDisconnectedState("a", DeviceState.UNAUTHORIZED)));
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("Device found but not authorized for connecting.");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class AdbRunnerTest method installApks_withDeviceId_connectedDevices_ok.
@Test
public void installApks_withDeviceId_connectedDevices_ok() {
AdbServer testAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of(FakeDevice.fromDeviceSpec("device1", DeviceState.ONLINE, lDeviceWithLocales("en-US")), FakeDevice.inDisconnectedState("device2", DeviceState.UNAUTHORIZED)));
testAdbServer.init(Paths.get("/test/adb"));
AdbRunner adbRunner = new AdbRunner(testAdbServer);
adbRunner.run(device -> device.installApks(ImmutableList.of(apkPath), DEFAULT_INSTALL_OPTIONS), "device1");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class AdbRunnerTest method installApks_noDeviceId_noConnectedDevices_throws.
@Test
public void installApks_noDeviceId_noConnectedDevices_throws() {
AdbServer testAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of());
testAdbServer.init(Paths.get("/test/adb"));
AdbRunner adbRunner = new AdbRunner(testAdbServer);
Throwable exception = assertThrows(CommandExecutionException.class, () -> adbRunner.run(device -> device.installApks(ImmutableList.of(apkPath), DEFAULT_INSTALL_OPTIONS)));
assertThat(exception).hasMessageThat().contains("Expected to find one connected device, but found none.");
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class AdbRunnerTest method installApks_noDeviceId_oneConnectedDevice_ok.
@Test
public void installApks_noDeviceId_oneConnectedDevice_ok() {
AdbServer testAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of(FakeDevice.fromDeviceSpec("a", DeviceState.ONLINE, lDeviceWithLocales("en-US"))));
testAdbServer.init(Paths.get("/test/adb"));
AdbRunner adbRunner = new AdbRunner(testAdbServer);
adbRunner.run(device -> device.installApks(ImmutableList.of(apkPath), DEFAULT_INSTALL_OPTIONS));
}
use of com.android.tools.build.bundletool.testing.FakeAdbServer in project bundletool by google.
the class AdbRunnerTest method installApks_noDeviceId_twoConnectedDevices_throws.
@Test
public void installApks_noDeviceId_twoConnectedDevices_throws() {
AdbServer testAdbServer = new FakeAdbServer(/* hasInitialDeviceList= */
true, ImmutableList.of(FakeDevice.fromDeviceSpec("a", DeviceState.ONLINE, lDeviceWithLocales("en-US")), FakeDevice.inDisconnectedState("b", DeviceState.UNAUTHORIZED)));
testAdbServer.init(Paths.get("/test/adb"));
AdbRunner adbRunner = new AdbRunner(testAdbServer);
Throwable exception = assertThrows(CommandExecutionException.class, () -> adbRunner.run(device -> device.installApks(ImmutableList.of(apkPath), DEFAULT_INSTALL_OPTIONS)));
assertThat(exception).hasMessageThat().contains("Expected to find one connected device, but found 2.");
}
Aggregations