Class MenuBarTester
-
- All Implemented Interfaces:
public class MenuBarTester<T extends MenuBar> extends ComponentTester<T>
Tester for MenuBar components.
-
-
Constructor Summary
Constructors Constructor Description MenuBarTester(T component)Wrap given component for testing.
-
Method Summary
Modifier and Type Method Description voidclickItem(String topLevelText, Array<String> nestedItemsText)Simulates a click on the item that matches the given text. voidclickItem(int topLevelPosition, Array<int> nestedItemsPositions)Simulates a click on the item at the given position in the menu. booleanisItemChecked(String topLevelText, Array<String> nestedItemsText)Checks if the checkable menu item matching given text is checked. booleanisItemChecked(int topLevelPosition, Array<int> nestedItemsPositions)Checks if the checkable menu item at given position is checked. -
-
Constructor Detail
-
MenuBarTester
MenuBarTester(T component)
Wrap given component for testing.- Parameters:
component- target component
-
-
Method Detail
-
clickItem
void clickItem(String topLevelText, Array<String> nestedItemsText)
Simulates a click on the item that matches the given text. For nested menu item provide the text of each menu item in the hierarchy. The path to the menu item must reflect what is seen in the browser, meaning that hidden items are ignored.
menu.addItem("Preview", event -> {}); var subMenu = menu.addItem("Share").getSubMenu(); subMenu.addItem("Copy link", event -> {}); subMenu.addItem("Email", event -> {}); // clicks top level menu item with text Preview wrapper.clickItem("Preview"); // clicks nested menu item with text Email wrapper.clickItem("Share", "Email");- Parameters:
topLevelText- the text content of the top level menu item, not null.nestedItemsText- text content of the nested menu items
-
clickItem
void clickItem(int topLevelPosition, Array<int> nestedItemsPositions)
Simulates a click on the item at the given position in the menu. For nested menu item provide the position of each sub menu that should be navigated to reach the request item. The position reflects what is seen in the browser, so hidden items are ignored.
menu.addItem("Preview", event -> {}); var subMenu = menu.addItem("Share").getSubMenu(); subMenu.addItem("Copy link", event -> {}); subMenu.addItem("Email", event -> {}); // clicks top level "Preview" menu item at position 0 wrapper.clickItem(0); // clicks then nested menu item at position 1 "Email" through the // item "Share" at position 1 wrapper.clickItem(1, 1);- Parameters:
topLevelPosition- the zero-based position of the item in the menu, as it will be seen in the browser.nestedItemsPositions- the zero-based position of the nested items, relative to the parent menu
-
isItemChecked
boolean isItemChecked(String topLevelText, Array<String> nestedItemsText)
Checks if the checkable menu item matching given text is checked. For nested menu item provide the text of each menu item in the hierarchy. The path to the menu item must reflect what is seen in the browser, meaning that hidden items are ignored.
menu.addItem("Preview", event -> {}).setCheckable(true); var subMenu = menu.addItem("Share").getSubMenu(); subMenu.addItem("Copy link", event -> {}).setCheckable(true); subMenu.addItem("Email", event -> {}).setCheckable(true); wrapper.isItemChecked("Preview"); wrapper.isItemChecked("Share", "Email");- Parameters:
topLevelText- the text content of the top level menu item, not null.nestedItemsText- text content of the nested menu items- Returns:
true if the item at given path is checked, otherwise false.
-
isItemChecked
boolean isItemChecked(int topLevelPosition, Array<int> nestedItemsPositions)
Checks if the checkable menu item at given position is checked. For nested menu item provide the position of each sub menu that should be navigated to reach the requested item. The position reflects what is seen in the browser, so hidden items are ignored.
menu.addItem("Preview", event -> {}).setCheckable(true); var subMenu = menu.addItem("Share").getSubMenu(); subMenu.addItem("Copy link", event -> {}).setCheckable(true); subMenu.addItem("Email", event -> {}).setCheckable(true); // checks top level "Preview" menu item at position 0 wrapper.isItemChecked(0); // checks nested menu item at position 1 "Email" through the // item "Share" at position 1 wrapper.isItemChecked(1, 1);- Parameters:
topLevelPosition- the zero-based position of the item in the menu, as it will be seen in the browser.nestedItemsPositions- the zero-based position of the nested items, relative to the parent menu
-
-
-
-