Class TreeGridTester<T extends TreeGrid<Y>,Y>
java.lang.Object
com.vaadin.browserless.ComponentTester<T>
com.vaadin.flow.component.grid.GridTester<T,Y>
com.vaadin.flow.component.treegrid.TreeGridTester<T,Y>
- Type Parameters:
T- component typeY- item type
- All Implemented Interfaces:
Clickable<T>
Tester for TreeGrid components.
Adds the hierarchy interactions a user can perform on top of everything
GridTester offers. Row indexes address the rows the user actually
sees, so children of collapsed nodes are not counted.
The expand toggle lives in the hierarchy column, and a TreeGrid can
be configured with none, one, or several of them. expand(int) and
collapse(int) require at least one visible hierarchy column, since
without one the user has nothing to click. Several hierarchy columns render
several toggles for the same node, and clicking any of them has the same
effect, so they need no special handling here.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcollapse(int row) Collapses the node on the given row, as if the user clicked its collapse toggle in the browser.voidexpand(int row) Expands the node on the given row, as if the user clicked its expand toggle in the browser.getCellText(int row, int column) Get the text that is shown on the client for the cell in the given position.booleanhasChildren(int row) Checks whether the node on the given row has children, meaning the user is shown an expand toggle for it.booleanisExpanded(int row) Checks whether the node on the given row is expanded.Methods inherited from class com.vaadin.flow.component.grid.GridTester
clickRow, clickRow, clickRow, clickRow, contextMenu, deselect, deselectAll, doubleClickRow, doubleClickRow, doubleClickRow, doubleClickRow, getCellComponent, getCellComponent, getColumn, getColumnPosition, getColumns, getFooterCell, getHeaderCell, getLitRendererPropertyValue, getLitRendererPropertyValue, getRow, getSelected, getSortDirection, getSortDirection, invokeLitRendererFunction, invokeLitRendererFunction, invokeLitRendererFunction, invokeLitRendererFunction, isColumnSortable, isColumnSortable, renderCellComponent, renderCellComponent, select, selectAll, size, sortByColumn, sortByColumn, sortByColumn, sortByColumnMethods inherited from class com.vaadin.browserless.ComponentTester
canSetValueAsUser, clearAsUser, clickClearButtonAsUser, ensureComponentIsUsable, ensureComponentIsUsable, ensureComponentIsUsableOrDetach, ensureVisible, ensureVisible, find, findAllByQuery, findByQuery, fireDomEvent, fireDomEvent, fireDomEvent, getComponent, getField, getField, getMethod, getMethod, isComponentReadOnly, isUsable, isUsable, notUsableReasons, notUsableReasons, roundTrip, setModal, setPropertyAsUser, setValueAsUser, setValueAsUserMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.browserless.Clickable
click, click, click, middleClick, middleClick, rightClick, rightClick
-
Constructor Details
-
TreeGridTester
Wrap tree grid for testing.- Parameters:
component- target tree grid
-
-
Method Details
-
expand
public void expand(int row) Expands the node on the given row, as if the user clicked its expand toggle in the browser. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped. The resultingExpandEventreportsComponentEvent.isFromClient()as true.- Parameters:
row- row of the node to expand- Throws:
IllegalStateException- if the component is not usable, if the tree grid has no visible hierarchy column, if the row has no children and thus no expand toggle, or if the node is already expanded
-
collapse
public void collapse(int row) Collapses the node on the given row, as if the user clicked its collapse toggle in the browser. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped. The resultingCollapseEventreportsComponentEvent.isFromClient()as true.- Parameters:
row- row of the node to collapse- Throws:
IllegalStateException- if the component is not usable, if the tree grid has no visible hierarchy column, if the row has no children and thus no collapse toggle, or if the node is not expanded
-
isExpanded
public boolean isExpanded(int row) Checks whether the node on the given row is expanded. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped.- Parameters:
row- row to check- Returns:
- true if the node on the row is expanded, otherwise false
- Throws:
IllegalStateException- if the component is not visible
-
hasChildren
public boolean hasChildren(int row) Checks whether the node on the given row has children, meaning the user is shown an expand toggle for it. The index is 0 based and counts only rows that are currently displayed, so children of collapsed nodes are skipped.- Parameters:
row- row to check- Returns:
- true if the node on the row has children, otherwise false
- Throws:
IllegalStateException- if the component is not visible
-
getCellText
Get the text that is shown on the client for the cell in the given position. A hierarchy column added withTreeGrid.addHierarchyColumn(com.vaadin.flow.function.ValueProvider)renders the item through avaadin-grid-tree-toggle, so its text is read from the toggle's own value provider rather than from a column path. Every other column is read exactly asGridTesterdoes.- Overrides:
getCellTextin classGridTester<T extends TreeGrid<Y>,Y> - Parameters:
row- row of cellcolumn- column of cell- Returns:
- cell content that is sent to the client
- Throws:
IllegalStateException- if component is not visible
-