MinimizedPanel extends JPanel implements SideModel.Listener<T> { @Override public void modelChanged(@NotNull SideModel<T> model, @NotNull SideModel.EventType unused) { removeAll(); myHasVisibleButtons = false; model.getTopTools(mySide).forEach(this::addButton); add(myFiller); model.getBottomTools(mySide).forEach(this::addButton); setVisible(myHasVisibleButtons); revalidate(); repaint(); } MinimizedPanel(@NotNull Side side, @NotNull SideModel<T> model); @Override void modelChanged(@NotNull SideModel<T> model, @NotNull SideModel.EventType unused); int drag(@NotNull AttachedToolWindow<T> tool, int position); void dragExit(@NotNull AttachedToolWindow<T> tool); void dragDrop(@NotNull AttachedToolWindow<T> tool, int position);  }
@Test public void testEmptyMinimizedPanel() { when(myModel.getTopTools(Side.LEFT)).thenReturn(Collections.emptyList()); when(myModel.getBottomTools(Side.LEFT)).thenReturn(Collections.emptyList()); myPanel.modelChanged(myModel, SideModel.EventType.LOCAL_UPDATE); assertThat(myPanel.isVisible()).isFalse(); assertThat(findVisibleComponents(Split.TOP)).isEmpty(); assertThat(findVisibleComponents(Split.BOTTOM)).isEmpty(); assertThat(findHiddenComponents()).isEmpty(); }
@Test public void testAllToolsAreVisible() { when(myToolWindow1.isMinimized()).thenReturn(false); when(myToolWindow2.isMinimized()).thenReturn(false); when(myModel.getTopTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow1)); when(myModel.getBottomTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow2)); myPanel.modelChanged(myModel, SideModel.EventType.LOCAL_UPDATE); assertThat(myPanel.isVisible()).isFalse(); assertThat(findVisibleComponents(Split.TOP)).containsExactly(myButton1); assertThat(findVisibleComponents(Split.BOTTOM)).containsExactly(myButton2); assertThat(findHiddenComponents()).isEmpty(); }
@Test public void testAllToolsAreVisibleOneIsAutoHide() { when(myToolWindow1.isMinimized()).thenReturn(false); when(myToolWindow2.isMinimized()).thenReturn(false); when(myToolWindow2.isAutoHide()).thenReturn(true); when(myModel.getTopTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow1)); when(myModel.getBottomTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow2)); myPanel.modelChanged(myModel, SideModel.EventType.LOCAL_UPDATE); assertThat(myPanel.isVisible()).isTrue(); assertThat(findVisibleComponents(Split.TOP)).containsExactly(myButton1); assertThat(findVisibleComponents(Split.BOTTOM)).containsExactly(myButton2); assertThat(findHiddenComponents()).isEmpty(); }
@Test public void testOneToolVisible() { when(myToolWindow1.isMinimized()).thenReturn(false); when(myToolWindow2.isMinimized()).thenReturn(true); when(myModel.getTopTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow1)); when(myModel.getBottomTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow2)); myPanel.modelChanged(myModel, SideModel.EventType.LOCAL_UPDATE); assertThat(myPanel.isVisible()).isTrue(); assertThat(findVisibleComponents(Split.TOP)).containsExactly(myButton1); assertThat(findVisibleComponents(Split.BOTTOM)).containsExactly(myButton2); assertThat(findHiddenComponents()).isEmpty(); }
@Test public void testNoToolsVisible() { when(myToolWindow1.isMinimized()).thenReturn(true); when(myToolWindow2.isMinimized()).thenReturn(true); when(myModel.getTopTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow1)); when(myModel.getBottomTools(Side.LEFT)).thenReturn(Collections.singletonList(myToolWindow2)); myPanel.modelChanged(myModel, SideModel.EventType.LOCAL_UPDATE); assertThat(myPanel.isVisible()).isTrue(); assertThat(findVisibleComponents(Split.TOP)).containsExactly(myButton1); assertThat(findVisibleComponents(Split.BOTTOM)).containsExactly(myButton2); assertThat(findHiddenComponents()).isEmpty(); }