|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fest.swing.driver.ComponentDriver
org.fest.swing.driver.ContainerDriver
org.fest.swing.driver.JComponentDriver
org.fest.swing.driver.JTableDriver
public class JTableDriver
Understands functional testing of
s:
JTable
org.fest.swing.fixture
in your tests.
Field Summary |
---|
Fields inherited from class org.fest.swing.driver.ComponentDriver |
---|
robot |
Constructor Summary | |
---|---|
JTableDriver(Robot robot)
Creates a new JTableDriver . |
Method Summary | |
---|---|
Color |
background(JTable table,
TableCell cell)
Returns the background color of the given table cell. |
void |
cancelCellEditing(JTable table,
TableCell cell)
Cancels editing the given cell of the , using this driver's
. |
TableCell |
cell(JTable table,
Pattern pattern)
Returns a cell from the given whose value matches the given regular expression pattern. |
TableCell |
cell(JTable table,
String value)
Returns a cell from the given whose value matches the given one. |
TableCell |
cell(JTable table,
TableCellFinder cellFinder)
Returns a cell from the given using the given cell finder. |
Component |
cellEditor(JTable table,
TableCell cell)
Returns the editor in the given cell of the , using this driver's
. |
void |
cellReader(JTableCellReader newCellReader)
Updates the implementation of to use when comparing internal values of a
and the values expected in a test. |
void |
cellWriter(JTableCellWriter newCellWriter)
Updates the implementation of to use to edit cell values in a
. |
void |
click(JTable table,
TableCell cell,
MouseButton mouseButton,
int times)
Clicks the given cell, using the specified mouse button, the given number of times. |
int |
columnIndex(JTable table,
Object columnId)
Returns the index of the column in the given whose id matches the given one. |
String[][] |
contents(JTable table)
Returns the String representation of the cells in the , using this
driver's . |
void |
drag(JTable table,
TableCell cell)
Starts a drag operation at the location of the given table cell. |
void |
drop(JTable table,
TableCell cell)
Starts a drop operation at the location of the given table cell. |
void |
enterValueInCell(JTable table,
TableCell cell,
String value)
Enters the given value in the given cell of the , using this driver's
. |
Font |
font(JTable table,
TableCell cell)
Returns the font of the given table cell. |
Color |
foreground(JTable table,
TableCell cell)
Returns the foreground color of the given table cell. |
Point |
pointAt(JTable table,
TableCell cell)
Converts the given table cell into a coordinate pair. |
void |
requireCellValue(JTable table,
TableCell cell,
Pattern pattern)
Asserts that the value of the given cell matches the given regular expression pattern. |
void |
requireCellValue(JTable table,
TableCell cell,
String value)
Asserts that the value of the given cell matches the given value. |
void |
requireColumnCount(JTable table,
int columnCount)
Asserts that the given has the given number of columns. |
void |
requireContents(JTable table,
String[][] contents)
Asserts that the String representation of the cell values in the is
equal to the given String array. |
void |
requireEditable(JTable table,
TableCell cell)
Asserts that the given table cell is editable. |
void |
requireNoSelection(JTable table)
Verifies that the does not have any selection. |
void |
requireNotEditable(JTable table,
TableCell cell)
Asserts that the given table cell is not editable. |
void |
requireRowCount(JTable table,
int rowCount)
Asserts that the given has the given number of rows. |
void |
requireSelectedRows(JTable table,
int... rows)
Asserts that the set of selected rows in the given contains to the given row indices. |
int |
rowCountOf(JTable table)
Returns the number of rows that can be shown in the given , given unlimited space. |
void |
selectCell(JTable table,
TableCell cell)
Selects the given cell, if it is not selected already. |
void |
selectCells(JTable table,
TableCell[] cells)
Selects the given cells of the . |
String |
selectionValue(JTable table)
Returns the String representation of the value of the selected cell, using this driver's
. |
void |
selectRows(JTable table,
int... rows)
Simulates a user selecting the given rows in the given . |
JPopupMenu |
showPopupMenuAt(JTable table,
TableCell cell)
Shows a pop-up menu at the given table cell. |
void |
startCellEditing(JTable table,
TableCell cell)
Starts editing the given cell of the , using this driver's
. |
void |
stopCellEditing(JTable table,
TableCell cell)
Stops editing the given cell of the , using this driver's
. |
JTableHeader |
tableHeaderOf(JTable table)
Returns the of the given . |
void |
validate(JTable table,
TableCell cell)
Validates that the given table cell is non null and its indices are not out of bounds. |
String |
value(JTable table,
int row,
int column)
Returns the String representation of the value at the given row and column, using this driver's
. |
String |
value(JTable table,
TableCell cell)
Returns the String representation of the value at the given cell, using this driver's
. |
Methods inherited from class org.fest.swing.driver.JComponentDriver |
---|
clientProperty, invokeAction, isVisible, isVisible, requireToolTip, requireToolTip, scrollToVisible |
Methods inherited from class org.fest.swing.driver.ContainerDriver |
---|
move, resize, resizeHeight, resizeWidth |
Methods inherited from class org.fest.swing.driver.ComponentDriver |
---|
assertIsEnabledAndShowing, click, click, click, click, click, doubleClick, drag, dragOver, drop, focus, focusAndWaitForFocusGain, invokePopupMenu, invokePopupMenu, moveMouseIgnoringAnyError, moveMouseIgnoringAnyError, performAccessibleActionOf, pressAndReleaseKey, pressAndReleaseKey, pressAndReleaseKeys, pressKey, propertyName, releaseKey, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireSize, requireVisible, rightClick, settings, waitForShowing |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JTableDriver(Robot robot)
JTableDriver
.
robot
- the robot to use to simulate user events.Method Detail |
---|
@RunsInEDT public JTableHeader tableHeaderOf(JTable table)
JTableHeader
of the given JTable
.
table
- the given JTable
.
JTableHeader
of the given JTable
.@RunsInEDT public String selectionValue(JTable table)
String
representation of the value of the selected cell, using this driver's
JTableCellReader
.
table
- the target JTable
.
String
representation of the value of the selected cell.cellReader(JTableCellReader)
@RunsInEDT public TableCell cell(JTable table, TableCellFinder cellFinder)
JTable
using the given cell finder.
table
- the target JTable
.cellFinder
- knows how to find a cell.
NullPointerException
- if cellFinder
is null
.
IndexOutOfBoundsException
- if the row or column indices in the found cell are out of bounds.
ActionFailedException
- if a matching cell could not be found.@RunsInEDT public TableCell cell(JTable table, String value)
JTable
whose value matches the given one.
table
- the target JTable
.value
- the value of the cell to look for. It can be a regular expression.
JTable
whose value matches the given one.
ActionFailedException
- if a cell with a matching value cannot be found.@RunsInEDT public TableCell cell(JTable table, Pattern pattern)
JTable
whose value matches the given regular expression pattern.
table
- the target JTable
.pattern
- the regular expression pattern to match
JTable
whose value matches the given one.
NullPointerException
- if the given regular expression is null
.
ActionFailedException
- if a cell with a matching value cannot be found.@RunsInEDT public String value(JTable table, TableCell cell)
String
representation of the value at the given cell, using this driver's
JTableCellReader
.
table
- the target JTable
.cell
- the table cell.
String
representation of the value at the given cell.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.cellReader(JTableCellReader)
@RunsInEDT public String value(JTable table, int row, int column)
String
representation of the value at the given row and column, using this driver's
JTableCellReader
.
table
- the target JTable
.row
- the given row.column
- the given column.
String
representation of the value at the given row and column.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.cellReader(JTableCellReader)
@RunsInEDT public Font font(JTable table, TableCell cell)
table
- the target JTable
.cell
- the table cell.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@RunsInEDT public Color background(JTable table, TableCell cell)
table
- the target JTable
.cell
- the table cell.
ActionFailedException
- if the cell is null
.
ActionFailedException
- if any of the indices (row and column) is out of bounds.@RunsInEDT public Color foreground(JTable table, TableCell cell)
table
- the target JTable
.cell
- the table cell.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.public void selectCells(JTable table, TableCell[] cells)
JTable
.
table
- the target JTable
.cells
- the cells to select.
NullPointerException
- if cells
is null
or empty.
IllegalArgumentException
- if cells
is null
or empty.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
NullPointerException
- if any element in cells
is null
.
IndexOutOfBoundsException
- if any of the indices of any of the cells
are out of bounds.@RunsInEDT public void requireNoSelection(JTable table)
JTable
does not have any selection.
table
- the target JTable
.
AssertionError
- is the JTable
has a selection.@RunsInEDT public void selectCell(JTable table, TableCell cell)
table
- the target JTable
.cell
- the cell to select.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@RunsInEDT public void click(JTable table, TableCell cell, MouseButton mouseButton, int times)
table
- the target JTable
.cell
- the table cell.mouseButton
- the mouse button to use.times
- the number of times to click the cell.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@RunsInEDT public void drag(JTable table, TableCell cell)
table
- the target JTable
.cell
- the table cell.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@RunsInEDT public void drop(JTable table, TableCell cell)
table
- the target JTable
.cell
- the table cell.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@RunsInEDT public JPopupMenu showPopupMenuAt(JTable table, TableCell cell)
table
- the target JTable
.cell
- the table cell.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
ComponentLookupException
- if a pop-up menu cannot be found.@RunsInEDT public Point pointAt(JTable table, TableCell cell)
table
- the target JTable
.cell
- the table cell.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.@RunsInEDT public void requireContents(JTable table, String[][] contents)
String
representation of the cell values in the JTable
is
equal to the given String
array. This method uses this driver's
JTableCellReader
to read the values of the table cells as String
s.
table
- the target JTable
.contents
- the expected String
representation of the cell values in the JTable
.cellReader(JTableCellReader)
@RunsInEDT public String[][] contents(JTable table)
String
representation of the cells in the JTable
, using this
driver's JTableCellReader
.
table
- the target JTable
.
String
representation of the cells in the JTable
.cellReader(JTableCellReader)
@RunsInEDT public void requireCellValue(JTable table, TableCell cell, String value)
table
- the target JTable
.cell
- the given table cell.value
- the expected value. It can be a regular expression.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
AssertionError
- if the value of the given cell does not match the given value.@RunsInEDT public void requireCellValue(JTable table, TableCell cell, Pattern pattern)
table
- the target JTable
.cell
- the given table cell.pattern
- the regular expression pattern to match.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
NullPointerException
- if the given regular expression pattern is null
.
AssertionError
- if the value of the given cell does not match the given regular expression pattern.@RunsInEDT public void enterValueInCell(JTable table, TableCell cell, String value)
JTable
, using this driver's
JTableCellWriter
.
table
- the target JTable
.cell
- the given cell.value
- the given value.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IllegalStateException
- if the JTable
cell is not editable.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
ActionFailedException
- if this driver's JTableCellValueReader
is unable to enter the given
value.cellWriter(JTableCellWriter)
@RunsInEDT public void requireEditable(JTable table, TableCell cell)
table
- the target JTable
.cell
- the given table cell.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
AssertionError
- if the given table cell is not editable.@RunsInEDT public void requireNotEditable(JTable table, TableCell cell)
table
- the target JTable
.cell
- the given table cell.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
AssertionError
- if the given table cell is editable.@RunsInEDT public Component cellEditor(JTable table, TableCell cell)
JTable
, using this driver's
JTableCellWriter
.
table
- the target JTable
.cell
- the given cell.
JTable
.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
cell is not editable.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.cellWriter(JTableCellWriter)
@RunsInEDT public void startCellEditing(JTable table, TableCell cell)
JTable
, using this driver's
JTableCellWriter
. This method should be called before manipulating the
Component
returned by cellEditor(JTable, TableCell)
.
table
- the target JTable
.cell
- the given cell.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IllegalStateException
- if the JTable
cell is not editable.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
ActionFailedException
- if this writer is unable to handle the underlying cell editor.cellWriter(JTableCellWriter)
@RunsInEDT public void stopCellEditing(JTable table, TableCell cell)
JTable
, using this driver's
JTableCellWriter
. This method should be called after manipulating the
Component
returned by cellEditor(JTable, TableCell)
.
table
- the target JTable
.cell
- the given cell.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IllegalStateException
- if the JTable
cell is not editable.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
ActionFailedException
- if this writer is unable to handle the underlying cell editor.cellWriter(JTableCellWriter)
@RunsInEDT public void cancelCellEditing(JTable table, TableCell cell)
JTable
, using this driver's
JTableCellWriter
. This method should be called after manipulating the
Component
returned by cellEditor(JTable, TableCell)
.
table
- the target JTable
.cell
- the given cell.
NullPointerException
- if the cell is null
.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IllegalStateException
- if the JTable
cell is not editable.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.
ActionFailedException
- if this writer is unable to handle the underlying cell editor.cellWriter(JTableCellWriter)
@RunsInEDT public void validate(JTable table, TableCell cell)
null
and its indices are not out of bounds.
table
- the target JTable
.cell
- to validate.
NullPointerException
- if the cell is null
.
IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.public void cellReader(JTableCellReader newCellReader)
JTableCellReader
to use when comparing internal values of a
JTable
and the values expected in a test.
newCellReader
- the new JTableCellValueReader
to use.
NullPointerException
- if newCellReader
is null
.public void cellWriter(JTableCellWriter newCellWriter)
JTableCellWriter
to use to edit cell values in a
JTable
.
newCellWriter
- the new JTableCellWriter
to use.
NullPointerException
- if newCellWriter
is null
.@RunsInEDT public int rowCountOf(JTable table)
JTable
, given unlimited space.
table
- the target JTable
.
JTable
.JTable.getRowCount()
@RunsInEDT public int columnIndex(JTable table, Object columnId)
JTable
whose id matches the given one.
table
- the target JTable
.columnId
- the id of the column to look for.
ActionFailedException
- if a column with a matching id could not be found.@RunsInEDT public void requireRowCount(JTable table, int rowCount)
JTable
has the given number of rows.
table
- the target JTable
.rowCount
- the expected number of rows.
AssertionError
- if the given JTable
does not have the given number of rows.@RunsInEDT public void requireColumnCount(JTable table, int columnCount)
JTable
has the given number of columns.
table
- the target JTable
.columnCount
- the expected number of columns.
AssertionError
- if the given JTable
does not have the given number of columns.@RunsInEDT public void selectRows(JTable table, int... rows)
JTable
.
table
- the target JTable
.rows
- the indices of the row to select.
NullPointerException
- if the given array of indices is null
.
IllegalArgumentException
- if the given array of indices is empty.
IllegalStateException
- if the JTable
is disabled.
IllegalStateException
- if the JTable
is not showing on the screen.
IndexOutOfBoundsException
- if any of the given indices is negative, or equal to or greater than the number
of rows in the JTable
.@RunsInEDT public void requireSelectedRows(JTable table, int... rows)
JTable
contains to the given row indices.
table
- the target JTable
.rows
- the indices of the rows expected to be selected.
AssertionError
- if the sets of selected rows in the given JTable
(if any) do not contain the
given row indices.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |