| Issue 177: | JTableCellFixture#enterValue(String) with JComboBox as editor | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Sign in to add a comment
|
Hi, I am using version 1.0a3 of the FEST-Swing module. When using JTableCellFixture#enterValue(String) on a table cell with a JComboBox editor I get the following exception: java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:1803) at java.awt.Component.getLocationOnScreen(Component.java:1777) at javax.swing.JPopupMenu.show(JPopupMenu.java:909) at javax.swing.plaf.basic.BasicComboPopup.show(BasicComboPopup.java:191) at javax.swing.plaf.basic.BasicComboBoxUI.setPopupVisible(BasicComboBoxUI.java:833) at org.fest.swing.driver.JComboBoxDriver.dropDownVisibleThroughUIDelegate(JComboBoxDriver.java:201) at org.fest.swing.driver.JComboBoxDriver$2.run(JComboBoxDriver.java:192) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) The strange thing is that everything goes well if I edit the cell "manually." By "manually" I mean: 0. get a JTableCellFixture instance for the table cell in question 1. call startEditing() 2. find the JComboBox and create a JComboBoxFixture for it 3. select the value using the fixture 5. call stopEditing() I've traced the sequence of method calls for both cases: 1. for JTableCellFixture#enterValue(String) it all boils down to: JTableComboBoxEditorCellWriter#enterValue(JTable, int, int, String) 2. for manual editing: JTableComboBoxEditorCellWriter#startEditing(JTable, int, int) The two cases are basically the same, the real difference is that JTableCellFixture#enterValue uses a JComboBoxDriver to select the value and in the case of manual selection I create a JComboBoxFixture for the combo box and use it to select the value. It might be some synchronization problem. I've inserted some Thread#sleep calls in relevant methods, but didn't find anything useful so far. Thank you, Csabi |
||||||||||||||||
,
Jul 15, 2008
I've made a spelling mistake in the title. Could you correct it? Sorry, Csabi |
|||||||||||||||||
,
Jul 15, 2008
Hi Csabi, It would help us a lot if you could please attach the source for the GUI you are testing (if possible) :) Thanks! Yvonnne
Summary: [fest-swing] JTableCellFixture#enterValue(String) with JComboBox as editor
Status: Accepted Owner: wanghy1101 Labels: -Priority-Medium Priority-Critical OpSys-All Milestone-Release1.0 |
|||||||||||||||||
,
Jul 15, 2008
Hi Yvonne, I would really like to attach the code, but I simply can't. I'm testing a proprietary telecom application with a massive GUI. The table I'm testing has a complex model behind it. I don't know exactly how it works. The editor used for the cell is: com.l2fprod.common.beans.editor.ComboBoxPropertyEditor and the table is contained in a: com.jidesoft.docking.DockableFrame Thank you, Csabi |
|||||||||||||||||
,
Jul 16, 2008
Hi Csabi, No problem at all. We'll try to figure out the problem from the stack trace :) Regards, -Yvonne |
|||||||||||||||||
,
Jul 16, 2008
Quick question, is the JComboBox editable? Thanks! -Yvonne |
|||||||||||||||||
,
Jul 17, 2008
Hi, No, it's not editable. It would be great if you could tell me where you are writing from. I'm writing from Romania and it seems to me that our work schedules are very different. I could write from home to reduce turnaround times. If you can think of anything else that might help you, I'm listening. Maybe it would help you to have the stack trace of the FEST thread up to the point of calling JComboBoxDriver#dropDownVisibleThroughUIDelegate(JComboBox, boolean), for example. Thanks, Csabi |
|||||||||||||||||
,
Jul 17, 2008
Hi Csabi, Thanks for your reply. I'm writing from Silicon Valley, CA. The source of the problem is that the combobox is not being made visible, which is very weird. I'm working on reproducing this bug. Thanks, -Yvonne |
|||||||||||||||||
,
Jul 17, 2008
Hi Yvonne, Thank you for not giving up. As I said in the initial report I've found a workaround for the problem, but I really hope that you'll fix the bug real soon. My colleague who works on the table is currently on holiday, but if you can't fix the problem by the time he comes back, I'll ask him to write a small application with a similar table and I'll write a simple test for it, if the test fails, I'll send you the code so that you can play with it. Thanks again, Csabi |
|||||||||||||||||
,
Jul 17, 2008
Hi Csabi, I found the problem and I fixed it. Although I'm sure the bug is fixed, I still would like to test it using the code you are going to send us. Thanks! -Yvonne. |
|||||||||||||||||
,
Jul 17, 2008
(No comment was entered for this change.)
Status: Fixed
|
|||||||||||||||||
,
Jul 17, 2008
Hi Yvonne, I'll send you the code as soon as possible. I'll also test the fix with the actual code I'm testing. Great work, thanks, Csabi |
|||||||||||||||||
,
Aug 19, 2008
Hi Yvonne, I've just updated to 1.0b1. The fix doesn't seem to be working. Here is the stack trace: org.fest.swing.exception.WaitTimedOutError: Timed out waiting for Component com.l2fprod.common.beans.editor.ComboBoxPropertyEditor$1[name=null, selectedItem=All, contents=[All, None, Per Link], editable=false, enabled=true, visible=true, showing=false] to show on the screen at org.fest.swing.core.Pause.pause(Pause.java:64) at org.fest.swing.core.Pause.pause(Pause.java:42) at org.fest.swing.driver.JTableComboBoxEditorCellWriter.startCellEditing(JTableComboBoxEditorCellWriter.java:55) at org.fest.swing.driver.JTableComboBoxEditorCellWriter.enterValue(JTableComboBoxEditorCellWriter.java:47) at org.fest.swing.driver.BasicJTableCellWriter.enterValue(BasicJTableCellWriter.java:65) at org.fest.swing.driver.JTableDriver.enterValueInCell(JTableDriver.java:347) at org.fest.swing.fixture.JTableCellFixture.enterValue(JTableCellFixture.java:252) at ro.alcatel.art.test.acceptance.sncp.TestCase02.execute03(TestCase02.java:95) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.Invoker.invokeMethod(Invoker.java:478) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110) at org.testng.TestRunner.runWorkers(TestRunner.java:712) at org.testng.TestRunner.privateRun(TestRunner.java:582) at org.testng.TestRunner.run(TestRunner.java:477) at org.testng.SuiteRunner.runTest(SuiteRunner.java:324) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292) at org.testng.SuiteRunner.run(SuiteRunner.java:198) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823) at org.testng.TestNG.runSuitesLocally(TestNG.java:790) at org.testng.TestNG.run(TestNG.java:708) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124) Unfortunately we are currently jumping from release 1.3 to 2.0 with our telecom application, there is a lot of work to do, so I cannot rely on my colleague to write the test application, I'll try to do it myself. I'm also having a similar problem with a JFormattedTextField in a com.l2fprod.common.propertysheet.PropertySheetTable. I've done some debugging and it seems that the width and height of the text field are both 0. This doesn't happen when running the application normally. I've verified with Swing Explorer. Here is the stack trace: org.fest.swing.exception.WaitTimedOutError: Timed out waiting for Component javax.swing.JFormattedTextField[name=null, text='-135.42', enabled=true, visible=true, showing=false] to show on the screen at org.fest.swing.core.Pause.pause(Pause.java:64) at org.fest.swing.core.Pause.pause(Pause.java:42) at org.fest.swing.driver.JTableTextComponentEditorCellWriter.startCellEditing(JTableTextComponentEditorCellWriter.java:57) at org.fest.swing.driver.JTableTextComponentEditorCellWriter.enterValue(JTableTextComponentEditorCellWriter.java:48) at org.fest.swing.driver.BasicJTableCellWriter.enterValue(BasicJTableCellWriter.java:65) at org.fest.swing.driver.JTableDriver.enterValueInCell(JTableDriver.java:347) at org.fest.swing.fixture.JTableCellFixture.enterValue(JTableCellFixture.java:252) at ro.alcatel.art.test.play.TestPropertiesPanel.step04(TestPropertiesPanel.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.Invoker.invokeMethod(Invoker.java:478) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110) at org.testng.TestRunner.runWorkers(TestRunner.java:712) at org.testng.TestRunner.privateRun(TestRunner.java:582) at org.testng.TestRunner.run(TestRunner.java:477) at org.testng.SuiteRunner.runTest(SuiteRunner.java:324) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292) at org.testng.SuiteRunner.run(SuiteRunner.java:198) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823) at org.testng.TestNG.runSuitesLocally(TestNG.java:790) at org.testng.TestNG.run(TestNG.java:708) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124) Thanks, Csabi |
|||||||||||||||||
,
Aug 20, 2008
Hi again Yvonne,
I think I have finally found the problem.
It is in the enterValue(String) method of JTableTextComponentEditorCellWriter and
JTableComboBoxEditorCellWriter. I'll demonstrate with
JTableTextComponentEditorCellWriter.
The problem is that #enterValue(String) calls #editor(JTable, int, int) twice, once
directly and once indirectly, via startCellEditing(JTable, int, int).
This is a problem if either getCellEditor(int, int) of the table or
getTableCellEditorComponent(JTable, Object, boolean, int, int) of the cell editor
returns a new instance each time it is called.
For me it is the first case.
In JTableTextComponentEditorCellWriter#enterValue(String) the first line
JTextComponent editor = editor(table, row, column);
just gets an editor component, without the table being edited.
The second line
startCellEditing(table, row, column);
properly starts editing.
The third line
driver.replaceText(editor, value);
uses the editor retrieved in the first line.
Now here is the problem. It should, instead use the editor created by calling
startCellEditing.
In fact this would be wrong to, because the call to editor(JTable, int, int) in
startCellEditing(JTable, int, int) also returns an editor which has nothing to do
with the table (it's not the editor created by clicking on the cell). The real
solution is to find the real editor in the component hierarchy.
A solution might be:
public void enterValue(JTable table, int row, int column, String value) {
JTextComponent editor = startCellEditing(table, row, column);
driver.replaceText(editor, value);
stopEditing(editor);
}
/** ${@inheritDoc} */
public void startCellEditing(JTable table, int row, int column) {
clickCell(table, row, column, 2);
JTextComponent editor = robot.finder().findByType(table, JTextComponent.class);
pause(new WaitForComponentToShowCondition(editor));
}
I don't know if using the finder this way is correct, the robot should find subtypes
of JTextComponent too.
Thank you,
Csabi
|
|||||||||||||||||
,
Aug 20, 2008
Actually, the solution I gave isn't such a good one. Here is a better one: http://drop.io/tlmpw7n I haven't solved cancellation, it is more tricky, because the editor (not the editor component) cannot be found in the component hierarchy. I hope that you will find a solution for cancellation as well. Thank you, Csabi |
|||||||||||||||||
,
Aug 20, 2008
Hi Csabi, Thank you so much for helping us fixing this bug. We truly, truly appreciate the effort you have put to find the problem. It is awesome! Many thanks! -Yvonne
Status: Accepted
|
|||||||||||||||||
,
Aug 20, 2008
Hi Yvonne, Thank you for this great framework. I love the changes in 1.0b1. Have a great day, Csabi |
|||||||||||||||||
,
Nov 30, 2008
Set the module as a label, instead of being part of the title.
Summary: JTableCellFixture#enterValue(String) with JComboBox as editor
Labels: Module-fest-swing |
|||||||||||||||||
,
Nov 30, 2008
Hi Csabi, Thanks for the kind words about FEST! :) We have changed the way cell editing works now. We don't call editor anymore for every single action. The fix is in 1.0b3-SNAPSHOT-2. You can find more details about where to get it at http://groups.google.com/group/easytesting/browse_frm/thread/7bd11084eac6ef44 I'm going to mark this bug as fixed. As always, we truly appreciate your help! Cheers, -Alex
Status: Fixed
|
|||||||||||||||||
,
Dec 03, 2008
Hi Alex, Thanks for fixing it. Regards, Csabi |
|||||||||||||||||
| ► Sign in to add a comment | |||||||||||||||||