com.vaadin.flow.component.grid.
Class GridTester<T extends Grid<Y>,Y>
Type Parameters:
T
- component type
Y
- item type
Tester for Grid components.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clickRow
(int row) Click on grid row.
void
Click on grid row with given meta keys pressed.
void
clickRow
(int row, MouseButton button) Click on grid row with given button.
void
clickRow
(int row, MouseButton button, MetaKeys metaKeys) Click on grid row with given button and meta keys pressed.
void
doubleClickRow
(int row) Double-click on grid row.
void
doubleClickRow
(int row, MetaKeys metaKeys) Double-click on grid row with given meta keys pressed.
void
doubleClickRow
(int row, MouseButton button) Double-click on grid row with given button.
void
doubleClickRow
(int row, MouseButton button, MetaKeys metaKeys) Double-click on grid row with given button and meta keys pressed.
getCellComponent
(int row, int column) Get component for item in cell.
getCellComponent
(int row, String columnName) Get component for item in column.
getCellText
(int row, int column) Get the text that is shown on the client for the cell in the given position.
Gets the grid column by column property.
int
getColumnPosition
(String property) Get the column position by column property.
getFooterCell
(int column) Deprecated, for removal: This API element is subject to removal in a future version.
getHeaderCell
(int column) Deprecated.
UseAbstractColumn.getHeaderText()
orAbstractColumn.getHeaderComponent()
<V> V
getLitRendererPropertyValue
(int row, int column, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column.
<V> V
getLitRendererPropertyValue
(int row, String columnName, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column.
getRow
(int row) Get the item at the given row index.
Get selected items.
getSortDirection
(int column) Gets the current sort direction for column at the given index.
getSortDirection
(String property) Gets the current sort direction for column corresponding to the at the given property.
void
invokeLitRendererFunction
(int row, int column, String functionName) Invoke named function for item's LitRenderer in column.
void
invokeLitRendererFunction
(int row, int column, String functionName, elemental.json.JsonArray jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments.
void
invokeLitRendererFunction
(int row, String columnName, String functionName) Invoke named function for item's LitRenderer in column.
void
invokeLitRendererFunction
(int row, String columnName, String functionName, elemental.json.JsonArray jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments.
boolean
isColumnSortable
(int column) Checks if the column at the given index is sortable.
boolean
isColumnSortable
(String property) Checks if the column for the given property is sortable.
void
select
(int row) Select the item on given row.
void
Select all items in grid.
int
size()
Get the amount of items in the grid.
void
sortByColumn
(int column) Sorts the grid according to the given column sort status, as if the column header is pressed in the browser.
void
sortByColumn
(int column, SortDirection direction) Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached.
void
sortByColumn
(String property) Sorts the grid according to sort status ot the column identified by the given property, as if the column header is pressed in the browser.
void
sortByColumn
(String property, SortDirection direction) Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached.
Methods inherited from class com.vaadin.testbench.unit.ComponentTester
ensureComponentIsUsable, ensureComponentIsUsable, ensureVisible, ensureVisible, find, findAllByQuery, findByQuery, fireDomEvent, fireDomEvent, fireDomEvent, getComponent, getField, getField, getMethod, getMethod, isUsable, isUsable, notUsableReasons, notUsableReasons, roundTrip, setModal
-
Constructor Details
-
GridTester
Wrap grid for testing.
Parameters:
component
- target grid
-
-
Method Details
-
size
public int size()Get the amount of items in the grid.
Returns:
items in grid
-
getRow
Get the item at the given row index.
The index is 0 based.
Parameters:
row
- row index of to getReturns:
grid item on row
-
clickRow
public void clickRow(int row) Click on grid row.
The index is 0 based.
Parameters:
row
- row to click -
clickRow
Click on grid row with given button.
The index is 0 based.
Parameters:
row
- row to clickbutton
- MouseButton that was clickedSee Also:
-
clickRow
Click on grid row with given meta keys pressed.
The index is 0 based.
Parameters:
row
- row to clickmetaKeys
- meta key statuses for click -
clickRow
Click on grid row with given button and meta keys pressed.
The index is 0 based.
Parameters:
row
- row to clickbutton
- MouseButton that was clickedmetaKeys
- meta key statuses for clickSee Also:
-
doubleClickRow
public void doubleClickRow(int row) Double-click on grid row.
The index is 0 based.
Parameters:
row
- row to click -
doubleClickRow
Double-click on grid row with given button.
The index is 0 based.
Parameters:
row
- row to clickbutton
- MouseButton that was clickedSee Also:
-
doubleClickRow
Double-click on grid row with given meta keys pressed.
The index is 0 based.
Parameters:
row
- row to clickmetaKeys
- meta key statuses for click -
doubleClickRow
Double-click on grid row with given button and meta keys pressed.
The index is 0 based.
Parameters:
row
- row to clickbutton
- MouseButton that was clickedmetaKeys
- meta key statuses for clickSee Also:
-
select
public void select(int row) Select the item on given row.
The index is 0 based.
Single select will clear any old selections. Multi select will add to selection.
Parameters:
row
- row to selectThrows:
IllegalStateException
- if not usable -
selectAll
public void selectAll()Select all items in grid.
Only works for multi select.
Throws:
IllegalStateException
- if not usable or not multi select -
getCellText
Get the text that is shown on the client for the cell in the given position.
The indexes for row and column are 0 based.
For the default renderer ColumnPathRenderer the result is the sent text for defined object path.
For a ComponentRenderer the result is the rendered component as prettyString.
More to be added as we find other renderers that need handling.
Parameters:
row
- row of cellcolumn
- column of cellReturns:
cell content that is sent to the client
Throws:
IllegalStateException
- if component is not visible -
getCellComponent
Get component for item in cell.
Parameters:
row
- item rowcolumn
- column to getReturns:
initialized component for the targeted cell
Throws:
IllegalArgumentException
- when the target column of the cell is not a component renderer -
getCellComponent
Get component for item in column.
Parameters:
row
- item rowcolumnName
- key/property of columnReturns:
initialized component for the target cell
Throws:
IllegalArgumentException
- when column for property doesn't exist or the target column of the cell is not a component renderer -
getLitRendererPropertyValue
public <V> V getLitRendererPropertyValue(int row, String columnName, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column.
Type Parameters:
V
- the type of the LitRenderer propertyParameters:
row
- item rowcolumnName
- key/property of columnpropertyName
- the name of the LitRenderer propertypropertyClass
- the class of the value of the LitRenderer propertyReturns:
value of renderer's property for the target cell
Throws:
IllegalArgumentException
- when column for property doesn't exist or the target column of the cell is not a LitRenderer or when the given type of the property does not match the actual property type -
getLitRendererPropertyValue
public <V> V getLitRendererPropertyValue(int row, int column, String propertyName, Class<V> propertyClass) Get property value for item's LitRenderer in column.
Type Parameters:
V
- the type of the LitRenderer propertyParameters:
row
- item rowcolumn
- column to getpropertyName
- the name of the LitRenderer propertypropertyClass
- the class of the value of the LitRenderer propertyReturns:
value of renderer's property for the target cell
Throws:
IllegalArgumentException
- when column for property doesn't exist or the target column of the cell is not a LitRenderer or when the given type of the property does not match the actual property type -
invokeLitRendererFunction
public void invokeLitRendererFunction(int row, String columnName, String functionName, elemental.json.JsonArray jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments.
Parameters:
row
- item rowcolumnName
- key/property of columnfunctionName
- the name of the LitRenderer function to invokejsonArray
- the arguments to pass to the function -
invokeLitRendererFunction
Invoke named function for item's LitRenderer in column.
Parameters:
row
- item rowcolumnName
- key/property of columnfunctionName
- the name of the LitRenderer function to invoke -
invokeLitRendererFunction
public void invokeLitRendererFunction(int row, int column, String functionName, elemental.json.JsonArray jsonArray) Invoke named function for item's LitRenderer in column using the supplied JSON arguments.
Parameters:
row
- item rowcolumn
- column to getfunctionName
- the name of the LitRenderer function to invokejsonArray
- the arguments to pass to the function -
invokeLitRendererFunction
Invoke named function for item's LitRenderer in column.
Parameters:
row
- item rowcolumn
- column to getfunctionName
- the name of the LitRenderer function to invoke -
getHeaderCell
Deprecated.UseAbstractColumn.getHeaderText()
orAbstractColumn.getHeaderComponent()
Get content in header for given column.
Parameters:
column
- column to get header forReturns:
header contents
Throws:
IllegalStateException
- if component is not visible -
getColumnPosition
Get the column position by column property.
Parameters:
property
- the property name of the column, not nullReturns:
int position of column
-
getColumn
Gets the grid column by column property.
Parameters:
property
- the property name of the column, not nullReturns:
Grid.Column for property
-
getSelected
Get selected items.
Returns:
selected items
-
isColumnSortable
public boolean isColumnSortable(int column) Checks if the column at the given index is sortable.
The index is 0 based.
Parameters:
column
- column index to check for sort featureReturns:
true if the column is sortable, otherwise false
Throws:
IndexOutOfBoundsException
- if column index is invalid -
isColumnSortable
Checks if the column for the given property is sortable.
Parameters:
property
- the property name of the column, not nullReturns:
true if the column is sortable, otherwise false
Throws:
IllegalArgumentException
- if property name does not identify a column -
getSortDirection
Gets the current sort direction for column at the given index. Throws an exception if the column does not exist or is not sortable.
Parameters:
column
- column index to get sort directionReturns:
sort direction for the column, or null if grid is not sorted by given column
Throws:
IllegalArgumentException
- if the column at given index is not sortableIndexOutOfBoundsException
- if column index is invalid -
getSortDirection
Gets the current sort direction for column corresponding to the at the given property. Throws an exception if the column does not exist or is not sortable.
Parameters:
property
- the property name of the column, not nullReturns:
sort direction for the column, or null if grid is not sorted by given column
Throws:
IllegalArgumentException
- if property name does not identify a column or if the column is not sortable -
sortByColumn
Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached. Throws an exception if the column is not sortable or not visible.
Parameters:
column
- column indexdirection
- sort direction -
sortByColumn
public void sortByColumn(int column) Sorts the grid according to the given column sort status, as if the column header is pressed in the browser. Throws an exception if the column is not sortable or not visible.
Parameters:
column
- column index -
sortByColumn
Sorts the grid according to sort status ot the column identified by the given property, as if the column header is pressed in the browser. Throws an exception if the column is not sortable or not visible.
Parameters:
property
- the property name of the column, not null -
sortByColumn
Sorts the grid by the given column and sort direction, as if the column header is pressed in the browser until the requested direction is reached. Throws an exception if the column is not sortable or not visible.
Parameters:
property
- the property name of the column, not nulldirection
- sort direction
-
AbstractColumn.getFooterText()
orAbstractColumn.getFooterComponent()
directly