SideDockItem extends AbstractSideDockItem { void createButton() { itemButton.setSize(ButtonSize.SMALL); itemButton.setType(ButtonType.LINK); configureIcon(itemButton, getDock().getImageIcon()); String tooltip = getDock().getTooltip(); if (tooltip == null) { tooltip = getDock().getLabel(); } configureTooltip(itemTooltip, tooltip); itemButton.addStyleName(CSS.CSS().sideDockItem()); itemButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!isOpened()) { openAndExecuteExpandCommand(); } else { closeAndExecuteCommand(); } } }); } SideDockItem(UberfireDock dock,
                 final ParameterizedCommand<String> openCommand,
                 final ParameterizedCommand<String> closeCommand); @Override void open(); @Override void openAndExecuteExpandCommand(); @Override void close(); void closeAndExecuteCommand(); boolean isOpened();  }
@Test public void createSideDockItemWithFontIconTest() { sideDockWithFontIcon.createButton(); verify(sideDockWithFontIcon).configureIcon(any(Button.class), eq((ImageResource) null)); verify(sideDockWithFontIcon, never()).configureImageIcon(any(Button.class), any(ImageResource.class)); }
@Test public void createSideDockItemWithImageIconTest() { sideDockWithImageIcon.createButton(); verify(sideDockWithImageIcon).configureIcon(any(Button.class), eq(imageResource)); verify(sideDockWithImageIcon).configureImageIcon(any(Button.class), eq(imageResource)); }
@Test public void createSideDockItemWithTooltipTest() { final String dock_screenID = "SCREEN_ID"; final String dock_label = "DOCK TITLE"; final String dock_tooltip = "DOCK TOOLTIP"; UberfireDock dock1 = new UberfireDock(UberfireDockPosition.EAST, "BRIEFCASE", placeRequest, "") .withLabel(dock_label) .withTooltip(dock_tooltip); SideDockItem tested1 = spy(new SideDockItem(dock1, emptyCommand, emptyCommand)); tested1.createButton(); verify(tested1).configureTooltip(any(Tooltip.class), eq(dock_tooltip)); UberfireDock dock2 = new UberfireDock(UberfireDockPosition.EAST, "BRIEFCASE", placeRequest, "") .withLabel(dock_label); SideDockItem tested2 = spy(new SideDockItem(dock2, emptyCommand, emptyCommand)); tested2.createButton(); verify(tested2).configureTooltip(any(Tooltip.class), eq(dock_label)); UberfireDock dock3 = new UberfireDock(UberfireDockPosition.EAST, "BRIEFCASE", new DefaultPlaceRequest(dock_screenID), ""); SideDockItem tested3 = spy(new SideDockItem(dock3, emptyCommand, emptyCommand)); tested3.createButton(); verify(tested3).configureTooltip(any(Tooltip.class), eq(dock_screenID)); Tooltip tooltip = new Tooltip(); sideDockWithImageIcon.configureTooltip(tooltip, sideDockWithImageIcon.getLabel()); assertEquals(sideDockWithImageIcon.getLabel(), tooltip.getTitle()); assertEquals(Placement.LEFT, tooltip.getPlacement()); }