private void testZenModeWithDuration(int mode,long durationMillis){
  final long startTimeMillis=System.currentTimeMillis();
  mPartnerInterface.setZenModeWithDuration(mode,durationMillis);
  final int actualZenMode=getZenMode();
  if (durationMillis == 0) {
    assertTrue(actualZenMode == mode || actualZenMode == PartnerInterface.ZEN_MODE_OFF);
  }
 else {
    assertEquals(mode,actualZenMode);
  }
  if (actualZenMode == PartnerInterface.ZEN_MODE_OFF || durationMillis < 0 || durationMillis == Long.MAX_VALUE) {
    return;
  }
  final long zenDuration=getZenModeDuration(startTimeMillis);
  assertTrue(Math.abs(zenDuration - durationMillis) <= DURATION_TOLERANCE_MS);
}

private void testZenModeWithDuration ( int mode , long durationMillis ) { final long startTimeMillis = System . currentTimeMillis ( ) ; mPartnerInterface . setZenModeWithDuration ( mode , durationMillis ) ; final int actualZenMode = getZenMode ( ) ; if ( durationMillis == 0 ) { assertTrue ( actualZenMode == mode || actualZenMode == PartnerInterface . ZEN_MODE_OFF ) ; } else { assertEquals ( mode , actualZenMode ) ; } if ( actualZenMode == PartnerInterface . ZEN_MODE_OFF || durationMillis < 0 || durationMillis == Long . MAX_VALUE ) { return ; } final long zenDuration = getZenModeDuration ( startTimeMillis ) ; assertTrue ( Math . abs ( zenDuration - durationMillis ) <= DURATION_TOLERANCE_MS ) ; }
testzenmodewithduration : sets zen mode with duration and blocks until the duration is verified . use with care ! this does not return until after durationmillis
