@Test public void teststopCollector_ThrowException() throws TimeoutException, AdbCommandRejectedException, IOException { when(device.getSyncService()).thenThrow(new IOException()); Date date = new Date(); when(videocapture.getVideoStartTime()).thenReturn(date); StatusResult testResult = rootedAndroidCollectorImpl.stopCollector(); assertEquals(211, testResult.getError().getCode()); }
@Override public StatusResult stopCollector() { log.info(Util.getMethod() + " stopCollector() for rooted-android-collector"); StatusResult result = new StatusResult(); this.running = false; if (device == null) { return result; } if (device.isEmulator()) { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getEmulator(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); android.stopTcpDump(device); while (android.isTraceRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } } result = pullTraceFromEmulator(); } else { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getRootedCollector(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); stopCollectorInDevice(); result = pullTrace(DEVICECOLLECTORFILENAMES); } if (isVideo()) { stopCaptureVideo(); } return result; }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult stopCollector() { log.info(Util.getMethod() + " stopCollector() for rooted-android-collector"); StatusResult result = new StatusResult(); this.running = false; if (device == null) { return result; } if (device.isEmulator()) { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getEmulator(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); android.stopTcpDump(device); while (android.isTraceRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } } result = pullTraceFromEmulator(); } else { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getRootedCollector(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); stopCollectorInDevice(); result = pullTrace(DEVICECOLLECTORFILENAMES); } if (isVideo()) { stopCaptureVideo(); } return result; } }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult stopCollector() { log.info(Util.getMethod() + " stopCollector() for rooted-android-collector"); StatusResult result = new StatusResult(); this.running = false; if (device == null) { return result; } if (device.isEmulator()) { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getEmulator(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); android.stopTcpDump(device); while (android.isTraceRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } } result = pullTraceFromEmulator(); } else { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getRootedCollector(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); stopCollectorInDevice(); result = pullTrace(DEVICECOLLECTORFILENAMES); } if (isVideo()) { stopCaptureVideo(); } return result; }  }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult stopCollector() { log.info(Util.getMethod() + " stopCollector() for rooted-android-collector"); StatusResult result = new StatusResult(); this.running = false; if (device == null) { return result; } if (device.isEmulator()) { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getEmulator(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); android.stopTcpDump(device); while (android.isTraceRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } } result = pullTraceFromEmulator(); } else { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getRootedCollector(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); stopCollectorInDevice(); result = pullTrace(DEVICECOLLECTORFILENAMES); } if (isVideo()) { stopCaptureVideo(); } return result; }  int getMilliSecondsForTimeout(); @Override String getName(); @Override void addDeviceStatusSubscriber(IDeviceStatus devicestatus); @Override void addVideoImageSubscriber(IVideoImageSubscriber subscriber); @Override int getMajorVersion(); @Override String getMinorVersion(); @Override DataCollectorType getType(); @Override boolean isRunning(); @Override String[] getLog(); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, String password); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, boolean isLiveViewVideo, String deviceId, Hashtable<String, Object> extraParams, String password); @Override void timeOutShutdown(); @Override void haltCollectorInDevice(); @Override boolean isTrafficCaptureRunning(int seconds); void startVideoCapture(); @Override StatusResult stopCollector(); @Override void receiveImage(BufferedImage videoimage); @Override String getPassword(); @Override boolean setPassword(String requestPassword); @Override String[] getDeviceSerialNumber(StatusResult status); @Override IAroDevice[] getDevices(StatusResult status); @Override boolean isDeviceDataPulled(); }
RootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult stopCollector() { log.info(Util.getMethod() + " stopCollector() for rooted-android-collector"); StatusResult result = new StatusResult(); this.running = false; if (device == null) { return result; } if (device.isEmulator()) { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getEmulator(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); android.stopTcpDump(device); while (android.isTraceRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } } result = pullTraceFromEmulator(); } else { GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendAnalyticsEvents(GoogleAnalyticsUtil.getAnalyticsEvents().getRootedCollector(), GoogleAnalyticsUtil.getAnalyticsEvents().getEndTrace()); stopCollectorInDevice(); result = pullTrace(DEVICECOLLECTORFILENAMES); } if (isVideo()) { stopCaptureVideo(); } return result; }  int getMilliSecondsForTimeout(); @Override String getName(); @Override void addDeviceStatusSubscriber(IDeviceStatus devicestatus); @Override void addVideoImageSubscriber(IVideoImageSubscriber subscriber); @Override int getMajorVersion(); @Override String getMinorVersion(); @Override DataCollectorType getType(); @Override boolean isRunning(); @Override String[] getLog(); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, String password); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace, VideoOption videoOption_old, boolean isLiveViewVideo, String deviceId, Hashtable<String, Object> extraParams, String password); @Override void timeOutShutdown(); @Override void haltCollectorInDevice(); @Override boolean isTrafficCaptureRunning(int seconds); void startVideoCapture(); @Override StatusResult stopCollector(); @Override void receiveImage(BufferedImage videoimage); @Override String getPassword(); @Override boolean setPassword(String requestPassword); @Override String[] getDeviceSerialNumber(StatusResult status); @Override IAroDevice[] getDevices(StatusResult status); @Override boolean isDeviceDataPulled();  }