public void testCheckboxSelection() {
// Initialize the grid
SelectionGrid testGrid = getSelectionGrid();
testGrid.resize(3, 4);
RowFormatter rowFormatter = testGrid.getRowFormatter();
CellFormatter cellFormatter = testGrid.getCellFormatter();
// Verify the column count before setting the checkbox policy
assertEquals(4, testGrid.getColumnCount());
for (int i = 0; i < 3; i++) {
Element tr = rowFormatter.getElement(i);
assertEquals(4, tr.getChildNodes().getLength());
}
// Verify the column count after setting the checkbox policy
testGrid.setSelectionPolicy(SelectionPolicy.CHECKBOX);
assertEquals(4, testGrid.getColumnCount());
for (int i = 0; i < 3; i++) {
Element tr = rowFormatter.getElement(i);
assertEquals(5, tr.getChildNodes().getLength());
}
// Set html and verify
testGrid.setText(0, 0, "test");
assertEquals("test", testGrid.getText(0, 0));
assertEquals("test", cellFormatter.getElement(0, 0).getInnerText());
assertEquals("test",
DOM.getChild(rowFormatter.getElement(0), 1).getInnerText());
}