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
JTables:
- user input simulation
- state verification
- property value query
Example:
// import static org.fest.swing.data.TableCell.row;JTableCellFixturecell = dialog.table("records").cell(row(3).column(0)); cell.select().showPopupMenu();
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJTableCellFixture(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) TableCellcell()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 JTableCellFixtureclick(MouseButton button, int times) click(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's table cell.intcolumn()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 JTableDriverdriver()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.introw()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) JTableFixturetable()private JTabletarget()private voidvalidateNotNull(TableCell newCell) private voidvalidateNotNull(JTableFixture newTable) value()Returns theStringrepresentation of the value of this fixture's table cell.
-
Field Details
-
table
-
cell
-
-
Constructor Details
-
JTableCellFixture
Creates a new.JTableCellFixture- Parameters:
table- handles theJTablecontaining the cell in this fixture.cell- row and column indices of the table cell to be managed by this fixture.- Throws:
NullPointerException- iftableisnull.NullPointerException- ifcellisnull.
-
-
Method Details
-
validateNotNull
-
validateNotNull
-
table
JTableFixture table() -
cell
TableCell cell() -
select
Simulates a user selecting this fixture's table cell.- Specified by:
selectin interfaceItemFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis not showing on the screen.
-
click
Simulates a user clicking this fixture's table cell.- Specified by:
clickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis not showing on the screen.
-
click
Simulates a user clicking this fixture's table cell.- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
mouseClickInfo- specifies the button to click and the times the button should be clicked.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseClickInfoisnull.IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's table cell.- Specified by:
doubleClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's table cell.- Specified by:
rightClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis 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:
clickin interfaceMouseInputSimulationFixture- Parameters:
button- the mouse button to use.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseButtonisnull.IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis not showing on the screen.
-
click
-
startEditing
Starts editing this fixture's table cell. This method should be called before manipulating thereturned byComponent.editor()This method uses the
from theJTableCellWriterthat created this fixture.JTableFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis 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 thereturned byComponent.editor()This method uses the
from theJTableCellWriterthat created this fixture.JTableFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis 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 thereturned 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 theJTableCellWriterthat created this fixture.JTableFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis 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 methodshould be called first. To apply any changes back to the table cell, the methodstartEditing()should be called. This method uses thestopEditing()from theJTableCellWriterthat created this fixture.JTableFixtureExample:
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 theJTableCellWriterthat created this fixture.JTableFixture- Parameters:
value- the value to enter in the cell.- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJTableis disabled.IllegalStateException- if this fixture'sJTableis 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'sJTableCellValueReaderis 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 thefrom theJTableCellReaderthat 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 thefrom theJTableCellReaderthat 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 thefrom theJTableCellReaderthat created this fixture.JTableFixture- Returns:
- a fixture that verifies the foreground color of this fixture's table cell.
- See Also:
-
value
Returns theStringrepresentation of the value of this fixture's table cell. This method uses thefrom theJTableCellReaderthat created this fixture.JTableFixture- Specified by:
valuein interfaceItemFixture- Returns:
- the
Stringrepresentation of the value of this fixture's table cell. - See Also:
-
drag
Simulates a user dragging this fixture's table cell.- Specified by:
dragin interfaceItemFixture- Returns:
- this fixture.
-
drop
Simulates a user dropping into this fixture's table cell.- Specified by:
dropin 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:
showPopupMenuin 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.
-