MemoryClassifierView extends AspectObserver { @VisibleForTesting @Nullable JTree getTree() { return myTree; } MemoryClassifierView(@NotNull MemoryProfilerStage stage, @NotNull IdeProfilerComponents ideProfilerComponents);   }
@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); 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); myStage.getStudioProfilers().getIdeServices().getCodeNavigator().navigate(codeLocation); myStage.getStudioProfilers().getIdeServices().getCodeNavigator().removeListener(myStage); assertThat(myStage.getProfilerMode()).isEqualTo(ProfilerMode.NORMAL); }