Search in sources :

Example 1 with StatusResult

use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.

the class RootedAndroidCollectorImplTest method teststopCollector_emulator_returnIsSuccess.

@Ignore
@Test
public void teststopCollector_emulator_returnIsSuccess() throws TimeoutException, AdbCommandRejectedException, IOException {
    doReturn(5).when(rootedAndroidCollectorImpl).getMilliSecondsForTimeout();
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    IDevice mockDevice = mock(IDevice.class);
    when(mockDevice.isEmulator()).thenReturn(true);
    SyncService service = mock(SyncService.class);
    when(mockDevice.getSyncService()).thenReturn(service);
    IDevice[] devlist = { mockDevice };
    when(mockDevice.getSerialNumber()).thenReturn("abc");
    try {
        when(adbservice.getConnectedDevices()).thenReturn(devlist);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        when(androidev.isAndroidRooted(any(IDevice.class))).thenReturn(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    when(android.isSDCardEnoughSpace(any(IDevice.class), any(long.class))).thenReturn(true);
    when(filemanager.fileExist(any(String.class))).thenReturn(true);
    when(extractor.extractFiles(any(String.class), any(String.class), any(ClassLoader.class))).thenReturn(true);
    when(android.pushFile(any(IDevice.class), any(String.class), any(String.class))).thenReturn(true);
    when(android.setExecutePermission(any(IDevice.class), any(String.class))).thenReturn(true);
    rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.LREZ, false, "abc", null, null);
    when(android.checkTcpDumpRunning(any(IDevice.class))).thenReturn(true);
    when(android.stopTcpDump(any(IDevice.class))).thenReturn(true);
    when(android.isTraceRunning()).thenReturn(false);
    Date date = new Date();
    when(mockDevice.isEmulator()).thenReturn(true);
    when(videocapture.getVideoStartTime()).thenReturn(date);
    when(videocapture.isVideoCaptureActive()).thenReturn(true);
    StatusResult testResult = rootedAndroidCollectorImpl.stopCollector();
    assertEquals(true, testResult.isSuccess());
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDevice(com.android.ddmlib.IDevice) SyncService(com.android.ddmlib.SyncService) TimeoutException(com.android.ddmlib.TimeoutException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) Date(java.util.Date) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with StatusResult

use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.

the class RootedAndroidCollectorImplTest method teststartCollector_returnIsErrorCode210.

@Ignore
@Test
public void teststartCollector_returnIsErrorCode210() {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    IDevice mockDevice = mock(IDevice.class);
    when(mockDevice.isEmulator()).thenReturn(false);
    IDevice[] devlist = { mockDevice };
    when(mockDevice.getSerialNumber()).thenReturn("abc");
    try {
        when(adbservice.getConnectedDevices()).thenReturn(devlist);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        when(androidev.isAndroidRooted(any(IDevice.class))).thenReturn(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    when(android.checkPackageExist(any(IDevice.class), any(String.class))).thenReturn(true);
    when(filemanager.fileExist(any(String.class))).thenReturn(true);
    String[] testarray = { "does not exist" };
    when(android.getShellReturn(any(IDevice.class), any(String.class))).thenReturn(testarray);
    StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, false, "abc", null, null);
    assertEquals(210, testResult.getError().getCode());
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDevice(com.android.ddmlib.IDevice) TimeoutException(com.android.ddmlib.TimeoutException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with StatusResult

use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.

the class RootedAndroidCollectorImplTest method teststartCollector_returnIsErrorCode201.

@Ignore
@Test
public void teststartCollector_returnIsErrorCode201() {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    IDevice mockDevice = mock(IDevice.class);
    when(mockDevice.isEmulator()).thenReturn(false);
    IDevice[] devlist = { mockDevice };
    when(mockDevice.getSerialNumber()).thenReturn("abc");
    try {
        when(adbservice.getConnectedDevices()).thenReturn(devlist);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        when(androidev.isAndroidRooted(any(IDevice.class))).thenReturn(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    when(android.checkPackageExist(any(IDevice.class), any(String.class))).thenReturn(false);
    StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, false, "abc", null, null);
    assertEquals(201, testResult.getError().getCode());
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDevice(com.android.ddmlib.IDevice) TimeoutException(com.android.ddmlib.TimeoutException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with StatusResult

use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.

the class RootedAndroidCollectorImplTest method teststartCollector_ThrowException.

@Ignore
@Test
public void teststartCollector_ThrowException() throws TimeoutException, AdbCommandRejectedException, IOException {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    IDevice mockDevice = mock(IDevice.class);
    IDevice[] devlist = { mockDevice };
    when(mockDevice.getSerialNumber()).thenReturn("abc");
    doThrow(new TimeoutException()).when(mockDevice).createForward(any(int.class), any(int.class));
    try {
        when(adbservice.getConnectedDevices()).thenReturn(devlist);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        when(androidev.isAndroidRooted(any(IDevice.class))).thenReturn(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, false, "abc", null, null);
    assertEquals(201, testResult.getError().getCode());
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IDevice(com.android.ddmlib.IDevice) TimeoutException(com.android.ddmlib.TimeoutException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) TimeoutException(com.android.ddmlib.TimeoutException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with StatusResult

use of com.att.aro.core.datacollector.pojo.StatusResult in project VideoOptimzer by attdevsupport.

the class RootedAndroidCollectorImplTest method testdirectoryExists.

@Test
public void testdirectoryExists() {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    when(filemanager.directoryExistAndNotEmpty(any(String.class))).thenReturn(true);
    StatusResult result = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.LREZ, false, "abc", null, null);
    assertEquals(false, result.isSuccess());
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) Test(org.junit.Test)

Aggregations

StatusResult (com.att.aro.core.datacollector.pojo.StatusResult)42 IOException (java.io.IOException)28 Test (org.junit.Test)20 AdbCommandRejectedException (com.android.ddmlib.AdbCommandRejectedException)19 TimeoutException (com.android.ddmlib.TimeoutException)19 IDevice (com.android.ddmlib.IDevice)17 Ignore (org.junit.Ignore)13 File (java.io.File)8 Date (java.util.Date)7 SyncService (com.android.ddmlib.SyncService)5 InstallException (com.android.ddmlib.InstallException)3 SyncException (com.android.ddmlib.SyncException)3 IAroDevice (com.att.aro.core.mobiledevice.pojo.IAroDevice)3 FileWriter (java.io.FileWriter)3 Hashtable (java.util.Hashtable)3 IDataCollector (com.att.aro.core.datacollector.IDataCollector)2 IVideoImageSubscriber (com.att.aro.core.datacollector.IVideoImageSubscriber)2 EnvironmentDetails (com.att.aro.core.datacollector.pojo.EnvironmentDetails)2 IFileManager (com.att.aro.core.fileio.IFileManager)2 AROAndroidDevice (com.att.aro.core.mobiledevice.pojo.AROAndroidDevice)2