MemoryInstanceDetailsView extends AspectObserver { @NotNull JComponent getComponent() { return myTabsPanel; } MemoryInstanceDetailsView(@NotNull MemoryProfilerStage stage, @NotNull IdeProfilerComponents ideProfilerComponents);   }
@Test public void NullSelectionVisibilityTest() throws Exception { Component component = myDetailsView.getComponent(); assertNull(myStage.getSelectedInstanceObject()); assertFalse(component.isVisible()); }
@Test public void NoCallstackOrReferenceVisibilityTest() throws Exception { Component component = myDetailsView.getComponent(); FakeInstanceObject fakeInstanceObject = new FakeInstanceObject.Builder(myFakeCaptureObject, 1, "DUMMY_CLASS").build(); myFakeCaptureObject.addInstanceObjects(ImmutableSet.of(fakeInstanceObject)); myStage.selectCaptureDuration( new CaptureDurationData<>(1, false, false, new CaptureEntry<CaptureObject>(new Object(), () -> myFakeCaptureObject)), null); myStage.selectInstanceObject(fakeInstanceObject); assertFalse(component.isVisible()); }
@Test public void SelectionWithReferenceVisibilityTest() throws Exception { Component component = myDetailsView.getComponent(); FakeInstanceObject referee = new FakeInstanceObject.Builder(myFakeCaptureObject, 1, "REFEREE").setName("referee").build(); FakeInstanceObject referer = new FakeInstanceObject.Builder(myFakeCaptureObject, 2, "REFERER").setName("referee").setFields(Collections.singletonList("mField")) .build(); referer.setFieldValue("mField", OBJECT, referee); myFakeCaptureObject.addInstanceObjects(ImmutableSet.of(referee, referer)); myStage.selectCaptureDuration( new CaptureDurationData<>(1, false, false, new CaptureEntry<CaptureObject>(new Object(), () -> myFakeCaptureObject)), null); myStage.selectInstanceObject(referee); assertTrue(component.isVisible()); }
@Test public void SelectionWithCallstackVisibilityTest() throws Exception { Component component = myDetailsView.getComponent(); Memory.AllocationStack stack = Memory.AllocationStack.newBuilder().setFullStack( Memory.AllocationStack.StackFrameWrapper.newBuilder().addFrames( Memory.AllocationStack.StackFrame.newBuilder().setClassName("MockClass").setMethodName("MockMethod").setLineNumber(1))) .build(); FakeInstanceObject instance = new FakeInstanceObject.Builder(myFakeCaptureObject, 1, "DUMMY_CLASS").setAllocationStack(stack).build(); myFakeCaptureObject.addInstanceObjects(ImmutableSet.of(instance)); myStage.selectCaptureDuration( new CaptureDurationData<>(1, false, false, new CaptureEntry<CaptureObject>(new Object(), () -> myFakeCaptureObject)), null); myStage.selectInstanceObject(instance); assertTrue(component.isVisible()); }