@Test
public void testSaveHeapDumpToFile() {

  Assume.assumeFalse("Unified pipeline import cannot yet be tested because of dependencies on TransportService.getInstance().",
                     myUnifiedPipeline);
  long startTimeNs = 3;
  long endTimeNs = 8;
  HeapDumpInfo dumpInfo = HeapDumpInfo.newBuilder().setStartTime(startTimeNs).setEndTime(endTimeNs).build();
  // Load in a simple Snapshot and verify the MemoryObject hierarchy:
  // - 1 holds reference to 2
  // - single root object in default heap
  SnapshotBuilder snapshotBuilder = new SnapshotBuilder(2, 0, 0)
    .addReferences(1, 2)
    .addRoot(1);
  byte[] buffer = snapshotBuilder.getByteBuffer();
  myTransportService.addFile(Long.toString(startTimeNs), ByteString.copyFrom(buffer));
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  MemoryProfiler.saveHeapDumpToFile(myStudioProfiler.getClient(), ProfilersTestData.SESSION_DATA, dumpInfo, baos,
                                    myStudioProfiler.getIdeServices().getFeatureTracker());
  assertArrayEquals(buffer, baos.toByteArray());
}