SideMenu extends HorizontalLayout { public MenuRegistration addTreeItem(String rootItem, MenuClickHandler clickHandler) { ensureTreeAdded(); MenuRegistration existingRegistration = treeMenuItemToRegistration.get(rootItem); if (null != existingRegistration) { return existingRegistration; } treeMenuData.addRootItems(rootItem); return registerTreeMenuItem(rootItem, clickHandler); } SideMenu(); MenuRegistration addMenuItem(String text, MenuClickHandler handler); MenuRegistration addMenuItem(String text, Resource icon, final MenuClickHandler handler); MenuRegistration addTreeItem(String rootItem, MenuClickHandler clickHandler); MenuRegistration addTreeItem(String parent, String item, MenuClickHandler clickHandler); MenuRegistration addUserMenuItem(String text, MenuClickHandler handler); MenuRegistration addUserMenuItem(String text, Resource icon, final MenuClickHandler handler); void setUserName(String userName); void setUserIcon(Resource icon); void setUserMenuVisible(boolean visible); boolean isUserMenuVisible(); void setMenuCaption(String caption); void setMenuCaption(String caption, Resource logo); void clearUserMenu(); void clearMenu(); MenuRegistration addNavigation(String text, String navigationState); MenuRegistration addNavigation(String text, Resource icon, final String navigationState); @Override void removeAllComponents(); @Override void addComponent(Component c); void setContent(Component content);  }
@Test public void addTreeItemRootNotUserOriginated() { SideMenu sideMenu = new SideMenu(); SideMenu.MenuRegistration item = sideMenu.addTreeItem("item", clickHandler); item.select(); verifyZeroInteractions(clickHandler); }
@Test public void addTreeItemSubNotUserOriginated() { SideMenu sideMenu = new SideMenu(); sideMenu.addTreeItem("parent", null); SideMenu.MenuRegistration item = sideMenu.addTreeItem("parent", "item", clickHandler); item.select(); verifyZeroInteractions(clickHandler); }
@Test public void addTreeItemRootRepeat() { SideMenu sideMenu = new SideMenu(); sideMenu.addTreeItem("item", clickHandler); sideMenu.addTreeItem("item", clickHandler); }
@Test public void addTreeItemSubRepeat() { SideMenu sideMenu = new SideMenu(); sideMenu.addTreeItem("parent1", clickHandler); sideMenu.addTreeItem("parent1", "item", clickHandler); sideMenu.addTreeItem("parent2", clickHandler); sideMenu.addTreeItem("parent2", "item", clickHandler); }