Class GridTester
-
- All Implemented Interfaces:
public class GridTester<T extends Grid<Y>, Y> extends ComponentTester<T>
Tester for Grid components.
-
-
Constructor Summary
Constructors Constructor Description GridTester(T component)Wrap grid for testing.
-
Method Summary
Modifier and Type Method Description intsize()Get the amount of items in the grid. YgetRow(int row)Get the item at the given row index. voidclickRow(int row)Click on grid row. voidclickRow(int row, MouseButton button)Click on grid row with given button. voidclickRow(int row, MetaKeys metaKeys)Click on grid row with given meta keys pressed. voidclickRow(int row, MouseButton button, MetaKeys metaKeys)Click on grid row with given button and meta keys pressed. voiddoubleClickRow(int row)Double-click on grid row. voiddoubleClickRow(int row, MouseButton button)Double-click on grid row with given button. voiddoubleClickRow(int row, MetaKeys metaKeys)Double-click on grid row with given meta keys pressed. voiddoubleClickRow(int row, MouseButton button, MetaKeys metaKeys)Double-click on grid row with given button and meta keys pressed. voidselect(int row)Select the item on given row. voidselectAll()Select all items in grid. StringgetCellText(int row, int column)Get the text that is shown on the client for the cell in the given position. ComponentgetCellComponent(int row, int column)Get component for item in cell. ComponentgetCellComponent(int row, String columnName)Get component for item in column. <V> VgetLitRendererPropertyValue(int row, String columnName, String propertyName, Class<V> propertyClass)Get property value for item's LitRenderer in column. <V> VgetLitRendererPropertyValue(int row, int column, String propertyName, Class<V> propertyClass)Get property value for item's LitRenderer in column. voidinvokeLitRendererFunction(int row, String columnName, String functionName, JsonArray jsonArray)Invoke named function for item's LitRenderer in column using the supplied JSON arguments. voidinvokeLitRendererFunction(int row, String columnName, String functionName)Invoke named function for item's LitRenderer in column. voidinvokeLitRendererFunction(int row, int column, String functionName, JsonArray jsonArray)Invoke named function for item's LitRenderer in column using the supplied JSON arguments. voidinvokeLitRendererFunction(int row, int column, String functionName)Invoke named function for item's LitRenderer in column. StringgetHeaderCell(int column)Get content in header for given column. intgetColumnPosition(String property)Get the column position by column property. Grid.Column<Y>getColumn(String property)Gets the grid column by column property. StringgetFooterCell(int column)Get content in footer for given column. Collection<Y>getSelected()Get selected items. booleanisColumnSortable(int column)Checks if the column at the given index is sortable. booleanisColumnSortable(String property)Checks if the column for the given property is sortable. SortDirectiongetSortDirection(int column)Gets the current sort direction for column at the given index. SortDirectiongetSortDirection(String property)Gets the current sort direction for column corresponding to the at the given property. voidsortByColumn(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. voidsortByColumn(int column)Sorts the grid according to the given column sort status, as if the column header is pressed in the browser. voidsortByColumn(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. voidsortByColumn(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. -
-
Constructor Detail
-
GridTester
GridTester(T component)
Wrap grid for testing.- Parameters:
component- target grid
-
-
Method Detail
-
size
int size()
Get the amount of items in the grid.
- Returns:
items in grid
-
getRow
Y getRow(int row)
Get the item at the given row index.
The index is 0 based.- Parameters:
row- row index of to get- Returns:
grid item on row
-
clickRow
void clickRow(int row)
Click on grid row.
The index is 0 based.- Parameters:
row- row to click
-
clickRow
void clickRow(int row, MouseButton button)
Click on grid row with given button.
The index is 0 based.- Parameters:
row- row to clickbutton- MouseButton that was clicked
-
clickRow
void clickRow(int row, MetaKeys metaKeys)
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
void clickRow(int row, MouseButton button, MetaKeys metaKeys)
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 click
-
doubleClickRow
void doubleClickRow(int row)
Double-click on grid row.
The index is 0 based.- Parameters:
row- row to click
-
doubleClickRow
void doubleClickRow(int row, MouseButton button)
Double-click on grid row with given button.
The index is 0 based.- Parameters:
row- row to clickbutton- MouseButton that was clicked
-
doubleClickRow
void doubleClickRow(int row, MetaKeys metaKeys)
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
void doubleClickRow(int row, MouseButton button, MetaKeys metaKeys)
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 click
-
select
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 select
-
selectAll
void selectAll()
Select all items in grid.
Only works for multi select.
-
getCellText
String getCellText(int row, int column)
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 cell- Returns:
cell content that is sent to the client
-
getCellComponent
Component getCellComponent(int row, int column)
Get component for item in cell.
- Parameters:
row- item rowcolumn- column to get- Returns:
initialized component for the targeted cell
-
getCellComponent
Component getCellComponent(int row, String columnName)
Get component for item in column.
- Parameters:
row- item rowcolumnName- key/property of column- Returns:
initialized component for the target cell
-
getLitRendererPropertyValue
<V> V getLitRendererPropertyValue(int row, String columnName, String propertyName, Class<V> propertyClass)
Get property value for item's LitRenderer in column.
- Parameters:
row- item rowcolumnName- key/property of columnpropertyName- the name of the LitRenderer propertypropertyClass- the class of the value of the LitRenderer property- Returns:
value of renderer's property for the target cell
-
getLitRendererPropertyValue
<V> V getLitRendererPropertyValue(int row, int column, String propertyName, Class<V> propertyClass)
Get property value for item's LitRenderer in column.
- Parameters:
row- item rowcolumn- column to getpropertyName- the name of the LitRenderer propertypropertyClass- the class of the value of the LitRenderer property- Returns:
value of renderer's property for the target cell
-
invokeLitRendererFunction
void invokeLitRendererFunction(int row, String columnName, String functionName, 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
void invokeLitRendererFunction(int row, String columnName, String functionName)
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
void invokeLitRendererFunction(int row, int column, String functionName, 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
void invokeLitRendererFunction(int row, int column, String functionName)
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() String getHeaderCell(int column)
Get content in header for given column.
- Parameters:
column- column to get header for- Returns:
header contents
-
getColumnPosition
int getColumnPosition(String property)
Get the column position by column property.
- Parameters:
property- the property name of the column, not null- Returns:
int position of column
-
getColumn
Grid.Column<Y> getColumn(String property)
Gets the grid column by column property.
- Parameters:
property- the property name of the column, not null- Returns:
Grid.Column for property
-
getFooterCell
@Deprecated(forRemoval = true) String getFooterCell(int column)
Get content in footer for given column.
- Parameters:
column- column to get footer for- Returns:
footer contents
-
getSelected
Collection<Y> getSelected()
Get selected items.
- Returns:
selected items
-
isColumnSortable
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 feature- Returns:
true if the column is sortable, otherwise false
-
isColumnSortable
boolean isColumnSortable(String property)
Checks if the column for the given property is sortable.
- Parameters:
property- the property name of the column, not null- Returns:
true if the column is sortable, otherwise false
-
getSortDirection
SortDirection getSortDirection(int column)
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 direction- Returns:
sort direction for the column, or null if grid is not sorted by given column
-
getSortDirection
SortDirection getSortDirection(String property)
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 null- Returns:
sort direction for the column, or null if grid is not sorted by given column
-
sortByColumn
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. Throws an exception if the column is not sortable or not visible.
- Parameters:
column- column indexdirection- sort direction
-
sortByColumn
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
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. Throws an exception if the column is not sortable or not visible.
- Parameters:
property- the property name of the column, not null
-
sortByColumn
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. Throws an exception if the column is not sortable or not visible.
- Parameters:
property- the property name of the column, not nulldirection- sort direction
-
-
-
-