* Test the {@link TableSelectionListener}.
*/
public void testListeners() {
// Initialize the grid
SelectionGrid testGrid = getSelectionGrid();
CellFormatter cellFormatter = testGrid.getCellFormatter();
// Create some listener
TestTableSelectionListener listener1 = new TestTableSelectionListener();
TestTableSelectionListener listener2 = new TestTableSelectionListener();
TestTableSelectionListener listener3 = new TestTableSelectionListener();
testGrid.addTableSelectionListener(listener1);
testGrid.addTableSelectionListener(listener2);
testGrid.addTableSelectionListener(listener3);
// Fire deselect rows
testGrid.deselectAllRows();
assertTrue(listener1.isAllRowsDeselectedCalled());
assertTrue(listener2.isAllRowsDeselectedCalled());
assertTrue(listener3.isAllRowsDeselectedCalled());
// Remove listener 2
testGrid.removeTableSelectionListener(listener2);
// Fire select row
testGrid.selectRow(4, true);
assertEquals(4, listener1.getSelectedRow());
assertEquals(1, listener1.getSelectedRowRange());
assertEquals(-1, listener2.getSelectedRow());
assertEquals(-1, listener2.getSelectedRowRange());
assertEquals(4, listener3.getSelectedRow());
assertEquals(1, listener3.getSelectedRowRange());
// Fire deselect row
testGrid.deselectRow(4);
assertEquals(4, listener1.getDeselectedRow());
assertEquals(4, listener3.getDeselectedRow());
// Fire hover row and cell
assertEquals(-1, listener1.getHoveringRow());
assertEquals(-1, listener1.getHoveringCell());
testGrid.hoverCell(cellFormatter.getElement(4, 2));
assertEquals(4, listener1.getHoveringRow());
assertEquals(2, listener1.getHoveringCell());
// Fire unhover row and cell
testGrid.hoverCell(null);