assertj / assertj/assertj-swing
Unable to find JPopupMenu in certain circumstances
- Dominant language
- Java
- Stars
- 121
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
_Issue by **[Bo Andersson](http://jira.codehaus.org/secure/ViewProfile.jspa?name=band)** from Tue, 31 Aug 2010 13:03:55 -0500_
_Originally opened as http://jira.codehaus.org/browse/FEST-386_
---
I have an application with several popupmenus attached to different components. When trying to run tests against those popup menus, fest swing is able to bring up the popup menu but is unable to find it. Investigation showed that the visible popup have the state isVisible() and isShowing() while the invisible popup(s) still have the isShowing() state but !isVisible(). This causes current finder logic to actually find two popups (which shouldn't be possible) and thus it returns an error saying it cannot find any popup whatsoever.
Unfortunately I'm unable to contribute a testcase since I haven't been able to reproduce this state in a self-contained test - however, I made some modifications to the current fest-swing code for testing my own app and simply changing the BasicRobot.POPUP_MATCHER to
private static final ComponentMatcher POPUP_MATCHER =
new AbstractComponentMatcher() {
public boolean matches(Component c)
{
return c.getClass().equals(JPopupMenu.class) && c.isVisible() && c.isShowing();
}
;
};
solved my issue, i.e check both isVisible() and isShowing() instead of simply isShowing().
Another proposal regarding this issue would be to add a check in BasicRobot.activePopupMenu() similar to
if (found.size() > 1) throw new IllegalStateException("Popup matcher incorrectly returned more than one visible popupMenu")
to assert against matcher problems due to strange component states.
---
votes (original issue): 0
watches (original issue): 0
Contributor guide
Assessment
This issue has not been assessed yet.