LayeredPanel extends JBLayeredPane implements SideModel.Listener<T>, Disposable { @Override public void modelChanged(@NotNull SideModel<T> model, @NotNull SideModel.EventType unused) { model.getHiddenSliders().forEach(this::addHiddenTool); addVisibleTool(model.getVisibleAutoHideTool()); revalidate(); repaint(); } LayeredPanel(@NotNull String benchName, @NotNull JComponent defaultLayer, @NotNull SideModel<T> model);   LayeredPanel(@NotNull String benchName,
               @NotNull JComponent defaultLayer,
               @NotNull SideModel<T> model,
               @NotNull PropertiesComponent propertiesComponent); @Override void modelChanged(@NotNull SideModel<T> model, @NotNull SideModel.EventType unused); @Override void doLayout(); @Override void dispose();  }
@Test public void testNoVisibleTools() { when(myModel.getHiddenSliders()).thenReturn(ImmutableList.of(myToolWindow1, myToolWindow2)); myPanel.modelChanged(myModel, myEventType); assertThat(mySplitter.isVisible()).isFalse(); assertThat(myContainer.getComponents()).asList().containsExactly(myToolWindowComponent1, myToolWindowComponent2); }
@Test public void testVisibleToolOnLeftSide() { when(myModel.getHiddenSliders()).thenReturn(ImmutableList.of(myToolWindow2)); when(myModel.getVisibleAutoHideTool()).thenReturn(myToolWindow1); when(myToolWindow1.isLeft()).thenReturn(true); myPanel.modelChanged(myModel, myEventType); assertThat(mySplitter.isVisible()).isTrue(); assertThat(mySplitter.getFirstComponent()).isEqualTo(myToolWindowComponent1); assertThat(mySplitter.getLastComponent()).isNull(); assertThat(myContainer.getComponents()).asList().containsExactly(myToolWindowComponent2); }
@Test public void testVisibleToolOnRightSide() { when(myModel.getHiddenSliders()).thenReturn(ImmutableList.of(myToolWindow2)); when(myModel.getVisibleAutoHideTool()).thenReturn(myToolWindow1); when(myToolWindow1.isLeft()).thenReturn(false); myPanel.modelChanged(myModel, myEventType); assertThat(mySplitter.isVisible()).isTrue(); assertThat(mySplitter.getFirstComponent()).isNull(); assertThat(mySplitter.getLastComponent()).isEqualTo(myToolWindowComponent1); assertThat(myContainer.getComponents()).asList().containsExactly(myToolWindowComponent2); }
@Test public void testThatWidthIsMaintained() { when(myModel.getHiddenSliders()).thenReturn(ImmutableList.of(myToolWindow2)); when(myModel.getVisibleAutoHideTool()).thenReturn(myToolWindow1); when(myToolWindow1.isLeft()).thenReturn(true); myPanel.modelChanged(myModel, myEventType); mySplitter.setFirstSize(JBUI.scale(700)); fireWidthChanged(); assertThat(myPropertiesComponent.getInt(TOOL_WINDOW_PROPERTY_PREFIX + "BENCH.PALETTE.UNSCALED.WIDTH", -1)).isEqualTo(700); myPanel.modelChanged(myModel, myEventType); assertThat(mySplitter.getFirstSize()).isEqualTo(JBUI.scale(700)); }