Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: FEST-Swing 1.2a3
-
Fix Version/s: FEST-Swing 1.2a4
-
Component/s: Swing
-
Labels:None
-
Number of attachments :
Description
Hi,
I have seen that even so FEST allows to select cells of a JTable, there is no way to simply select a row and verify that it is selected. (anyway I have not found)
I propose those modifications.
In JTableFixture :
public JTableFixture selectRow(int row) { driver.selectCell(target, TableCell.row(row).column(0)); return this; } public JTableFixture selectRows(int ... rows) { robot.pressKey(KeyEvent.VK_CONTROL); for(int row : rows) driver.selectCell(target, TableCell.row(row).column(0)); robot.releaseKey(KeyEvent.VK_CONTROL); return this; } public JTableFixture requireSelection(int row) { driver.requireSelection(target, row); return this; } public JTableFixture requireNotSelected(int row) { driver.requireNotSelected(target, row); return this; }
In JTableDriver :
public void requireSelection(JTable table, int index) { int selectedRow = this.selectedRow(table); assertThat(selectedRow).as(propertyName(table, "selectedRow")).isEqualTo(index); }
Thanks for your reading
Cheers
Florian
Thanks Florian for reporting this improvement. After careful thought, I decided not to implement the method requireNotSelected(int). I find the implementation a little too complicated for the potential benefit that this method might bring. For example, in your suggestion you use JTable#selectedRow which returns the index of the first selected row. If we use this method when a JTable has multiple selected rows, it will not be accurate: we won't know for sure if the given row was selected or not. To fix the implementation, we need to work with the whole set of selected rows, and deduce from there if the expected non-selected row is not in that set.
Other than that, I have implemented the rest of methods you suggested.
Many thanks,
-Alex