@Test
public void notifyUserIfDeviceDisconnectedDuringInstall() {

  // on an install request, return a failure on first install and a success on the 2nd install
  when (myInstaller.installApp(myDevice, myLaunchStatus))
    .thenAnswer(invocation -> {
      myStopWatchTimeSource.advance(50);
      return new InstallResult(InstallResult.FailureCode.DEVICE_NOT_FOUND, null, null);
    });
  when (myDevice.getName())
    .thenReturn("Test Device");
  // perform the installation
  RetryingInstallerResult installResult = myRetryingInstaller.install();
  assertThat(installResult.isSuccess()).isFalse();
  assertThat(installResult.getRetryCount()).isEqualTo(1);
  assertThat(installResult.getTotalDuration().toMillis()).isEqualTo(50);
  assertThat(installResult.getLastInstallDuration().toMillis()).isEqualTo(50);
  // verify that we got only 1 install requests (there is no retry for this error)
  verify(myInstaller, times(1)).installApp(myDevice, myLaunchStatus);
  // verify that we prompted the user
  verify(myPrompter).showErrorMessage(AndroidBundle.message(
    "deployment.failed.reason.devicedisconnected", myDevice.getName()));
}