Skip to content

Commit

Permalink
8233648: [TESTBUG] DefaultMenuBarTest.java failing on macos
Browse files Browse the repository at this point in the history
Backport-of: 46b5bfbc38f14607f0db686a42f1fa96d2f61891
  • Loading branch information
Victor Rudometov authored and mrserb committed Oct 29, 2022
1 parent 18631ef commit 5ecd16d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@ java/awt/event/MouseEvent/MultipleMouseButtonsTest/MultipleMouseButtonsTest.java
java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java 8233568 macosx-all
java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java 8233568 macosx-all
java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java 8233568 macosx-all
com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java 8233648 macosx-all
java/awt/TrayIcon/RightClickWhenBalloonDisplayed/RightClickWhenBalloonDisplayed.java 8238720 windows-all
java/awt/PopupMenu/PopupMenuLocation.java 8238720 windows-all
java/awt/GridLayout/ComponentPreferredSize/ComponentPreferredSize.java 8238720 windows-all
Expand Down
38 changes: 16 additions & 22 deletions test/jdk/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,18 +24,21 @@
/**
* @test
* @key headful
* @bug 8007267
* @bug 8007267 8233648
* @summary [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
* @requires (os.family == "mac")
* @author leonid.romanov@oracle.com
* @modules java.desktop/sun.awt
* java.desktop/com.apple.eawt
* @run main DefaultMenuBarTest
* @modules java.desktop/com.apple.eawt
* @run main/othervm DefaultMenuBarTest
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Robot;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.lang.reflect.Method;


Expand All @@ -50,14 +53,11 @@ public static void main(String[] args) throws Exception {
}

System.setProperty("apple.laf.useScreenMenuBar", "true");
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
SwingUtilities.invokeAndWait(DefaultMenuBarTest::createAndShowGUI);

Robot robot = new Robot();
robot.setAutoDelay(100);
robot.waitForIdle();

robot.keyPress(KeyEvent.VK_META);
robot.keyPress(ks.getKeyCode());
Expand All @@ -76,13 +76,7 @@ private static void createAndShowGUI() {
JMenuItem newItem = new JMenuItem("Open");

newItem.setAccelerator(ks);
newItem.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e) {
listenerCallCounter++;
}
}
);
newItem.addActionListener(e -> listenerCallCounter++);
menu.add(newItem);

JMenuBar defaultMenu = new JMenuBar();
Expand All @@ -104,7 +98,7 @@ public void actionPerformed(ActionEvent e) {
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
}

1 comment on commit 5ecd16d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.