Package org.fest.swing.fixture
Class JTableCellFixture
java.lang.Object
org.fest.swing.fixture.JTableCellFixture
- All Implemented Interfaces:
ItemFixture
,MouseInputSimulationFixture
Understands functional testing of single cells in
JTable
s:
- user input simulation
- state verification
- property value query
Example:
// import static org.fest.swing.data.TableCell.row;JTableCellFixture
cell = dialog.table
("records").cell(row
(3).column(0)); cell.select().showPopupMenu();
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
JTableCellFixture
(JTableFixture table, TableCell cell) Creates a new
.JTableCellFixture
-
Method Summary
Modifier and TypeMethodDescriptionReturns a fixture that verifies the background color of this fixture's table cell.Cancels editing this fixture's table cell.(package private) TableCell
cell()
click()
Simulates a user clicking this fixture's table cell.click
(MouseButton button) Simulates a user clicking a cell in this fixture's table cell once, using the specified mouse button.private JTableCellFixture
click
(MouseButton button, int times) click
(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's table cell.int
column()
Returns the column index of this fixture's table cell.Simulates a user double-clicking this fixture's table cell.drag()
Simulates a user dragging this fixture's table cell.private JTableDriver
driver()
drop()
Simulates a user dropping into this fixture's table cell.editor()
Returns the editor of this fixture's table cell.enterValue
(String value) Enters the given value to this fixture's table cell.font()
Returns a fixture that verifies the font of this fixture's table cell.Returns a fixture that verifies the foreground color of this fixture's table cell.Asserts that this fixture's table cell is editable.Asserts that this fixture's table cell is not editable.requireValue
(String value) Asserts that the value of this fixture's table cell matches the given value.requireValue
(Pattern pattern) Asserts that the value of this fixture's table cell matches the given regular expression pattern.Simulates a user right-clicking this fixture's table cell.int
row()
Returns the row index of this fixture's table cell.select()
Simulates a user selecting this fixture's table cell.Shows a pop-up menu using this fixture's table cell as the invoker of the pop-up menu.Starts editing this fixture's table cell.Stops editing this fixture's table cell.(package private) JTableFixture
table()
private JTable
target()
private void
validateNotNull
(TableCell newCell) private void
validateNotNull
(JTableFixture newTable) value()
Returns theString
representation of the value of this fixture's table cell.
-
Field Details
-
table
-
cell
-
-
Constructor Details
-
JTableCellFixture
Creates a new
.JTableCellFixture
- Parameters:
table
- handles theJTable
containing the cell in this fixture.cell
- row and column indices of the table cell to be managed by this fixture.- Throws:
NullPointerException
- iftable
isnull
.NullPointerException
- ifcell
isnull
.
-
-
Method Details
-
validateNotNull
-
validateNotNull
-
table
JTableFixture table() -
cell
TableCell cell() -
select
Simulates a user selecting this fixture's table cell.- Specified by:
select
in interfaceItemFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.
-
click
Simulates a user clicking this fixture's table cell.- Specified by:
click
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.
-
click
Simulates a user clicking this fixture's table cell.- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
mouseClickInfo
- specifies the button to click and the times the button should be clicked.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseClickInfo
isnull
.IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's table cell.- Specified by:
doubleClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's table cell.- Specified by:
rightClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.
-
click
Simulates a user clicking a cell in this fixture's table cell once, using the specified mouse button.- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
button
- the mouse button to use.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseButton
isnull
.IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.
-
click
-
startEditing
Starts editing this fixture's table cell. This method should be called before manipulating the
returned byComponent
.editor()
This method uses the
from theJTableCellWriter
that created this fixture.JTableFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.IllegalStateException
- if this 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.- See Also:
-
stopEditing
Stops editing this fixture's table cell. This method should be called after manipulating the
returned byComponent
.editor()
This method uses the
from theJTableCellWriter
that created this fixture.JTableFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.IllegalStateException
- if this 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.- See Also:
-
cancelEditing
Cancels editing this fixture's table cell. This method should be called after manipulating the
returned byComponent
.editor()
TableCellFixture cell = table.cell(row(6).column(8)); Component editor = cell.editor(); // assume editor is a JTextField JTextComponentFixture editorFixture = new JTextComponentFixture(robot, (JTextField) editor); cell.
startEditing()
; editorFixture.enterText("Hello"); // discard any entered value cell.cancelEditing();This method uses the
from theJTableCellWriter
that created this fixture.JTableFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.IllegalStateException
- if this 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.- See Also:
-
editor
Returns the editor of this fixture's table cell. To manipulate the editor (e.g. wrapping it with aComponentFixture
,) the method
should be called first. To apply any changes back to the table cell, the methodstartEditing()
should be called. This method uses thestopEditing()
from theJTableCellWriter
that created this fixture.JTableFixture
Example:
TableCellFixture cell = table.cell(row(6).column(8)); Component editor = cell.editor(); // assume editor is a JTextField JTextComponentFixture editorFixture = new JTextComponentFixture(robot, (JTextField) editor); cell.
startEditing()
; editorFixture.enterText("Hello"); cell.stopEditing()
;- Returns:
- the editor of this fixture's table cell.
- See Also:
-
enterValue
Enters the given value to this fixture's table cell. This method starts cell edition, enters the given value and stops cell edition. To change the value of a cell, only a call to this method is necessary. If you need more flexibility, you can retrieve the cell editor with
.editor()
This method uses the
from theJTableCellWriter
that created this fixture.JTableFixture
- Parameters:
value
- the value to enter in the cell.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJTable
is disabled.IllegalStateException
- if this fixture'sJTable
is not showing on the screen.IllegalStateException
- if this cell is not editable.IndexOutOfBoundsException
- if any of the indices (row and column) is out of bounds.ActionFailedException
- if this driver'sJTableCellValueReader
is unable to enter the given value.- See Also:
-
driver
-
target
-
requireValue
Asserts that the value of this fixture's table cell matches the given value.- Parameters:
value
- the expected value of this fixture's table cell. It can be a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError
- if the value of this fixture's table cell does not match the expected one.
-
requireValue
Asserts that the value of this fixture's table cell matches the given regular expression pattern.- Parameters:
pattern
- the regular expression pattern to match.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the given regular expression pattern isnull
.AssertionError
- if the value of this fixture's table cell does not match the expected the given regular expression pattern.- Since:
- 1.2
-
font
Returns a fixture that verifies the font of this fixture's table cell. This method uses the
from theJTableCellReader
that created this fixture.JTableFixture
- Returns:
- a fixture that verifies the font of this fixture's table cell.
- See Also:
-
background
Returns a fixture that verifies the background color of this fixture's table cell. This method uses the
from theJTableCellReader
that created this fixture.JTableFixture
- Returns:
- a fixture that verifies the background color of this fixture's table cell.
- See Also:
-
foreground
Returns a fixture that verifies the foreground color of this fixture's table cell. This method uses the
from theJTableCellReader
that created this fixture.JTableFixture
- Returns:
- a fixture that verifies the foreground color of this fixture's table cell.
- See Also:
-
value
Returns theString
representation of the value of this fixture's table cell. This method uses the
from theJTableCellReader
that created this fixture.JTableFixture
- Specified by:
value
in interfaceItemFixture
- Returns:
- the
String
representation of the value of this fixture's table cell. - See Also:
-
drag
Simulates a user dragging this fixture's table cell.- Specified by:
drag
in interfaceItemFixture
- Returns:
- this fixture.
-
drop
Simulates a user dropping into this fixture's table cell.- Specified by:
drop
in interfaceItemFixture
- Returns:
- this fixture.
-
showPopupMenu
Shows a pop-up menu using this fixture's table cell as the invoker of the pop-up menu.- Specified by:
showPopupMenu
in interfaceItemFixture
- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
ComponentLookupException
- if a pop-up menu cannot be found.
-
requireEditable
Asserts that this fixture's table cell is editable.- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture's table cell is not editable.
-
requireNotEditable
Asserts that this fixture's table cell is not editable.- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture's table cell is editable.
-
row
public int row()Returns the row index of this fixture's table cell.- Returns:
- the row index of this fixture's table cell.
-
column
public int column()Returns the column index of this fixture's table cell.- Returns:
- the column index of this fixture's table cell.
-