|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.uispec4j.AbstractUIComponent
org.uispec4j.AbstractSwingUIComponent
org.uispec4j.Table
public class Table
Wrapper for JTable components.
The contents of the underlying table can be usually checked with String or Boolean values, as in the following example:
assertTrue(table.contentEquals(new String[]{
{"Bart", "Simpson"},
{"Marge", "Simpson"}
}));
The conversion between the values (Strings) given in the test and the values
actually displayed by the table renderer is performed by a dedicated
TableCellValueConverter, which retrieves the graphical component that draws
the table cells and determines the displayed value accordingly.
A DefaultTableCellValueConverter is used by default by the Table component.
| Nested Class Summary | |
|---|---|
class |
Table.Cell
Represents a table cell. |
class |
Table.Header
|
| Field Summary | |
|---|---|
static java.lang.Class[] |
SWING_CLASSES
|
static java.lang.String |
TYPE_NAME
|
| Constructor Summary | |
|---|---|
Table(javax.swing.JTable table)
|
|
| Method Summary | |
|---|---|
void |
addRowToSelection(int row)
|
Assertion |
backgroundEquals(java.lang.Object[][] colors)
Checks the background color of the table cells using either Color or String objects |
Assertion |
backgroundNear(int row,
int column,
java.lang.Object expected)
|
Assertion |
blockEquals(int fromRowIndex,
int fromColumnIndex,
int columnCount,
int rowCount,
java.lang.Object[][] expected)
|
Assertion |
borderEquals(javax.swing.border.Border[][] borders)
|
Assertion |
cellEquals(int row,
int column,
java.lang.Object expectedValue)
Checks the contents of a given cell. |
Assertion |
cellEquals(int row,
int column,
java.lang.Object expectedValue,
TableCellValueConverter converter)
Checks the contents of a given cell using a specific data converter. |
Assertion |
cellIsEditable(int rowIndex,
int columnIndex)
|
Assertion |
cellIsSelected(int rowIndex,
int columnIndex)
|
void |
clearSelection()
|
void |
click(int row,
int column)
|
void |
click(int row,
int column,
Key.Modifier modifier)
|
Assertion |
columnCountEquals(int count)
|
Assertion |
columnEquals(int columnIndex,
java.lang.Object[] expectedColumn)
|
Assertion |
columnIsEditable(int columnIndex,
boolean isEditable)
|
Assertion |
columnIsEditable(java.lang.String columnName,
boolean shouldBeEditable)
|
Assertion |
columnSizeEquals(int columnIndex,
int expectedWidth)
|
Assertion |
columnSizeEquals(java.lang.String columnName,
int expectedWidth)
|
Assertion |
containsRow(int columnIndex,
java.lang.Object cellContent)
Checks that the table contains a row with a given cell. |
Assertion |
containsRow(java.lang.Object[] expectedRow)
Checks that the table contains a complete row. |
Assertion |
contentEquals(java.lang.Object[][] expected)
Checks the values displayed in the table. Sample usage: |
Assertion |
contentEquals(java.lang.String[] columnNames,
java.lang.Object[][] expected)
Checks the values displayed in the table for a given set of columns. |
void |
doubleClick(int row,
int column)
|
Table.Cell |
editCell(int row,
int column)
Returns a Table.Cell object for interacting with the content of an individual table cell.
Sample usage: |
void |
editCell(int row,
int column,
java.lang.String value,
boolean validateChange)
Inputs some text in a given cell. This method only works when the underlying editor is a JTextField or a JComboBox - it will throw an exception if this is not the case, or if the cell is not editable. |
Assertion |
endsWith(java.lang.Object[][] expectedEndRows)
Asserts that the contents of the table ends with the specified rows. |
Assertion |
foregroundEquals(java.lang.Object[][] colors)
Checks the foreground color of the table cells using either Color or String objects |
Assertion |
foregroundNear(int row,
int column,
java.lang.Object expected)
|
javax.swing.JTable |
getAwtComponent()
Returns the Java GUI component represented by this object. |
int |
getColumnCount()
|
int |
getColumnIndex(java.lang.String columnName)
|
java.lang.Object |
getContentAt(int row,
int column)
Returns the object (String or Boolean) displayed in a given cell. The returned object is that returned by the current TableCellValueConverter used by the table. |
java.lang.Object |
getContentAt(int row,
int column,
TableCellValueConverter converter)
Returns the value displayed in a given cell using a specific converter. |
java.lang.String |
getDescriptionTypeName()
Returns the name of the component as it will appear in the XML representation returned by UIComponent.getDescription(). |
Table.Header |
getHeader()
Returns a helper interface which gives access to the table header. |
javax.swing.JTable |
getJTable()
|
int |
getRowCount()
|
int |
getRowIndex(int column,
java.lang.Object value)
|
int[] |
getRowIndices(int column,
java.lang.Object value)
|
java.awt.Component |
getSwingEditorComponentAt(int row,
int column)
|
java.awt.Component |
getSwingRendererComponentAt(int row,
int column)
|
Assertion |
hasHeader()
Checks whether a header is displayed for this table. |
Assertion |
isEditable(boolean[][] expected)
|
Assertion |
isEmpty()
|
void |
removeRowFromSelection(int row)
|
void |
resizeColumn(java.lang.String columnName,
int width)
|
void |
rightClick(int row,
int column)
|
Assertion |
rowCountEquals(int count)
|
Assertion |
rowEquals(int rowIndex,
int fromColumnIndex,
int columnCount,
java.lang.Object[] expectedRow)
|
Assertion |
rowEquals(int rowIndex,
java.lang.Object[] expectedRow)
|
Assertion |
rowEquals(int rowIndex,
java.lang.String[] columnNames,
java.lang.Object[] expected)
|
Assertion |
rowIsSelected(int rowIndex)
|
Assertion |
rowsAreSelected(int... rowIndexes)
|
void |
selectAllRows()
|
void |
selectBlock(int top,
int left,
int bottom,
int right)
|
void |
selectCell(int row,
int column)
|
Assertion |
selectionEquals(boolean[][] expected)
Checks the selection on a cell-by-cell basis. |
Assertion |
selectionIsEmpty()
|
void |
selectRow(int row)
|
void |
selectRows(int... rowIndexes)
|
void |
selectRowSpan(int start,
int end)
|
void |
selectRowsWithText(int column,
java.lang.String... labels)
Selects all rows where the content of the given column is one of the given labels. |
void |
setCellValueConverter(int column,
TableCellValueConverter tableCellValueConverter)
Sets a new converter for analyzing the cells of a given column. |
void |
setDefaultCellValueConverter(TableCellValueConverter cellValueConverter)
Sets a new converter for analyzing the table cells content. |
Assertion |
startsWith(java.lang.Object[][] expectedFirstRows)
Asserts that the contents of the table starts with the specified rows. |
java.lang.String |
toString()
|
Trigger |
triggerClick(int row,
int column,
Key.Modifier modifier)
|
Trigger |
triggerDoubleClick(int row,
int column)
|
Trigger |
triggerRightClick(int row,
int column)
|
| Methods inherited from class org.uispec4j.AbstractSwingUIComponent |
|---|
tooltipContains, tooltipEquals |
| Methods inherited from class org.uispec4j.AbstractUIComponent |
|---|
addAttributes, backgroundEquals, backgroundNear, foregroundEquals, foregroundNear, getContainer, getContainer, getDescription, getDescription, getLabel, getName, getSubDescription, isEnabled, isVisible, pressKey, releaseKey, typeKey |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String TYPE_NAME
public static final java.lang.Class[] SWING_CLASSES
| Constructor Detail |
|---|
public Table(javax.swing.JTable table)
| Method Detail |
|---|
public java.lang.String getDescriptionTypeName()
UIComponentUIComponent.getDescription().
public javax.swing.JTable getAwtComponent()
UIComponent
getAwtComponent in interface UIComponentgetAwtComponent in class AbstractSwingUIComponentpublic javax.swing.JTable getJTable()
public Table.Header getHeader()
public void setDefaultCellValueConverter(TableCellValueConverter cellValueConverter)
public void setCellValueConverter(int column,
TableCellValueConverter tableCellValueConverter)
public void click(int row,
int column)
public void click(int row,
int column,
Key.Modifier modifier)
public void rightClick(int row,
int column)
public void doubleClick(int row,
int column)
public Trigger triggerClick(int row,
int column,
Key.Modifier modifier)
public Trigger triggerRightClick(int row,
int column)
public Trigger triggerDoubleClick(int row,
int column)
public int getRowCount()
public Assertion rowCountEquals(int count)
public int getColumnCount()
public Assertion columnCountEquals(int count)
public java.lang.Object getContentAt(int row,
int column)
setCellValueConverter(int,TableCellValueConverter),
setDefaultCellValueConverter(TableCellValueConverter)
public java.lang.Object getContentAt(int row,
int column,
TableCellValueConverter converter)
public Table.Cell editCell(int row,
int column)
Table.Cell object for interacting with the content of an individual table cell.
Sample usage:
ComboBox comboBox = table.editCell(0, 0).getComboBox();
assertTrue(comboBox.contentEquals(choices));
comboBox.select("b");
public int getRowIndex(int column,
java.lang.Object value)
public int[] getRowIndices(int column,
java.lang.Object value)
public void editCell(int row,
int column,
java.lang.String value,
boolean validateChange)
editCell(int,int) for a more flexible edition method.
public Assertion hasHeader()
public Assertion contentEquals(java.lang.Object[][] expected)
assertTrue(table.contentEquals(new Object[][]{
{"a", Boolean.TRUE, "3"},
{"c", Boolean.FALSE, "4"}
}));
The conversion between the displayed values and the objects to
be given in the array can be customized with
setCellValueConverter(int,TableCellValueConverter)
public Assertion blockEquals(int fromRowIndex,
int fromColumnIndex,
int columnCount,
int rowCount,
java.lang.Object[][] expected)
public Assertion contentEquals(java.lang.String[] columnNames,
java.lang.Object[][] expected)
contentEquals(Object[][])
public Assertion cellEquals(int row,
int column,
java.lang.Object expectedValue)
setCellValueConverter(int,TableCellValueConverter)
getContentAt(int,int)
public Assertion cellEquals(int row,
int column,
java.lang.Object expectedValue,
TableCellValueConverter converter)
setCellValueConverter(int,TableCellValueConverter)
getContentAt(int,int,TableCellValueConverter)
public Assertion rowEquals(int rowIndex,
java.lang.Object[] expectedRow)
public Assertion rowEquals(int rowIndex,
int fromColumnIndex,
int columnCount,
java.lang.Object[] expectedRow)
public Assertion rowEquals(int rowIndex,
java.lang.String[] columnNames,
java.lang.Object[] expected)
public Assertion columnEquals(int columnIndex,
java.lang.Object[] expectedColumn)
public Assertion isEmpty()
public Assertion foregroundEquals(java.lang.Object[][] colors)
public Assertion foregroundNear(int row,
int column,
java.lang.Object expected)
public Assertion backgroundNear(int row,
int column,
java.lang.Object expected)
public Assertion backgroundEquals(java.lang.Object[][] colors)
public Assertion borderEquals(javax.swing.border.Border[][] borders)
public int getColumnIndex(java.lang.String columnName)
public Assertion isEditable(boolean[][] expected)
public Assertion columnIsEditable(int columnIndex,
boolean isEditable)
public Assertion cellIsEditable(int rowIndex,
int columnIndex)
public Assertion columnIsEditable(java.lang.String columnName,
boolean shouldBeEditable)
public Assertion selectionIsEmpty()
public Assertion selectionEquals(boolean[][] expected)
public Assertion rowIsSelected(int rowIndex)
public Assertion cellIsSelected(int rowIndex,
int columnIndex)
public java.lang.String toString()
toString in class java.lang.Object
public java.awt.Component getSwingEditorComponentAt(int row,
int column)
public java.awt.Component getSwingRendererComponentAt(int row,
int column)
public void resizeColumn(java.lang.String columnName,
int width)
public Assertion columnSizeEquals(java.lang.String columnName,
int expectedWidth)
public Assertion columnSizeEquals(int columnIndex,
int expectedWidth)
public Assertion rowsAreSelected(int... rowIndexes)
public void selectCell(int row,
int column)
public void selectAllRows()
public void selectRow(int row)
public void selectRows(int... rowIndexes)
public void selectRowsWithText(int column,
java.lang.String... labels)
public void selectRowSpan(int start,
int end)
public void selectBlock(int top,
int left,
int bottom,
int right)
public void addRowToSelection(int row)
public void removeRowFromSelection(int row)
public void clearSelection()
public Assertion startsWith(java.lang.Object[][] expectedFirstRows)
public Assertion endsWith(java.lang.Object[][] expectedEndRows)
public Assertion containsRow(java.lang.Object[] expectedRow)
public Assertion containsRow(int columnIndex,
java.lang.Object cellContent)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||