Skip to content
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

FEST unable to click on menus under Mac OS X / Java 7 #2

Open
martinrleon opened this issue Aug 24, 2012 · 4 comments
Open

FEST unable to click on menus under Mac OS X / Java 7 #2

martinrleon opened this issue Aug 24, 2012 · 4 comments
Assignees

Comments

@martinrleon
Copy link

I am trying to run FEST tests under Mac OS X 10.7.4 x86_64 using Oracle Corporation 1.7.0_06

The Oracle JDK for OS X is available at [http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1637583.html]

When trying to click on a menu item FEST returns the following Exception:

Running on:
Exception in thread "main" org.fest.swing.exception.ActionFailedException: Clicking on menu item <javax.swing.JMenu[name=null, text='File', selected=false, enabled=true, visible=true, showing=true]> never showed a pop-up menu
at org.fest.swing.exception.ActionFailedException.actionFailure(ActionFailedException.java:33)
at org.fest.swing.driver.JMenuItemDriver.ensurePopupIsShowing(JMenuItemDriver.java:137)
at org.fest.swing.driver.JMenuItemDriver.click(JMenuItemDriver.java:73)
at org.fest.swing.driver.JMenuItemDriver.activateParentIfIsAMenu(JMenuItemDriver.java:97)
at org.fest.swing.driver.JMenuItemDriver.show(JMenuItemDriver.java:79)
at org.fest.swing.driver.JMenuItemDriver.click(JMenuItemDriver.java:71)
at org.fest.swing.fixture.JMenuItemFixture.click(JMenuItemFixture.java:84)
at com.test.NewSwingAppTest.doFESTtest(NewSwingAppTest.java:42)
at com.test.NewSwingAppTest.main(NewSwingAppTest.java:16)

See the code below:

package com.test;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import javax.swing.SwingUtilities;

public class NewSwingApp extends javax.swing.JFrame {

    /**
     * 
     */
    private static final long serialVersionUID = -6489118287010615132L;

    protected static final String OS_NAME = System.getProperty("os.name");
    protected static final String OS_VERSION = System.getProperty("os.version");
    protected static final String OS_ARCH = System.getProperty("os.arch");
    protected static final String JAVA_VER = System.getProperty("java.version");
    protected static final String JAVA_VENDOR = System.getProperty("java.vendor");

    private JMenuItem helpMenuItem;
    private JMenu jMenu5;
    private JMenuItem deleteMenuItem;
    private JSeparator jSeparator1;
    private JMenuItem pasteMenuItem;
    private JMenuItem copyMenuItem;
    private JMenuItem cutMenuItem;
    private JMenu jMenu4;
    private JMenuItem exitMenuItem;
    private JSeparator jSeparator2;
    private JMenuItem closeFileMenuItem;
    private JMenuItem saveAsMenuItem;
    private JMenuItem saveMenuItem;
    private JMenuItem openFileMenuItem;
    private JMenuItem newFileMenuItem;
    private JMenu jMenu3;
    private JMenuBar jMenuBar1;

