Search in sources :

Example 11 with SyncService

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);
}
Also used : SyncService(com.android.ddmlib.SyncService) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 12 with SyncService

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, " ", " "));
}
Also used : ISyncProgressMonitor(com.android.ddmlib.SyncService.ISyncProgressMonitor) IDevice(com.android.ddmlib.IDevice) SyncService(com.android.ddmlib.SyncService) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 13 with SyncService

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, " ", " "));
}
Also used : ISyncProgressMonitor(com.android.ddmlib.SyncService.ISyncProgressMonitor) IDevice(com.android.ddmlib.IDevice) SyncService(com.android.ddmlib.SyncService) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 14 with SyncService

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;
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) SyncService(com.android.ddmlib.SyncService)

Example 15 with SyncService

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());
}
Also used : IVideoImageSubscriber(com.att.aro.core.datacollector.IVideoImageSubscriber) InputStream(java.io.InputStream) Hashtable(java.util.Hashtable) IVideoCapture(com.att.aro.core.video.IVideoCapture) IDevice(com.android.ddmlib.IDevice) IOException(java.io.IOException) SyncException(com.android.ddmlib.SyncException) SyncService(com.android.ddmlib.SyncService) TimeoutException(com.android.ddmlib.TimeoutException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) SyncException(com.android.ddmlib.SyncException) Date(java.util.Date) ISyncProgressMonitor(com.android.ddmlib.SyncService.ISyncProgressMonitor) StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) TimeoutException(com.android.ddmlib.TimeoutException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

SyncService (com.android.ddmlib.SyncService)18 Test (org.junit.Test)10 IOException (java.io.IOException)9 IDevice (com.android.ddmlib.IDevice)8 TimeoutException (com.android.ddmlib.TimeoutException)8 BaseTest (com.att.aro.core.BaseTest)7 AdbCommandRejectedException (com.android.ddmlib.AdbCommandRejectedException)6 ISyncProgressMonitor (com.android.ddmlib.SyncService.ISyncProgressMonitor)6 StatusResult (com.att.aro.core.datacollector.pojo.StatusResult)5 SyncException (com.android.ddmlib.SyncException)4 File (java.io.File)3 Date (java.util.Date)3 Ignore (org.junit.Ignore)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 FileEntry (com.android.ddmlib.FileListingService.FileEntry)1 IVideoImageSubscriber (com.att.aro.core.datacollector.IVideoImageSubscriber)1 IVideoCapture (com.att.aro.core.video.IVideoCapture)1 InputStream (java.io.InputStream)1 Hashtable (java.util.Hashtable)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1