@Test
public void navigationTest() {

  final String TEST_CLASS_NAME = "com.Foo";
  FakeCaptureObject captureObject = new FakeCaptureObject.Builder().build();
  InstanceObject instance1 =
    new FakeInstanceObject.Builder(captureObject, 1, TEST_CLASS_NAME).setName("instanceFoo1").setDepth(0)
      .setShallowSize(0).setRetainedSize(0).build();
  Set<InstanceObject> instanceObjects = new HashSet<>(Collections.singleton(instance1));
  captureObject.addInstanceObjects(instanceObjects);
  myStage
    .selectCaptureDuration(new CaptureDurationData<>(1, false, false, new CaptureEntry<CaptureObject>(new Object(), () -> captureObject)),
                           null);
  HeapSet heapSet = captureObject.getHeapSet(CaptureObject.DEFAULT_HEAP_ID);
  assertThat(heapSet).isNotNull();
  myStage.selectHeapSet(heapSet);
  assertThat(myStage.getConfiguration().getClassGrouping()).isEqualTo(ARRANGE_BY_CLASS);
  JTree classifierTree = myClassifierView.getTree();
  assertThat(classifierTree).isNotNull();
  Object root = classifierTree.getModel().getRoot();
  assertThat(root).isInstanceOf(MemoryObjectTreeNode.class);
  assertThat(((MemoryObjectTreeNode)root).getAdapter()).isInstanceOf(HeapSet.class);
  //noinspection unchecked
  MemoryObjectTreeNode<ClassifierSet> rootNode = (MemoryObjectTreeNode<ClassifierSet>)root;
  assertThat(rootNode.getChildCount()).isEqualTo(1);
  assertThat(myStage.getSelectedClassSet()).isNull();
  myStage.selectClassSet(findChildClassSetWithName(rootNode.getAdapter(), TEST_CLASS_NAME));
  myStage.selectInstanceObject(instance1);
  Supplier<CodeLocation> codeLocationSupplier = myFakeIdeProfilerComponents.getCodeLocationSupplier(classifierTree);
  assertThat(codeLocationSupplier).isNotNull();
  CodeLocation codeLocation = codeLocationSupplier.get();
  assertThat(codeLocation).isNotNull();
  String codeLocationClassName = codeLocation.getClassName();
  assertThat(codeLocationClassName).isEqualTo(TEST_CLASS_NAME);
  myStage.getStudioProfilers().getIdeServices().getCodeNavigator().addListener(myStage); // manually add, since we didn't enter stage
  myStage.getStudioProfilers().getIdeServices().getCodeNavigator().navigate(codeLocation);
  myStage.getStudioProfilers().getIdeServices().getCodeNavigator().removeListener(myStage);
  assertThat(myStage.getProfilerMode()).isEqualTo(ProfilerMode.NORMAL);
}