@Test
public void reimportTraceShouldSelectSameSession() throws IOException {

  Assume.assumeFalse("Unified pipeline import cannot yet be tested because of dependencies on TransportService.getInstance().",
                     myUnifiedPipeline);
  myCpuProfiler = new CpuProfiler(myProfilers);
  File trace = CpuProfilerTestUtils.getTraceFile("valid_trace.trace");
  long traceCreationTime =
    Files.readAttributes(Paths.get(trace.getPath()), BasicFileAttributes.class).creationTime().to(TimeUnit.NANOSECONDS);
  SessionsManager sessionsManager = myProfilers.getSessionsManager();
  // Imported session's start time should be equal to the imported trace file creation time
  sessionsManager.importSessionFromFile(trace);
  assertThat(sessionsManager.getSelectedSession().getStartTimestamp()).isEqualTo(traceCreationTime);
  // Create and select a different session.
  sessionsManager.beginSession(FAKE_DEVICE, FAKE_PROCESS);
  assertThat(sessionsManager.getSelectedSession().getStartTimestamp()).isNotEqualTo(traceCreationTime);
  myTimer.tick(FakeTimer.ONE_SECOND_IN_NS);
  // Reimport again should select the existing session.
  sessionsManager.importSessionFromFile(trace);
  assertThat(sessionsManager.getSelectedSession().getStartTimestamp()).isEqualTo(traceCreationTime);
}