use of com.att.aro.core.peripheral.pojo.DeviceDetail in project VideoOptimzer by attdevsupport.
the class DeviceDetailReaderImplTest method readData.
@Test
public void readData() throws IOException {
Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true);
String[] arr = new String[] { "com.att.android.arodatacollector", "HTC One X", "HTC", "android", "4.0.4", "3.1.1.7", "-1", "720*1184", "" };
Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(arr);
DeviceDetail info = reader.readData("/");
assertEquals("com.att.android.arodatacollector", info.getCollectorName());
assertEquals("HTC One X", info.getDeviceModel());
assertEquals("HTC", info.getDeviceMake());
assertEquals("android", info.getOsType());
assertEquals("4.0.4", info.getOsVersion());
assertEquals("3.1.1.7", info.getCollectorVersion());
assertEquals("720*1184", info.getScreenSize());
assertTrue(info.getTotalLines() > 0);
}
use of com.att.aro.core.peripheral.pojo.DeviceDetail in project VideoOptimzer by attdevsupport.
the class VideoResolutionQualityImpl method presetResultsByDevice.
private BPResultType presetResultsByDevice(AbstractTraceResult traceResults) {
noDPIflag = false;
BPResultType resultType = BPResultType.NONE;
if (traceResults != null && traceResults instanceof TraceDirectoryResult) {
DeviceDetail deviceDetail = ((TraceDirectoryResult) traceResults).getDeviceDetail();
String deviceModel = deviceDetail.getDeviceModel();
String[] screenSize = deviceDetail.getScreenSize().split("\\*");
if (screenSize != null && screenSize.length > 0) {
double screenHeight = Double.valueOf(screenSize[0]);
if (deviceDetail.getOsType().equals("android") && deviceDetail.getScreenDensity() == 0) {
noDPIflag = true;
conditionalMessage = " " + noDPI;
resultType = BPResultType.SELF_TEST;
}
if (deviceModel.startsWith("iPad") || isTablet(screenHeight, deviceDetail.getScreenDensity())) {
resultType = BPResultType.PASS;
}
}
}
return resultType;
}
use of com.att.aro.core.peripheral.pojo.DeviceDetail in project VideoOptimzer by attdevsupport.
the class TraceDataReaderImpl method readDeviceDetails.
/**
* Reads a device data from the device file in trace folder.
*
* @throws IOException
*/
private void readDeviceDetails(TraceDirectoryResult result) {
DeviceDetail device = devicedetailreader.readData(result.getTraceDirectory());
if (device != null) {
result.setDeviceDetail(device);
if (device.getTotalLines() > 7) {
String line = device.getScreenSize();
if (null != line) {
String[] resolution = line.split("\\*");
result.setDeviceScreenSizeX(Integer.parseInt(resolution[0]));
result.setDeviceScreenSizeY(Integer.parseInt(resolution[1]));
}
}
}
}
use of com.att.aro.core.peripheral.pojo.DeviceDetail in project VideoOptimzer by attdevsupport.
the class DeviceDetailReaderImpl method readData.
@Override
public DeviceDetail readData(String directory) {
String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.DEVICEDETAILS_FILE;
DeviceDetail device = new DeviceDetail();
if (!filereader.fileExist(filepath)) {
return null;
}
String[] lines = null;
try {
lines = filereader.readAllLine(filepath);
} catch (IOException e) {
LOGGER.error("failed to read device detail file: " + filepath);
}
if (lines == null || lines.length < 1) {
return null;
}
device.setTotalLines(lines.length);
device.setCollectorName(lines[0]);
device.setDeviceModel(lines[1]);
device.setDeviceMake(lines[2]);
device.setOsType(lines[3]);
device.setOsVersion(lines[4]);
device.setCollectorVersion(lines[5]);
if (lines.length > 7) {
device.setScreenSize(lines[7]);
}
if (lines.length > 8) {
double screenDensity;
try {
screenDensity = Double.parseDouble(lines[8]);
} catch (NumberFormatException e) {
screenDensity = 0;
}
device.setScreenDensity(screenDensity);
}
return device;
}
use of com.att.aro.core.peripheral.pojo.DeviceDetail in project VideoOptimzer by attdevsupport.
the class TraceDataReaderImplTest method readTraceDir_.
@Test
public void readTraceDir_() throws IOException {
String[] time = { "1410212153 1410213352", "272927100", "1410213352.550" };
String[] appId = { "5", "5", "13", "-127" };
traceDataReaderImpl.setFileReader(filereader);
when(filereader.directoryExist(any(String.class))).thenReturn(true);
when(filereader.fileExist(any(String.class))).thenReturn(true);
when(filereader.readAllLine(any(String.class))).thenReturn(time);
when(filereader.readAllLine(Util.getCurrentRunningDir() + Util.FILE_SEPARATOR + "appid")).thenReturn(appId);
when(filereader.fileExist(Util.getCurrentRunningDir() + Util.FILE_SEPARATOR + "traffic1.cap")).thenReturn(false);
Map<String, List<ScheduledAlarmInfo>> scheduledAlarms = new HashMap<String, List<ScheduledAlarmInfo>>();
List<AlarmAnalysisInfo> statistics = new ArrayList<AlarmAnalysisInfo>();
AlarmAnalysisResult alarmResult = mock(AlarmAnalysisResult.class);
when(alarmResult.getScheduledAlarms()).thenReturn(scheduledAlarms);
when(alarmResult.getStatistics()).thenReturn(statistics);
when(alarmanalysisinfoparser.parse(any(String.class), any(String.class), any(String.class), any(double.class), any(double.class), any(Date.class))).thenReturn(alarmResult);
// Crypto
traceDataReaderImpl.setCrypto(crypto);
when(crypto.readSSLKeys(any(String.class))).thenReturn(1);
Mockito.doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) {
byte b = 3;
short s = 1;
InetAddress address1 = null;
InetAddress address2 = null;
try {
address2 = InetAddress.getByName("78.46.84.177");
address1 = InetAddress.getByName("78.46.84.171");
} catch (UnknownHostException e) {
e.printStackTrace();
}
Date date1 = new Date();
IPPacket ippack01 = mock(IPPacket.class);
when(ippack01.getIPVersion()).thenReturn(b);
when(ippack01.getFragmentOffset()).thenReturn(s);
when(ippack01.getSourceIPAddress()).thenReturn(address1);
when(ippack01.getDestinationIPAddress()).thenReturn(address2);
when(ippack01.getTimeStamp()).thenReturn((double) date1.getTime());
// pretend jpcap lib
traceDataReaderImpl.packetArrived("com.google.android.youtube", ippack01);
return null;
}
}).when(packetreader).readPacket(any(String.class), any(IPacketListener.class));
AppInfo app = new AppInfo();
Map<String, String> appMap = new HashMap<String, String>();
appMap.put("flipboard.app", "2.3.8");
appMap.put("com.att.android.arodatacollector", "3.1.1.6");
appMap.put("com.google.android.youtube", "4.0.23");
app.setAppVersionMap(appMap);
List<String> appInfos = new ArrayList<String>();
appInfos.add("flipboard.app");
appInfos.add("com.att.android.arodatacollector");
appInfos.add("com.google.android.youtube");
app.setAppInfos(appInfos);
when(appinforeader.readData(any(String.class))).thenReturn(app);
DeviceDetail device = new DeviceDetail();
device.setTotalLines(8);
device.setScreenSize("720*1280");
when(devicedetailreader.readData(any(String.class))).thenReturn(device);
CollectOptions cOptions = new CollectOptions();
when(collectOptionsReader.readData(any(String.class))).thenReturn(cOptions);
NetworkTypeObject obj = new NetworkTypeObject();
when(networktypereader.readData(any(String.class), any(double.class), any(double.class))).thenReturn(obj);
TraceDirectoryResult result = traceDataReaderImpl.readTraceDirectory(Util.getCurrentRunningDir());
assertSame(3, result.getAppIds().size());
}
Aggregations