I am trying to verify the copy and paste menu functions and I ran into this issue.
I type in some text into a JTextField and then highlight it. Next I click on the Edit menu and select Copy.
When the robot clicks on Edit, the focus is lost on the text component and the hightlight goes away. So the Copy action then copies nothing.
I can run through this scenario manually and everything works fine.
The test was passing in Fest version 0.8 and is broken in version 1.0.
I ran into a similar issue and I think the problem is due to the following code:
public void BasicRobot.click(Component c, Point where, MouseButton button, int times) { if (c != null) focus(c); // ...more code... }
What's the rationale for this focus() call in click?
What I wanted to test when I came across the problem was the following: I have a component that opens a popup menu in a similar manner as a JComboBox. My test should ensure that the component closes the popup menu if another component is clicked that is not focusable (e.g. JPanel). With the call to focus() as depicted above my component gets a FOCUS_LOST event when calling panelFixture.click(). This does not happen if I click the JPanel manually in the application.