Search in sources :

Example 31 with StatusResult

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

the class RootedAndroidCollectorImplTest method teststartCollector_returnIsErrorCode209.

@Ignore
@Test
public void teststartCollector_returnIsErrorCode209() {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    IDevice mockDevice = mock(IDevice.class);
    when(mockDevice.isEmulator()).thenReturn(true);
    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(android.pushFile(any(IDevice.class), any(String.class), any(String.class))).thenReturn(false);
    StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, false, "abc", null, null);
    assertEquals(209, 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 32 with StatusResult

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

the class RootedAndroidCollectorImplTest method teststartCollector_returnIsErrorCode203.

// @Ignore
@Test
public void teststartCollector_returnIsErrorCode203() {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    IDevice[] devlist = {};
    try {
        when(adbservice.getConnectedDevices()).thenReturn(devlist);
    } catch (Exception e) {
        e.printStackTrace();
    }
    StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, false, "abc", null, null);
    assertEquals(203, 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) Test(org.junit.Test)

Example 33 with StatusResult

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

the class RootedAndroidCollectorImplTest method teststartCollector_returnIsErrorCode200.

// @Ignore
@Test
public void teststartCollector_returnIsErrorCode200() throws Exception {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    when(adbservice.getConnectedDevices()).thenThrow(new IOException("AndroidDebugBridge failed to start"));
    StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, null);
    assertEquals(200, testResult.getError().getCode());
}
Also used : StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) IOException(java.io.IOException) Test(org.junit.Test)

Example 34 with StatusResult

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

the class RootedAndroidCollectorImplTest method teststartCollector_returnIsErrorCode212.

@Ignore
@Test
public void teststartCollector_returnIsErrorCode212() {
    when(filemanager.directoryExist(any(String.class))).thenReturn(true);
    IDevice mockDevice = mock(IDevice.class);
    when(mockDevice.isEmulator()).thenReturn(true);
    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(false);
    StatusResult testResult = rootedAndroidCollectorImpl.startCollector(true, "", VideoOption.NONE, false, "abc", null, null);
    assertEquals(212, 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 35 with StatusResult

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

the class AROController method startCollector.

/**
 * Extract parameters from an AROCollectorActionEvent event. Initiate a
 * collection on Android and iOS devices
 *
 * @param event
 * @param actionCommand
 *                          - "startCollector" or "startCollectorIos"
 */
private void startCollector(ActionEvent event, String actionCommand) {
    StatusResult result;
    this.theView.updateCollectorStatus(CollectorStatus.STARTING, null);
    // reset so that a failure will be true
    this.theView.setDeviceDataPulled(true);
    if (event instanceof AROCollectorActionEvent) {
        IAroDevice device = ((AROCollectorActionEvent) event).getDevice();
        String traceName = ((AROCollectorActionEvent) event).getTrace();
        extraParams = ((AROCollectorActionEvent) event).getExtraParams();
        result = startCollector(device, traceName, extraParams);
        LOG.info("---------- result: " + result.toString());
        if (!result.isSuccess()) {
            // report failure
            if (result.getError().getCode() == 206) {
                try {
                    (new File(traceFolderPath)).delete();
                } catch (Exception e) {
                    LOG.warn("failed to delete trace folder :" + traceFolderPath);
                }
                this.theView.updateCollectorStatus(CollectorStatus.CANCELLED, result);
            } else {
                this.theView.updateCollectorStatus(null, result);
            }
        } else {
            // apk has launched and been activated
            if (!getVideoOption().equals(VideoOption.NONE) && "startCollector".equals(actionCommand)) {
                this.theView.liveVideoDisplay(collector);
            }
            this.theView.updateCollectorStatus(CollectorStatus.STARTED, result);
        }
        if (device.getPlatform().equals(IAroDevice.Platform.iOS)) {
            for (int i = 0; i < 30; i++) {
                try {
                    if (!result.isSuccess() && result.getError().getCode() == 529) {
                        this.theView.updateCollectorStatus(CollectorStatus.CANCELLED, result);
                        this.theView.stopCollector();
                        break;
                    } else {
                        Thread.sleep(1000);
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : IAroDevice(com.att.aro.core.mobiledevice.pojo.IAroDevice) StatusResult(com.att.aro.core.datacollector.pojo.StatusResult) File(java.io.File) IOException(java.io.IOException)

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