Skip to content

Commit 7e438cf

Browse files
Victor Rudometovmrserb
authored andcommitted
8233648: [TESTBUG] DefaultMenuBarTest.java failing on macos
Backport-of: 46b5bfbc38f14607f0db686a42f1fa96d2f61891
1 parent 2728c7a commit 7e438cf

File tree

2 files changed

+16
-23
lines changed

2 files changed

+16
-23
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ java/awt/event/MouseEvent/MultipleMouseButtonsTest/MultipleMouseButtonsTest.java
498498
java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java 8233568 macosx-all
499499
java/awt/event/KeyEvent/DeadKey/DeadKeyMacOSXInputText.java 8233568 macosx-all
500500
java/awt/event/KeyEvent/DeadKey/deadKeyMacOSX.java 8233568 macosx-all
501-
com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java 8233648 macosx-all
502501
java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.java 7185258 macosx-all
503502
java/awt/TrayIcon/RightClickWhenBalloonDisplayed/RightClickWhenBalloonDisplayed.java 8238720 windows-all
504503
java/awt/PopupMenu/PopupMenuLocation.java 8238720 windows-all

test/jdk/com/apple/eawt/DefaultMenuBar/DefaultMenuBarTest.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,18 +24,21 @@
2424
/**
2525
* @test
2626
* @key headful
27-
* @bug 8007267
27+
* @bug 8007267 8233648
2828
* @summary [macosx] com.apple.eawt.Application.setDefaultMenuBar is not working
2929
* @requires (os.family == "mac")
30-
31-
* @modules java.desktop/sun.awt
32-
* java.desktop/com.apple.eawt
33-
* @run main DefaultMenuBarTest
30+
* @modules java.desktop/com.apple.eawt
31+
* @run main/othervm DefaultMenuBarTest
3432
*/
3533

36-
import java.awt.*;
37-
import java.awt.event.*;
38-
import javax.swing.*;
34+
import java.awt.Robot;
35+
import javax.swing.JMenu;
36+
import javax.swing.JMenuBar;
37+
import javax.swing.JMenuItem;
38+
import javax.swing.KeyStroke;
39+
import javax.swing.SwingUtilities;
40+
import java.awt.event.InputEvent;
41+
import java.awt.event.KeyEvent;
3942
import java.lang.reflect.Method;
4043

4144

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

5255
System.setProperty("apple.laf.useScreenMenuBar", "true");
53-
SwingUtilities.invokeAndWait(new Runnable() {
54-
public void run() {
55-
createAndShowGUI();
56-
}
57-
});
56+
SwingUtilities.invokeAndWait(DefaultMenuBarTest::createAndShowGUI);
5857

5958
Robot robot = new Robot();
6059
robot.setAutoDelay(100);
60+
robot.waitForIdle();
6161

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

7878
newItem.setAccelerator(ks);
79-
newItem.addActionListener(
80-
new ActionListener(){
81-
public void actionPerformed(ActionEvent e) {
82-
listenerCallCounter++;
83-
}
84-
}
85-
);
79+
newItem.addActionListener(e -> listenerCallCounter++);
8680
menu.add(newItem);
8781

8882
JMenuBar defaultMenu = new JMenuBar();
@@ -104,7 +98,7 @@ public void actionPerformed(ActionEvent e) {
10498
}
10599
}
106100
} catch (Exception e) {
107-
e.printStackTrace();
101+
throw new RuntimeException(e);
108102
}
109103
}
110104
}

0 commit comments

Comments
 (0)