    /**
    * Auto-generated main method to display this JFrame
    */
    public static void main(String[] args) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                final NewSwingApp inst = new NewSwingApp();
                inst.setLocationRelativeTo(null);
                inst.setVisible(true);
            }
        });
    }

    public NewSwingApp() {
        super();
        initGUI();

        System.out.println("\nRunning on:");
        System.out.format("\tOS: %s %s %s\n", OS_NAME, OS_VERSION, OS_ARCH);
        System.out.format("\tJava: %s %s\n", JAVA_VENDOR, JAVA_VER);
    }

    private void initGUI() {
        try {
            {
                this.setTitle("NewSwingApp");
            }
            setSize(400, 300);
            setPreferredSize(getSize());
            setMaximumSize(getPreferredSize());
            setMinimumSize(getPreferredSize());
            {
                this.jMenuBar1 = new JMenuBar();
                setJMenuBar(this.jMenuBar1);
                {
                    this.jMenu3 = new JMenu();
                    this.jMenuBar1.add(this.jMenu3);
                    this.jMenu3.setText("File");
                    {
                        this.newFileMenuItem = new JMenuItem();
                        this.jMenu3.add(this.newFileMenuItem);
                        this.newFileMenuItem.setText("New");
                    }
                    {
                        this.openFileMenuItem = new JMenuItem();
                        this.jMenu3.add(this.openFileMenuItem);
                        this.openFileMenuItem.setText("Open");
                    }
                    {
                        this.saveMenuItem = new JMenuItem();
                        this.jMenu3.add(this.saveMenuItem);
                        this.saveMenuItem.setText("Save");
                    }
                    {
                        this.saveAsMenuItem = new JMenuItem();
                        this.jMenu3.add(this.saveAsMenuItem);
                        this.saveAsMenuItem.setText("Save As ...");
                    }
                    {
                        this.closeFileMenuItem = new JMenuItem();
                        this.jMenu3.add(this.closeFileMenuItem);
                        this.closeFileMenuItem.setText("Close");
                    }
                    {
                        this.jSeparator2 = new JSeparator();
                        this.jMenu3.add(this.jSeparator2);
                    }
                    {
                        this.exitMenuItem = new JMenuItem();
                        this.jMenu3.add(this.exitMenuItem);
                        this.exitMenuItem.setText("Exit");
                        this.exitMenuItem.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                System.exit(NORMAL);
                            }
                        });
                    }
                }
                {
                    this.jMenu4 = new JMenu();
                    this.jMenuBar1.add(this.jMenu4);
                    this.jMenu4.setText("Edit");
                    {
                        this.cutMenuItem = new JMenuItem();
                        this.jMenu4.add(this.cutMenuItem);
                        this.cutMenuItem.setText("Cut");
                    }
                    {
                        this.copyMenuItem = new JMenuItem();
                        this.jMenu4.add(this.copyMenuItem);
                        this.copyMenuItem.setText("Copy");
                    }
                    {
                        this.pasteMenuItem = new JMenuItem();
                        this.jMenu4.add(this.pasteMenuItem);
                        this.pasteMenuItem.setText("Paste");
                    }
                    {
                        this.jSeparator1 = new JSeparator();
                        this.jMenu4.add(this.jSeparator1);
                    }
                    {
                        this.deleteMenuItem = new JMenuItem();
                        this.jMenu4.add(this.deleteMenuItem);
                        this.deleteMenuItem.setText("Delete");
                    }
                }
                {
                    this.jMenu5 = new JMenu();
                    this.jMenuBar1.add(this.jMenu5);
                    this.jMenu5.setText("Help");
                    {
                        this.helpMenuItem = new JMenuItem();
                        this.jMenu5.add(this.helpMenuItem);
                        this.helpMenuItem.setText("Help");
                    }
                }
            }
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }

}
package com.test;

import org.fest.swing.edt.FailOnThreadViolationRepaintManager;
import org.fest.swing.edt.GuiActionRunner;
import org.fest.swing.edt.GuiQuery;
import org.fest.swing.fixture.FrameFixture;

public class NewSwingAppTest {

    private NewSwingApp swingApp;

    private FrameFixture window;

    public static void main(String[] args) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        doFESTtest();
    }

    public static void launchApp() {

        final NewSwingApp inst = new NewSwingApp();

        inst.setVisible(true);
    }

    public static void doFESTtest() {
        FailOnThreadViolationRepaintManager.install();

        final NewSwingAppTest testApp = new NewSwingAppTest();

        testApp.swingApp = GuiActionRunner.execute(new GuiQuery<NewSwingApp>() {
            protected NewSwingApp executeInEDT() {

                final NewSwingApp inst = new NewSwingApp();

                return inst;
            }
        });
        testApp.window = new FrameFixture(testApp.swingApp);
        testApp.window.robot.showWindow(testApp.window.target, null, false);

        testApp.window.menuItemWithPath("File", "Exit").click();
    }
}
@ghost ghost assigned wanghy Aug 24, 2012
@alexruiz
Copy link
Owner

Thanks a lot, Martin, for filing this bug. Yvonne and I will be taking a look at it shortly. I would take us a little more time than usual though. We haven't touched the code base for more than a year, so some re-learning will be necessary. We also need to migrate the project to Java 7.

@martinrleon
Copy link
Author

@wanghy -- any update on the status of this? I know you guys are working through a huge backlog

@alexruiz
Copy link
Owner

alexruiz commented Oct 2, 2012

If you haven't heard from us, there are no updates. We will get there,
eventually.

Cheers,
-Alex

On Tue, Oct 2, 2012 at 10:01 AM, martinrleon [email protected]:

@wanghy https://github.com/wanghy -- any update on the status of this?
I know you guys are working through a huge backlog


Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-9078335.

@ffissore
Copy link

This is related to #11
Calling System.setProperty("mrj.version", "whynot"); in some parent abstract test class makes tests work again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants