Skip to content

Commit 1499e5e

Browse files
author
Alexander Zvegintsev
committedJun 7, 2022
8273573: [macos12] ActionListenerCalledTwiceTest.java fails on macOS 12
Reviewed-by: psadhukhan, serb
1 parent 2f62f15 commit 1499e5e

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed
 

‎test/jdk/ProblemList.txt

-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all
672672
javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all
673673
javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all
674674
javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
675-
javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java 8273573 macosx-all
676675

677676
# Several tests which fail on some hidpi systems/macosx12-aarch64 system
678677
java/awt/Window/8159168/SetShapeTest.java 8274106 macosx-aarch64

‎test/jdk/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java

+26-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2022, 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
@@ -21,42 +21,45 @@
2121
* questions.
2222
*/
2323

24-
/**
24+
/*
2525
* @test
2626
* @key headful
2727
* @bug 7160951 8152492 8178448
2828
* @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
29-
* @author vera.akulova@oracle.com
30-
* @modules java.desktop/java.awt:open
31-
* @library /test/lib
32-
* @build jdk.test.lib.Platform
29+
* @requires (os.family == "mac")
3330
* @run main ActionListenerCalledTwiceTest
3431
*/
3532

36-
import jdk.test.lib.Platform;
37-
import java.awt.*;
38-
import java.awt.event.*;
39-
import javax.swing.*;
33+
import java.awt.Desktop;
34+
import java.awt.Robot;
35+
import java.awt.event.InputEvent;
36+
import java.awt.event.KeyEvent;
37+
import javax.swing.JFrame;
38+
import javax.swing.JMenu;
39+
import javax.swing.JMenuBar;
40+
import javax.swing.JMenuItem;
41+
import javax.swing.KeyStroke;
42+
import javax.swing.SwingUtilities;
4043

4144
public class ActionListenerCalledTwiceTest {
4245

43-
static String menuItems[] = {"Item1", "Item2", "Item3",
44-
"Item4", "Item5", "Item6"};
45-
static KeyStroke keyStrokes[] = {
46-
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
46+
static final String[] menuItems = { "Item1", "Item2", "Item3",
47+
"Item4", "Item5", "Item6" };
48+
static final KeyStroke[] keyStrokes = {
49+
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_DOWN_MASK),
4750
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
48-
KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),
49-
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.META_MASK),
50-
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK),
51-
KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK)
51+
KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_DOWN_MASK),
52+
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.META_DOWN_MASK),
53+
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK),
54+
KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_DOWN_MASK)
5255
};
5356

5457
static JMenuBar bar;
5558
static JFrame frame;
5659
static volatile int listenerCallCounter = 0;
5760

5861
public static void main(String[] args) throws Exception {
59-
if (!Platform.isOSX()) {
62+
if (!System.getProperty("os.name").toLowerCase().startsWith("mac")) {
6063
System.out.println("This test is for MacOS only." +
6164
" Automatically passed on other platforms.");
6265
return;
@@ -81,7 +84,10 @@ public static void main(String[] args) throws Exception {
8184

8285
testForTwice(robot, "DefaultMenuBar");
8386
} finally {
84-
SwingUtilities.invokeAndWait(() -> frame.dispose());
87+
SwingUtilities.invokeAndWait(() -> {
88+
frame.dispose();
89+
Desktop.getDesktop().setDefaultMenuBar(null);
90+
});
8591
}
8692
}
8793

0 commit comments

Comments
 (0)
Please sign in to comment.