@Test
public void testgetAllocationInfosForSession() {

  Assume.assumeTrue(myUnifiedPipeline);
  Common.Session session = myStudioProfiler.getSession();
  // Insert a completed info.
  Memory.AllocationsInfo info1 = Memory.AllocationsInfo.newBuilder()
    .setStartTime(1).setEndTime(2).setSuccess(true).setLegacy(true).build();
  myTransportService.addEventToStream(
    session.getStreamId(),
    ProfilersTestData.generateMemoryAllocationInfoData(1, session.getPid(), info1).build());
  List<Memory.AllocationsInfo> infos = MemoryProfiler.getAllocationInfosForSession(myStudioProfiler.getClient(),
                                                                                   session,
                                                                                   new Range(0, 10),
                                                                                   myStudioProfiler.getIdeServices());
  Truth.assertThat(infos).containsExactly(info1);
  // Insert a not yet completed info followed up by a generic end event.
  Memory.AllocationsInfo info2 = Memory.AllocationsInfo.newBuilder().setStartTime(5).setEndTime(Long.MAX_VALUE).setLegacy(true).build();
  myTransportService.addEventToStream(
    session.getStreamId(),
    Common.Event.newBuilder().setTimestamp(5).setGroupId(5).setKind(Common.Event.Kind.MEMORY_ALLOC_TRACKING)
      .setPid(session.getPid())
      .setMemoryAllocTracking(Memory.MemoryAllocTrackingData.newBuilder().setInfo(info2))
      .build());
  myTransportService.addEventToStream(
    session.getStreamId(),
    Common.Event.newBuilder().setTimestamp(10).setGroupId(5).setKind(Common.Event.Kind.MEMORY_ALLOC_TRACKING)
      .setPid(session.getPid()).setIsEnded(true).build());
  infos = MemoryProfiler.getAllocationInfosForSession(myStudioProfiler.getClient(),
                                                      session,
                                                      new Range(0, 10),
                                                      myStudioProfiler.getIdeServices());
  Truth.assertThat(infos).containsExactly(info1, info2.toBuilder().setEndTime(session.getEndTimestamp()).setSuccess(false).build());
}