Hi Bassam,
As you certainly already know, all UISpec4J component wrappers offer a means to check their associated tooltips.
Now, we didn't anticipated the fact that one could attach tooltips to ComboBox items (and, more generally, to compound components items).
This may be an interesting improvement for the next version... (to be studied!)
Sorry for that... I will try here to suggest a workaround: write a static function, taking a ComboBox wrapper as a parameter.
( Disclaimer: the code hereafter has not been tested ;)
public static Assertion tooltipEquals(ComboBox comboBox, int index, final String text) {
JComboBox jComboBox = comboBox.getAwtComponent();
Object value = jComboBox.getModel().getElementAt(index);
final JComponent component = (JComponent) jComboBox.getRenderer().getListCellRendererComponent(new JList(), value, index, false, false);
return new Assertion() {
public void check() {
AssertAdapter.assertEquals(text, component.getToolTipText());
}
};
}
I understand that such an API may not be ideal, but let's consider it as a first draft.
Please tell us what you think and how this works: your feedback (ideally along with the final workaround you will have implemented) will drive the possible integration of such an improvement in the library.
I hope this helps,
Regards,
Pascal.
On Jul 13, 2009, at 11:24 PM, Bassam Islam wrote:
Hi,
Thank you so much for the help you've given me. You've been very responsive and helpful.
Apologies if this question is simple, but how do I check the contents of a tooltip that is attached to a choice in a combobox that results from clicking in a cell in a table?
E.g.:
assertTrue(mainWindow.getTable().editCell(0, 1).getComboBox().[Get a choice from the combobox].tooltipContains("Tooltip text"));
I know that I can reference the contents of the cell using this method, along with the contents of the combobox, and to select a choice in there, but I don't know how to check the tooltip contents for the different choices in the combobox.
Thanks for your help,
Bassam