Class GridTester<T>

java.lang.Object
com.vaadin.testbench.uiunittest.testers.Tester<com.vaadin.ui.Grid<T>>
com.vaadin.testbench.uiunittest.testers.GridTester<T>
Direct Known Subclasses:
TreeGridTester

public class GridTester<T> extends Tester<com.vaadin.ui.Grid<T>>
  • Constructor Details

    • GridTester

      public GridTester(com.vaadin.ui.Grid<T> grid)
  • Method Details

    • cell

      public Object cell(int column, int row)
      Return the content of the cell. If ComponentRenderer was used it is the Component produced by the renderer otherwise it is the value. Asserts that column is visible.
      Parameters:
      column - Column index including hidden columns
      row - The row index
      Returns:
      Cell content
    • description

      public String description(int row)
      Return the description (aka tooltip) for the row.
      Parameters:
      row - The row index, base 0
      Returns:
      Description String
    • description

      public String description(int column, int row)
      Return the description (aka tooltip) for the cell.
      Parameters:
      column - Column index including hidden columns
      row - The row index, base 0
      Returns:
      Description String
    • styleName

      public String styleName(int row)
      Return the style name (aka CSS class name) for the row.
      Parameters:
      row - The row index, base 0
      Returns:
      Style name String
    • item

      public T item(int row)
      Return data item of the row.
      Parameters:
      row - Row index
      Returns:
      The item
    • size

      public int size()
      Return the total amount of rows as reported by DataProvider.
      Returns:
      int value
    • click

      public void click(int column, int row)
      Simulate click in given cell. Will trigger ItemClick event as a user. If selection mode is Single, selection is updated accordingly. Asserts that column is visible.
      Parameters:
      column - Column index including hidden columns
      row - Row index
    • clickToSelect

      public void clickToSelect(int row)
      Simulate clicking of the multiselect checkbox column of the Grid as a user on a given item.
      Parameters:
      row - The row index
    • clickToSelect

      public void clickToSelect(T item)
      Simulate clicking of the multiselect checkbox column of the Grid as a user on a given item.
      Parameters:
      item - Item
    • edit

      public void edit(int row)
      Simulate user opening the editor if Grid and Editor are interactable. This will fire EditorOpenEvent and populate the editor with the item.

      Note: There is a limitation. Programmatic opening of the editor from application logic will require client round trip, which is not possible in Unit testing. E.g. if you have ItemClickListener that opens the editor, clicking the item will do nothing.

      Parameters:
      row - Row index to start the editor
      See Also:
    • editorOpen

      public boolean editorOpen()
      Returns the open state of the Editor.
      Returns:
      boolean value
      See Also:
    • save

      public void save()
      Simulates clicking save button of the editor. If Editor is in buffered mode, bean is written if is valid. Validation errors will prevent editor saving and closing. If save is success, Editor is closed and EditorSaveEvent will be fired.

      Note: There is a limitation. Programmatic saving of the editor from application logic will require client round trip, which is not possible in Unit testing. E.g. if you have logic that force saves the editor, it will do nothing.

      See Also:
    • cancel

      public void cancel()
      Simulates clicking cancel button of the editor. If Editor is in buffered mode, bean is not written and Grid is not updated. Editor is closed.
      See Also:
    • toggleColumnVisibility

      public void toggleColumnVisibility(int columnIndex)
      Toggles the visibility of the given column by index. The ColumnVisibilityChangeEvent fired will have userOriginated = true.
      Parameters:
      columnIndex - int
    • toggleColumnVisibility

      public void toggleColumnVisibility(String caption)
      Toggles the visibility of the given column by caption value. The ColumnVisibilityChangeEvent fired will have userOriginated = true.
      Parameters:
      caption - The caption as string
    • toggleColumnSorting

      public void toggleColumnSorting(int columnIndex)
      Simulate toggling of the sorting direction of the column. Asserts that column is visible. SortEvent fired will have userOriginated = true.
      Parameters:
      columnIndex - Index of the column including hidden columns.
    • select

      protected void select(Set<T> items)
    • deselect

      protected void deselect(Set<T> items)
    • select

      protected void select(T item)
    • deselect

      protected void deselect(T item)
    • getComponent

      protected com.vaadin.ui.Grid<T> getComponent()
      Overrides:
      getComponent in class Tester<com.vaadin.ui.Grid<T>>