Package com.vaadin.browserless.internal
Class MenuItemNavigation
java.lang.Object
com.vaadin.browserless.internal.MenuItemNavigation
Menu item lookup shared by the menu testers.
A path addresses an item the way the browser shows it: by the text of each item in the hierarchy, or by the zero-based position of each item among the visible ones. The item at the end of the path must be enabled and visible, since a user cannot click anything else.
For internal use only.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends ContextMenuBase<C,I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>>
IfindByPath(List<I> rootItems, int topLevelPosition, int... nestedItemsPositions) Finds the menu item addressed by the given position path.static <C extends ContextMenuBase<C,I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>>
IfindByPath(List<I> rootItems, String topLevelText, String... nestedItemsText) Finds the menu item addressed by the given text path.static StringpathToString(int topLevelPosition, int... nestedItemsPositions) Renders a position path the way it is reported in error messages.static StringpathToString(String topLevelText, String... nestedItemsText) Renders a text path the way it is reported in error messages.static voidrequireCheckable(MenuItemBase<?, ?, ?> menuItem, String path) Ensures that the given menu item is checkable, as only a checkable item has a checked state to read.static <C extends ContextMenuBase<C,I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>>
List<String> visibleSubMenuTexts(List<I> rootItems, String topLevelText, String... nestedItemsText) Gets the texts of the visible items of the sub menu of the item addressed by the given text path.visibleTexts(List<? extends MenuItemBase<?, ?, ?>> items) Gets the texts of the given menu items as the browser shows them, i.e.
-
Method Details
-
findByPath
public static <C extends ContextMenuBase<C,I, I findByPathS>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> (List<I> rootItems, String topLevelText, String... nestedItemsText) Finds the menu item addressed by the given text path.- Type Parameters:
C- menu typeI- menu item typeS- sub menu type- Parameters:
rootItems- the items of the top level menutopLevelText- the text content of the top level menu item, not nullnestedItemsText- text content of the nested menu items- Returns:
- the menu item at the given path
- Throws:
IllegalArgumentException- if the provided text does not identify a menu itemIllegalStateException- if there are multiple visible matching items at any level, or if the item at the given path is disabled or not visible
-
findByPath
public static <C extends ContextMenuBase<C,I, I findByPathS>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> (List<I> rootItems, int topLevelPosition, int... nestedItemsPositions) Finds the menu item addressed by the given position path.- Type Parameters:
C- menu typeI- menu item typeS- sub menu type- Parameters:
rootItems- the items of the top level menutopLevelPosition- the zero-based position of the item in the menu, as it will be seen in the browsernestedItemsPositions- the zero-based position of the nested items, relative to the parent menu- Returns:
- the menu item at the given path
- Throws:
IllegalArgumentException- if the provided position does not identify a menu itemIllegalStateException- if the item at the given position is disabled or not visible
-
visibleTexts
Gets the texts of the given menu items as the browser shows them, i.e. only the visible ones, in their order.An item created from a component has no text of its own, so it is reported as an empty string.
- Parameters:
items- the items of a menu level- Returns:
- the texts of the visible items
-
visibleSubMenuTexts
public static <C extends ContextMenuBase<C,I, List<String> visibleSubMenuTextsS>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> (List<I> rootItems, String topLevelText, String... nestedItemsText) Gets the texts of the visible items of the sub menu of the item addressed by the given text path.- Type Parameters:
C- menu typeI- menu item typeS- sub menu type- Parameters:
rootItems- the items of the top level menutopLevelText- the text content of the top level menu item, not nullnestedItemsText- text content of the nested menu items- Returns:
- the texts of the visible items of the sub menu
- Throws:
IllegalArgumentException- if the provided text does not identify a menu item, or if the item at the given path has no sub menuIllegalStateException- if there are multiple matching items at any level, or if the item at the given path is disabled or not visible
-
pathToString
Renders a text path the way it is reported in error messages.- Parameters:
topLevelText- the text content of the top level menu itemnestedItemsText- text content of the nested menu items- Returns:
- the path as a string
-
pathToString
Renders a position path the way it is reported in error messages.- Parameters:
topLevelPosition- the position of the top level menu itemnestedItemsPositions- positions of the nested menu items- Returns:
- the path as a string
-