@Test public void readData() throws IOException { Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true); Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(new String[] { "1414108436.923000 screen press" ,"1414108436.957000 screen release" ,"" ,"1414108463.785000 key volup press" ,"1414108464.059000 key volup release" ,"1414108466.065000 key voldown press" ,"1414108466.396000 key voldown release" ,"1414108473.096000 key power press" ,"1414108473.512000 key power release" ,"1414108473.512000 key ball press" ,"1414108473.512000 key ball release" ,"1414108473.512000 key home press" ,"1414108473.512000 key home release" ,"1414108473.512000 key menu press" ,"1414108473.512000 key menu release" ,"1414108473.512000 key back press" ,"1414108473.512000 key back release" ,"1414108473.512000 key search press" ,"1414108473.512000 key search release" ,"1414108473.512000 key green press" ,"1414108473.512000 key green release" ,"1414108473.512000 key red press" ,"1414108473.512000 key red release" ,"1414108473.512000 key key press" ,"1414108473.512000 key key release" ,"" }); List<UserEvent> listUserEvent = traceDataReader.readData(traceFolder, 0, 0); assertEquals(12.0, listUserEvent.size(), 0); assertEquals("SCREEN_TOUCH", listUserEvent.get(0).getEventType().toString()); assertEquals("KEY_VOLUP", listUserEvent.get(1).getEventType().toString()); assertEquals("KEY_VOLDOWN", listUserEvent.get(2).getEventType().toString()); assertEquals("KEY_POWER", listUserEvent.get(3).getEventType().toString()); assertEquals("KEY_BALL", listUserEvent.get(4).getEventType().toString()); assertEquals("KEY_HOME", listUserEvent.get(5).getEventType().toString()); assertEquals("KEY_MENU", listUserEvent.get(6).getEventType().toString()); assertEquals("KEY_BACK", listUserEvent.get(7).getEventType().toString()); assertEquals(1414108436.923000, listUserEvent.get(0).getPressTime(), 0); assertEquals(1414108436.957000, listUserEvent.get(0).getReleaseTime(), 0); assertEquals(1414108463.785000, listUserEvent.get(1).getPressTime(), 0); assertEquals(1414108464.059000, listUserEvent.get(1).getReleaseTime(), 0); assertEquals(1414108466.065000, listUserEvent.get(2).getPressTime(), 0); assertEquals(1414108466.396000, listUserEvent.get(2).getReleaseTime(), 0); assertEquals(1414108473.096000, listUserEvent.get(3).getPressTime(), 0); assertEquals(1414108473.512000, listUserEvent.get(3).getReleaseTime(), 0); }
@Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; } }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }  }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }  List<UserEvent> readGetEventsFile(String directory, double eventTime0, double startTime); @Override List<UserEvent> readData(String directory, double eventTime0, double startTime); }
UserEventReaderImpl extends PeripheralBase implements IUserEventReader { @Override public List<UserEvent> readData(String directory, double eventTime0, double startTime) { List<UserEvent> userEvents = new ArrayList<UserEvent>(); Map<UserEventType, Double> lastEvent = new EnumMap<UserEventType, Double>( UserEventType.class); String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_EVENTS_FILE; String getEventsFilePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.USER_GETEVENTS_FILE; if(filereader.fileExist(filepath)) { userEvents = readUserInputFile(lastEvent, filepath, startTime, eventTime0); } else if (filereader.fileExist(getEventsFilePath)) { userEvents = readGetEventsFile(directory, eventTime0, startTime); } return userEvents; }  List<UserEvent> readGetEventsFile(String directory, double eventTime0, double startTime); @Override List<UserEvent> readData(String directory, double eventTime0, double startTime);  }