MemoryInstanceDetailsView extends AspectObserver { @VisibleForTesting @Nullable JTree getReferenceTree() { return myReferenceTree; } MemoryInstanceDetailsView(@NotNull MemoryProfilerStage stage, @NotNull IdeProfilerComponents ideProfilerComponents);   }
@Test public void testGoToInstance() { FakeInstanceObject referer = new FakeInstanceObject.Builder(myFakeCaptureObject, 1, "REFERER").setFields(Collections.singletonList("mField")).build(); FakeInstanceObject referee = new FakeInstanceObject.Builder(myFakeCaptureObject, 2, "REFEREE").build(); referer.setFieldValue("mField", OBJECT, referee); myFakeCaptureObject.addInstanceObjects(ImmutableSet.of(referer, referee)); myStage.selectCaptureDuration( new CaptureDurationData<>(1, false, false, new CaptureEntry<CaptureObject>(new Object(), () -> myFakeCaptureObject)), null); assertNotNull(myStage.getSelectedCapture()); myStage .selectClassSet((ClassSet)myFakeCaptureObject.getHeapSet(FakeCaptureObject.DEFAULT_HEAP_ID).findContainingClassifierSet(referee)); assertNotNull(myStage.getSelectedClassSet()); myStage.selectInstanceObject(referee); JTree tree = myDetailsView.getReferenceTree(); assertNotNull(tree); assertEquals(referee, myStage.getSelectedInstanceObject()); List<ContextMenuItem> menus = myFakeIdeProfilerComponents.getComponentContextMenus(tree); assertNotNull(menus); assertEquals(1, menus.size()); assertEquals("Go to Instance", menus.get(0).getText()); assertFalse(menus.get(0).isEnabled()); TreeNode refNode = ((MemoryObjectTreeNode)tree.getModel().getRoot()).getChildAt(0); tree.setSelectionPath(new TreePath(refNode)); assertTrue(menus.get(0).isEnabled()); menus.get(0).run(); assertEquals(myFakeCaptureObject.getHeapSet(FakeCaptureObject.DEFAULT_HEAP_ID), myStage.getSelectedHeapSet()); assertNotNull(myStage.getSelectedClassSet()); assertEquals(myStage.getSelectedClassSet(), myStage.getSelectedClassSet().findContainingClassifierSet(referer)); assertEquals(referer, myStage.getSelectedInstanceObject()); }