UserEventDataSeries implements DataSeries<EventAction<UserEvent>> { @Override public List<SeriesData<EventAction<UserEvent>>> getDataForRange(@NotNull Range timeCurrentRangeUs) { if (myProfilers.getIdeServices().getFeatureConfig().isUnifiedPipelineEnabled()) { return getTransportData(timeCurrentRangeUs); } else { return getLegacyData(timeCurrentRangeUs); } } UserEventDataSeries(@NotNull StudioProfilers profilers); @Override List<SeriesData<EventAction<UserEvent>>> getDataForRange(@NotNull Range timeCurrentRangeUs);  }
@Test public void testRotationEvent() { buildRotationEvent(1); Range range = new Range(TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS), TimeUnit.NANOSECONDS.toMicros(TEST_END_TIME_NS)); List<SeriesData<EventAction<UserEvent>>> dataList = mySeries.getDataForRange(range); assertEquals(dataList.size(), 1); for (SeriesData<EventAction<UserEvent>> data : dataList) { assertEquals(data.x, TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(data.value.getStartUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(data.value.getEndUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(data.value.getType(), UserEvent.ROTATION); } }
@Test public void testTouchEvent() { buildTouchEvent(1); Range range = new Range(TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS), TimeUnit.NANOSECONDS.toMicros(TEST_END_TIME_NS)); List<SeriesData<EventAction<UserEvent>>> dataList = mySeries.getDataForRange(range); assertEquals(dataList.size(), 1); for (SeriesData<EventAction<UserEvent>> event : dataList) { assertEquals(event.x, TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getStartUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getEndUs(), TimeUnit.NANOSECONDS.toMicros(TEST_END_TIME_NS)); assertEquals(event.value.getType(), UserEvent.TOUCH); } }
@Test public void testKeyEvent() { buildKeyEvent(1); Range range = new Range(TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS), TimeUnit.NANOSECONDS.toMicros(TEST_END_TIME_NS)); List<SeriesData<EventAction<UserEvent>>> dataList = mySeries.getDataForRange(range); assertEquals(dataList.size(), 1); for (SeriesData<EventAction<UserEvent>> event : dataList) { assertEquals(event.x, TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getStartUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getEndUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getType(), UserEvent.KEYBOARD); assertEquals(((KeyboardAction)event.value).getData().toString(), "Hello"); } }
@Test public void testMixedEvent() { buildTouchEvent(1); buildRotationEvent(2); Range range = new Range(TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS), TimeUnit.NANOSECONDS.toMicros(TEST_END_TIME_NS)); List<SeriesData<EventAction<UserEvent>>> dataList = mySeries.getDataForRange(range); assertEquals(dataList.size(), 2); SeriesData<EventAction<UserEvent>> event = dataList.get(0); assertEquals(event.x, TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getStartUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getEndUs(), TimeUnit.NANOSECONDS.toMicros(TEST_END_TIME_NS)); assertEquals(event.value.getType(), UserEvent.TOUCH); event = dataList.get(1); assertEquals(event.x, TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getStartUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getEndUs(), TimeUnit.NANOSECONDS.toMicros(TEST_START_TIME_NS)); assertEquals(event.value.getType(), UserEvent.ROTATION); }