/**
   * Run the test over device given.
   *
   * @param device the device to run the test.
   */
  public void run(final TestDevice device)
      throws DeviceDisconnectedException, ADBServerNeedRestartException {

    if ((getName() == null) || (getName().length() == 0)) {
      return;
    }

    if (TestSession.exceedsMaxCount()) {
      throw new ADBServerNeedRestartException("Test count reached overflow point");
    } else {
      TestSession.incTestCount();
    }

    mTestStop = false;
    mDevice = device;
    mTimeOutTimer =
        new HostTimer(new TimeOutTask(this), HostConfig.Ints.individualStartTimeoutMs.value());
    mTimeOutTimer.start();
    mProgressObserver = new ProgressObserver();
    mProgressObserver.start();

    setStartTime(System.currentTimeMillis());
    String testFullName = getFullName();
    print(testFullName + "...");

    runImpl();

    synchronized (mTimeOutTimer) {
      if (!mTestStop) {
        try {
          mTimeOutTimer.waitOn();
        } catch (InterruptedException e) {
          Log.d("time out object interrupted");
        }
      }

      mProgressObserver.stop();
      if (mTimeOutTimer.isTimeOut()) {
        return;
      } else {
        // not caused by timer timing out
        // need to cancel timer
        mTimeOutTimer.cancel(false);
      }
    }

    setResult(mResult);
  }