-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FindActivePopup does not work for cascade JPopupMenu with JMenu cascading items #15
Comments
Hi, what would be the best approach to get this fixed and generally submitted into the master branch. All the code is present so I'd hoped this would be fixed (somehow), but I guess I'm not understanding how github works back in 2013, and now too to some extent. Also, 2013 was a bad time for FEST working or being built due to poor SNAPSHOT and easytesting.org going missing. Any feedback would be appreciated. |
Hi @DaveBrad thanks for commenting on this old issue. Currently the best way is doing a fork of assertj-swing. Committing the new changes on your own fork and clicking the "Pull request" button which lets the maintainers include your change in one second ;-) I'll have a look at the code above and can commit it by myself :P |
I slightly changed your code, since the list of popup menus found is not always in the correct order. And IMO it makes sense to return the outer popup menu not just any of them.. Thanks for your help and especially your patience ;-) |
Backport from Master to Branch 2.2.x (java 1.8 to 1.7) (cherry picked from commit 9d5ff3b)
Issue by DaveBrad from Wednesday Jan 30, 2013 at 09:09 GMT
Originally opened as alexruiz/fest-swing-1.x#6
When I test using findActivePopup I found that JPopupMenu with a cascade menu fails to found a popup.
On investigation (using FEST-Swing source code and debug via eclipse) the method private JPopupMenu activePopupMenu() of BasicRobot.java was doing a finder action and the found List structure had more than one item (JPopupMenu, JMenu). Thus the test for found.size() == 1 was failing. Changing the test to >= 1 resolved the problem.
Any chance this can be put into the new release of FEST-Swing?
Below is the code and a JUnit test for testing with a cascade.
BasicRobot.java
@RunsInEDT
private JPopupMenu activePopupMenu() {
List found = new ArrayList(finder().findAll(POPUP_MATCHER));
if (found.size() == 1) return (JPopupMenu)found.get(0);
return null;
}
advise to change to >= from == as the finder seems to find additional cascade jmenu in the array too
@RunsInEDT
private JPopupMenu activePopupMenu() {
List found = new ArrayList(finder().findAll(POPUP_MATCHER));
if (found.size() >= 1) return (JPopupMenu)found.get(0);
return null;
}
BasicRobot_findActivePopupMenu_Test.java
@RunsInEDT
final JPopupMenu addPopupMenuToTextFieldWithCascade() {
return createAndSetPopupMenuWithCascade(window.textField, "Luke", "Leia");
}
@RunsInEDT
public static JPopupMenu createAndSetPopupMenuWithCascade(final JComponent c, final String...items) {
return execute(new GuiQuery() {
@OverRide protected JPopupMenu executeInEDT() {
JPopupMenu popupMenu = new JPopupMenu();
@test
public void should_return_active_popupMenu_cascadingPopup() {
addPopupMenuToTextFieldWithCascade();
robot.showPopupMenu(window.textField);
}
The text was updated successfully, but these errors were encountered: