use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.
the class AccessingPeripheralImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
AccessingPeripheralResult result = new AccessingPeripheralResult();
AbstractTraceResult traceResult = tracedata.getTraceresult();
TraceDirectoryResult trresult = null;
if (traceResult != null && traceResult instanceof TraceDirectoryResult) {
trresult = (TraceDirectoryResult) traceResult;
}
if (trresult != null && isPeripheralDataAvailable(trresult)) {
double activeGPSRatio = 0.0;
double activeBluetoothRatio = 0.0;
double activeCameraRatio = 0.0;
double gpsActiveDuration = 0.0;
double bluetoothActiveDuration = 0.0;
double cameraActiveDuration = 0.0;
double duration = 0.0;
boolean accessingPeripherals = true;
TimeRange timeRange = null;
if (tracedata.getFilter() != null) {
timeRange = tracedata.getFilter().getTimeRange();
}
if (tracedata.getTraceresult().getTraceResultType() == TraceResultType.TRACE_DIRECTORY) {
gpsActiveDuration = trresult.getGpsActiveDuration();
bluetoothActiveDuration = trresult.getBluetoothActiveDuration();
cameraActiveDuration = trresult.getCameraActiveDuration();
}
if (timeRange != null) {
duration = timeRange.getEndTime() - timeRange.getBeginTime();
} else {
duration = tracedata.getTraceresult().getTraceDuration();
}
activeGPSRatio = (gpsActiveDuration * 100) / duration;
activeBluetoothRatio = (bluetoothActiveDuration * 100) / duration;
activeCameraRatio = (cameraActiveDuration * 100) / duration;
result.setActiveBluetoothRatio(activeBluetoothRatio);
result.setActiveCameraRatio(activeCameraRatio);
result.setActiveGPSRatio(activeGPSRatio);
result.setActiveBluetoothDuration(bluetoothActiveDuration);
result.setActiveCameraDuration(cameraActiveDuration);
result.setActiveGPSDuration(gpsActiveDuration);
if (activeGPSRatio > PERIPHERAL_ACTIVE_LIMIT || activeBluetoothRatio > PERIPHERAL_ACTIVE_LIMIT || activeCameraRatio > PERIPHERAL_ACTIVE_LIMIT) {
accessingPeripherals = false;
}
String cameraPer = "0";
NumberFormat nfor = NumberFormat.getIntegerInstance();
if (cameraActiveDuration != 0.0) {
if (activeCameraRatio < 1.0) {
cameraPer = Util.percentageFormat(activeCameraRatio);
} else {
cameraPer = nfor.format(activeCameraRatio);
}
}
String key = "";
if (accessingPeripherals) {
result.setResultType(BPResultType.PASS);
key = this.textResultPass;
} else {
// ref. old analyzer give warning in this best practice
result.setResultType(BPResultType.WARNING);
key = this.textResults;
}
String text = MessageFormat.format(key, activeGPSRatio, activeBluetoothRatio, cameraPer);
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, result.getResultType().getDescription(), activeGPSRatio, activeBluetoothRatio, cameraPer));
} else {
result.setResultText(noData);
result.setResultType(BPResultType.NO_DATA);
result.setResultExcelText(BPResultType.NO_DATA.getDescription());
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportAllBTDesc(exportAllBTDesc);
result.setExportAllCamDesc(exportAllCamDesc);
result.setExportAllGPSDesc(exportAllGPSDesc);
return result;
}
use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.
the class PacketAnalyzerImplTest method Test_analyzeTraceDirectory_returnIsPacketAnalyzerResult.
@Test
public void Test_analyzeTraceDirectory_returnIsPacketAnalyzerResult() throws Exception {
iPacketAnalyzer.setEnergyModelFactory(energymodelfactory);
iPacketAnalyzer.setBurstCollectionAnalayzer(burstcollectionanalyzer);
iPacketAnalyzer.setRrcStateMachineFactory(statemachinefactory);
iPacketAnalyzer.setProfileFactory(profilefactory);
TraceDirectoryResult mockTraceDirResult = mock(TraceDirectoryResult.class);
MetaDataHelper metaDataHelper = mock(MetaDataHelper.class);
MetaDataModel metaDataModel = new MetaDataModel();
AnalysisFilter filter = mock(AnalysisFilter.class);
filter.setIpv4Sel(true);
filter.setIpv6Sel(true);
filter.setUdpSel(true);
CpuActivityList cpuList = new CpuActivityList();
cpuList.add(new CpuActivity());
when(mockTraceDirResult.getCpuActivityList()).thenReturn(cpuList);
when(tracereader.readTraceDirectory(any(String.class))).thenReturn(mockTraceDirResult);
when(metaDataHelper.initMetaData(any(PacketAnalyzerResult.class))).thenReturn(metaDataModel);
ProfileLTE profileLTE = new ProfileLTE();
when(profilefactory.createLTEdefault()).thenReturn(profileLTE);
PacketAnalyzerResult testResult = iPacketAnalyzer.analyzeTraceDirectory("", profileLTE, filter);
assertEquals(null, testResult.getSessionlist());
}
use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.
the class PktAnazlyzerTimeRangeImplTest method getTimeRangeResultTest.
@Test
public void getTimeRangeResultTest() {
TraceDirectoryResult result = new TraceDirectoryResult();
List<UserEvent> userEvents = new ArrayList<UserEvent>();
userEvents.add(new UserEvent(UserEventType.KEY_HOME, 4.0, 3.0));
result.setUserEvents(userEvents);
List<GpsInfo> gpsInfos = new ArrayList<GpsInfo>();
gpsInfos.add(new GpsInfo(0.0, 0.9, GpsState.GPS_ACTIVE));
gpsInfos.add(new GpsInfo(1.0, 4.0, GpsState.GPS_ACTIVE));
gpsInfos.add(new GpsInfo(1.4, 12.0, GpsState.GPS_ACTIVE));
gpsInfos.add(new GpsInfo(12.4, 14.0, GpsState.GPS_ACTIVE));
result.setGpsInfos(gpsInfos);
List<BluetoothInfo> bluetoothInfos = new ArrayList<BluetoothInfo>();
bluetoothInfos.add(new BluetoothInfo(0.0, 3.0, BluetoothState.BLUETOOTH_CONNECTED));
bluetoothInfos.add(new BluetoothInfo(4.0, 10.0, BluetoothState.BLUETOOTH_CONNECTED));
bluetoothInfos.add(new BluetoothInfo(1.0, 13.0, BluetoothState.BLUETOOTH_DISCONNECTED));
bluetoothInfos.add(new BluetoothInfo(11.0, 16.0, BluetoothState.BLUETOOTH_CONNECTED));
result.setBluetoothInfos(bluetoothInfos);
List<CameraInfo> cameraInfos = new ArrayList<CameraInfo>();
cameraInfos.add(new CameraInfo(0.0, 1.0, CameraState.CAMERA_ON));
cameraInfos.add(new CameraInfo(3.0, 7.0, CameraState.CAMERA_ON));
cameraInfos.add(new CameraInfo(8.0, 14.0, CameraState.CAMERA_ON));
cameraInfos.add(new CameraInfo(1.0, 14.0, CameraState.CAMERA_ON));
cameraInfos.add(new CameraInfo(12.0, 15.0, CameraState.CAMERA_ON));
result.setCameraInfos(cameraInfos);
List<ScreenStateInfo> screenStateInfos = new ArrayList<ScreenStateInfo>();
ScreenStateInfo screenInfo01 = new ScreenStateInfo(0.0, 1.0, ScreenState.SCREEN_ON, " ", 5);
ScreenStateInfo screenInfo02 = new ScreenStateInfo(1.0, 12.0, ScreenState.SCREEN_ON, "", 3);
ScreenStateInfo screenInfo03 = new ScreenStateInfo(5.0, 9.0, ScreenState.SCREEN_ON, "", 2);
ScreenStateInfo screenInfo04 = new ScreenStateInfo(12.0, 15.0, ScreenState.SCREEN_ON, "", 4);
screenStateInfos.add(screenInfo01);
screenStateInfos.add(screenInfo02);
screenStateInfos.add(screenInfo03);
screenStateInfos.add(screenInfo04);
result.setScreenStateInfos(screenStateInfos);
List<RadioInfo> radioInfos = new ArrayList<RadioInfo>();
radioInfos.add(new RadioInfo(0.0, 3.0));
radioInfos.add(new RadioInfo(4.0, 8.0));
result.setRadioInfos(radioInfos);
List<BatteryInfo> batteryInfos = new ArrayList<BatteryInfo>();
batteryInfos.add(new BatteryInfo(3.0, true, 2, 3));
result.setBatteryInfos(batteryInfos);
List<WifiInfo> wifiInfos = new ArrayList<WifiInfo>();
wifiInfos.add(new WifiInfo(1.0, 2.0, WifiState.WIFI_CONNECTED, "", "", ""));
wifiInfos.add(new WifiInfo(1.0, 5.0, WifiState.WIFI_CONNECTING, "", "", ""));
wifiInfos.add(new WifiInfo(1.4, 13.0, WifiState.WIFI_CONNECTING, "", "", ""));
wifiInfos.add(new WifiInfo(9.0, 13.0, WifiState.WIFI_CONNECTING, "", "", ""));
result.setWifiInfos(wifiInfos);
List<NetworkType> networkTypesList = new ArrayList<NetworkType>();
networkTypesList.add(NetworkType.LTE);
result.setNetworkTypesList(networkTypesList);
List<NetworkBearerTypeInfo> networkTypeInfos = new ArrayList<NetworkBearerTypeInfo>();
networkTypeInfos.add(new NetworkBearerTypeInfo(1.0, 3.0, NetworkType.HSPA, NetworkType.OVERRIDE_NETWORK_TYPE_NONE));
networkTypeInfos.add(new NetworkBearerTypeInfo(8.0, 12.0, NetworkType.HSPA, NetworkType.OVERRIDE_NETWORK_TYPE_NONE));
result.setNetworkTypeInfos(networkTypeInfos);
TimeRange timeRange = new TimeRange(2.00, 11.00);
TraceDirectoryResult testResult = (TraceDirectoryResult) pktTimeUtil.getTimeRangeResult(result, timeRange);
assertEquals(1, testResult.getBatteryInfos().size());
assertEquals(2, testResult.getGpsInfos().size());
assertEquals(1, testResult.getBatteryInfos().size());
assertEquals(5, testResult.getCameraInfos().size());
assertEquals(2, testResult.getScreenStateInfos().size());
assertEquals(1, testResult.getRadioInfos().size());
assertEquals(3, testResult.getWifiInfos().size());
assertEquals(2, testResult.getNetworkTypeInfos().size());
}
use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.
the class AROServiceImplTest method analyzeDirectoryTest.
@Test
public void analyzeDirectoryTest() throws IOException {
TraceDirectoryResult traceresult = new TraceDirectoryResult();
List<PacketInfo> allpackets = new ArrayList<PacketInfo>();
allpackets.add(new PacketInfo(new Packet(0, 0, 0, 0, null)));
traceresult.setAllpackets(allpackets);
PacketAnalyzerResult analyze = new PacketAnalyzerResult();
analyze.setTraceresult(traceresult);
CacheAnalysis cacheAnalysis = new CacheAnalysis();
PeriodicTransferResult periodicTransferResult = new PeriodicTransferResult();
List<BestPracticeType> req = new ArrayList<BestPracticeType>();
req.add(BestPracticeType.UNNECESSARY_CONNECTIONS);
req.add(BestPracticeType.CONNECTION_CLOSING);
req.add(BestPracticeType.CONNECTION_OPENING);
req.add(BestPracticeType.PERIODIC_TRANSFER);
req.add(BestPracticeType.SCREEN_ROTATION);
req.add(BestPracticeType.ACCESSING_PERIPHERALS);
req.add(BestPracticeType.COMBINE_CS_JSS);
req.add(BestPracticeType.HTTP_1_0_USAGE);
req.add(BestPracticeType.CACHE_CONTROL);
req.add(BestPracticeType.USING_CACHE);
req.add(BestPracticeType.DUPLICATE_CONTENT);
req.add(BestPracticeType.HTTP_4XX_5XX);
req.add(BestPracticeType.HTTP_3XX_CODE);
req.add(BestPracticeType.FILE_COMPRESSION);
req.add(BestPracticeType.IMAGE_SIZE);
req.add(BestPracticeType.MINIFICATION);
req.add(BestPracticeType.EMPTY_URL);
req.add(BestPracticeType.SPRITEIMAGE);
req.add(BestPracticeType.SCRIPTS_URL);
req.add(BestPracticeType.ASYNC_CHECK);
req.add(BestPracticeType.DISPLAY_NONE_IN_CSS);
req.add(BestPracticeType.FILE_ORDER);
req.add(BestPracticeType.VIDEO_STALL);
req.add(BestPracticeType.STARTUP_DELAY);
req.add(BestPracticeType.BUFFER_OCCUPANCY);
req.add(BestPracticeType.NETWORK_COMPARISON);
req.add(BestPracticeType.TCP_CONNECTION);
req.add(BestPracticeType.CHUNK_SIZE);
req.add(BestPracticeType.CHUNK_PACING);
req.add(BestPracticeType.VIDEO_REDUNDANCY);
req.add(BestPracticeType.VIDEO_VARIABLE_BITRATE);
req.add(BestPracticeType.HTTPS_USAGE);
req.add(BestPracticeType.TRANSMISSION_PRIVATE_DATA);
req.add(BestPracticeType.DISPLAY_NONE_IN_CSS);
req.add(BestPracticeType.VIDEO_CONCURRENT_SESSION);
req.add(BestPracticeType.AUDIO_STREAM);
req.add(BestPracticeType.MULTI_SIMULCONN);
List<BestPracticeType> list = SettingsUtil.retrieveBestPractices();
SettingsUtil.saveBestPractices(req);
when(packetanalyzer.analyzeTraceDirectory(any(String.class), any(Profile.class), any(AnalysisFilter.class))).thenReturn(analyze);
when(worker.runTest(any(PacketAnalyzerResult.class))).thenReturn(periodicTransferResult);
when(cacheAnalyzer.analyze(anyListOf(Session.class))).thenReturn(cacheAnalysis);
try {
AROTraceData testResult = aro.analyzeDirectory(req, Util.getCurrentRunningDir());
assertEquals(null, testResult.getBestPracticeResults());
} finally {
SettingsUtil.saveBestPractices(list);
}
}
use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult 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