use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class AdbServiceImplTest method pullFile.
@Test
public void pullFile() throws Exception {
SyncService syncservice = Mockito.mock(SyncService.class);
Mockito.doNothing().when(syncservice).pullFile(Mockito.anyString(), Mockito.anyString(), (ISyncProgressMonitor) Mockito.any());
boolean success = adbService.pullFile(syncservice, "remote", "file", "local");
assertTrue(success);
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class AndroidImplTest method pullTraceFilesFromEmulator_returnIsFalse.
@Test
public void pullTraceFilesFromEmulator_returnIsFalse() throws TimeoutException, AdbCommandRejectedException, IOException, SyncException {
IDevice device = mock(IDevice.class);
SyncService syncServ = mock(SyncService.class);
when(device.getSyncService()).thenReturn(syncServ);
when(filereader.createFile(any(String.class), any(String.class))).thenReturn(folder.newFile("cpu"));
doThrow(SyncException.class).when(syncServ).pullFile(any(String.class), any(String.class), any(ISyncProgressMonitor.class));
assertFalse(androidImpl.pullTraceFilesFromEmulator(device, " ", " "));
doThrow(TimeoutException.class).when(syncServ).pullFile(any(String.class), any(String.class), any(ISyncProgressMonitor.class));
assertFalse(androidImpl.pullTraceFilesFromEmulator(device, " ", " "));
doThrow(IOException.class).when(syncServ).pullFile(any(String.class), any(String.class), any(ISyncProgressMonitor.class));
assertFalse(androidImpl.pullTraceFilesFromEmulator(device, " ", " "));
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class AndroidImplTest method pullTraceFilesFromEmulator_returnIsTrue.
@Test
public void pullTraceFilesFromEmulator_returnIsTrue() throws TimeoutException, AdbCommandRejectedException, IOException, SyncException {
IDevice device = mock(IDevice.class);
SyncService syncServ = mock(SyncService.class);
when(device.getSyncService()).thenReturn(syncServ);
doNothing().when(syncServ).pullFile(any(String.class), any(String.class), any(ISyncProgressMonitor.class));
when(filereader.createFile(any(String.class), any(String.class))).thenReturn(folder.newFile("cpu"));
assertTrue(androidImpl.pullTraceFilesFromEmulator(device, " ", " "));
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class NorootedAndroidCollectorImpl method pullTrace.
private StatusResult pullTrace(String[] files) {
StatusResult result = new StatusResult();
SyncService service = getSyncService();
if (service == null) {
result.setError(ErrorCodeRegistry.getFailSyncService());
return result;
}
String deviceTracePath = "";
String setCommand = "";
boolean commandFailure = false;
if (Util.isWindowsOS()) {
deviceTracePath = "/sdcard/ARO/";
setCommand = Util.wrapText(adbService.getAdbPath() + " -s " + device.getSerialNumber() + " pull " + deviceTracePath + ". " + Util.wrapText(localTraceFolder + "/ARO"));
commandFailure = runCommand(setCommand);
if (!commandFailure) {
setCommand = Util.wrapText("move " + Util.wrapText(localTraceFolder + "\\ARO\\*") + " " + Util.wrapText(localTraceFolder));
commandFailure = runCommand(setCommand);
}
if (!commandFailure) {
setCommand = Util.wrapText("rd " + Util.wrapText(localTraceFolder + "\\ARO"));
runCommand(setCommand);
}
if (!commandFailure) {
setCommand = Util.wrapText("rmdir /S /Q " + Util.wrapText(localTraceFolder + "\\ARO"));
}
} else {
deviceTracePath = "/sdcard/ARO/";
setCommand = adbService.getAdbPath() + " -s " + device.getSerialNumber() + " pull " + deviceTracePath + ". " + Util.wrapText(localTraceFolder);
commandFailure = runCommand(setCommand);
}
if (commandFailure) {
result.setError(ErrorCodeRegistry.getAdbPullFailure());
} else {
result.setSuccess(true);
}
return result;
}
use of com.android.ddmlib.SyncService in project VideoOptimzer by attdevsupport.
the class NorootedAndroidCollectorImplTest method stopCollector.
@Ignore
@Test
public void stopCollector() {
String[] str1 = {};
Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(str1);
String[] str2 = { "some ip " };
Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(str2);
try {
Mockito.doNothing().when(fileManager).saveFile(Mockito.any(InputStream.class), Mockito.anyString());
} catch (IOException IOExp) {
IOExp.printStackTrace();
}
Mockito.doNothing().when(videoCapture).stopRecording();
Mockito.when(android.removeEmulatorData(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(true);
StatusResult sResult = null;
SyncService sycService = null;
try {
Mockito.when(device.getSyncService()).thenReturn(sycService);
} catch (TimeoutException e1) {
e1.printStackTrace();
} catch (AdbCommandRejectedException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
sResult = nonRootedAndroidCollector.stopCollector();
assertEquals(411, sResult.getError().getCode());
sycService = Mockito.mock(SyncService.class);
try {
Mockito.when(device.getSyncService()).thenReturn(sycService);
} catch (TimeoutException e1) {
e1.printStackTrace();
} catch (AdbCommandRejectedException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
Mockito.doNothing().when(sycService).pullFile(Mockito.anyString(), Mockito.anyString(), Mockito.any(ISyncProgressMonitor.class));
} catch (SyncException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
sResult = nonRootedAndroidCollector.stopCollector();
assertTrue(sResult.isSuccess());
Hashtable<String, Object> extranalParams = new Hashtable<String, Object>();
Mockito.when(fileManager.directoryExistAndNotEmpty(Mockito.anyString())).thenReturn(false);
Mockito.doNothing().when(fileManager).mkDir(Mockito.anyString());
Mockito.when(fileManager.directoryExist(Mockito.anyString())).thenReturn(true);
IDevice aDevice1 = Mockito.mock(IDevice.class);
Mockito.when(aDevice1.getSerialNumber()).thenReturn("device1");
IDevice[] devices = { aDevice1 };
try {
Mockito.when(adbService.getConnectedDevices()).thenReturn(devices);
} catch (Exception exp) {
exp.printStackTrace();
}
Mockito.when(fileManager.fileExist(Mockito.anyString())).thenReturn(true);
Mockito.when(android.runApkInDevice(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(true);
String[] str3 = { "some ip ", "tun0: ip 10. some" };
Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(str3);
try {
Mockito.doNothing().when(videoCapture).init(Mockito.any(IDevice.class), Mockito.anyString());
Mockito.doNothing().when(videoCapture).addSubscriber(Mockito.any(IVideoImageSubscriber.class));
Mockito.doNothing().when(threadExecutor).execute(Mockito.any(IVideoCapture.class));
} catch (IOException e) {
e.printStackTrace();
}
nonRootedAndroidCollector.stopRunning();
Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(noVpnCon).thenReturn(vpnActive);
sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.LREZ, false, "device1", extranalParams, null);
assertTrue(sResult.isSuccess());
Date aDate = new Date();
Mockito.when(videoCapture.getVideoStartTime()).thenReturn(aDate);
sResult = nonRootedAndroidCollector.stopCollector();
assertEquals(411, sResult.getError().getCode());
}
Aggregations