Skip to content

Commit 2ed46d8

Browse files
committed
8211822: Some tests fail after JDK-8210039
8202886: [macos] Test java/awt/MenuBar/8007006/bug8007006.java fails on MacOS Reviewed-by: mdoerr Backport-of: 245a729
1 parent f441970 commit 2ed46d8

File tree

5 files changed

+57
-46
lines changed

5 files changed

+57
-46
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ java/awt/Focus/WindowUpdateFocusabilityTest/WindowUpdateFocusabilityTest.java 82
463463
java/awt/datatransfer/ConstructFlavoredObjectTest/ConstructFlavoredObjectTest.java 8202860 linux-all
464464
java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java 8202790 macosx-all,linux-all
465465
java/awt/FileDialog/FilenameFilterTest/FilenameFilterTest.java 8202882 linux-all
466-
java/awt/MenuBar/8007006/bug8007006.java 8202886 macosx-all
467466
java/awt/Frame/FramesGC/FramesGC.java 8079069 macosx-all
468467
java/awt/dnd/MissingDragExitEventTest/MissingDragExitEventTest.java 8030121 macosx-all
469468
java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java 8202931 macosx-all,linux-all

test/jdk/java/awt/MenuBar/8007006/bug8007006.java

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
* @test
2626
* @key headful
2727
* @bug 8007006
28+
* @requires (os.family == "mac")
2829
* @summary [macosx] Closing subwindow loses main window menus.
29-
* @author Leonid Romanov
3030
* @library /test/lib
31-
* @build ExtendedRobot jdk.test.lib.Platform
31+
* @build jdk.test.lib.Platform
3232
* @run main bug8007006
3333
*/
3434

@@ -40,6 +40,7 @@
4040
public class bug8007006 {
4141
private static Frame frame1;
4242
private static Frame frame2;
43+
private static volatile boolean isActionPerformed;
4344

4445
public static void main(String[] args) throws Exception {
4546
if (!Platform.isOSX()) {
@@ -49,46 +50,19 @@ public static void main(String[] args) throws Exception {
4950

5051
System.setProperty("apple.laf.useScreenMenuBar", "true");
5152

52-
ExtendedRobot robot = new ExtendedRobot();
53-
robot.setAutoDelay(50);
53+
Robot robot = new Robot();
54+
robot.setAutoDelay(300);
5455

5556
createAndShowGUI();
56-
robot.waitForIdle(1500);
57-
57+
robot.waitForIdle();
5858
frame2.dispose();
59-
60-
robot.waitForIdle(1500);
61-
62-
63-
// open "Apple" menu (the leftmost one)
64-
robot.keyPress(KeyEvent.VK_META);
65-
robot.keyPress(KeyEvent.VK_SHIFT);
66-
robot.keyPress(KeyEvent.VK_SLASH);
67-
robot.keyRelease(KeyEvent.VK_SLASH);
68-
robot.keyRelease(KeyEvent.VK_SHIFT);
69-
robot.keyRelease(KeyEvent.VK_META);
70-
71-
// Select our menu
72-
robot.keyPress(KeyEvent.VK_LEFT);
73-
robot.keyRelease(KeyEvent.VK_LEFT);
74-
75-
// Select menu item
76-
robot.keyPress(KeyEvent.VK_DOWN);
77-
robot.keyRelease(KeyEvent.VK_DOWN);
78-
robot.keyPress(KeyEvent.VK_ENTER);
79-
robot.keyRelease(KeyEvent.VK_ENTER);
80-
8159
robot.waitForIdle();
8260

83-
MenuBar mbar = frame1.getMenuBar();
84-
Menu menu = mbar.getMenu(0);
85-
CheckboxMenuItem item = (CheckboxMenuItem)menu.getItem(0);
86-
boolean isChecked = item.getState();
61+
performMenuItemTest(robot);
8762

8863
frame1.dispose();
89-
90-
if (isChecked) {
91-
throw new Exception("Test failed: menu item remained checked");
64+
if (!isActionPerformed) {
65+
throw new Exception("Test failed: menu item action was not performed");
9266
}
9367
}
9468

@@ -106,14 +80,51 @@ private static void createAndShowGUI() {
10680
}
10781

10882
private static MenuBar createMenuBar() {
109-
MenuBar mbar = new MenuBar();
110-
Menu menu = new Menu("Menu");
111-
MenuItem item = new CheckboxMenuItem("Checked", true);
112-
83+
// A very long name makes it more likely that the robot will hit the
84+
// menu
85+
Menu menu = new Menu("TestTestTestTestTestTestTestTestTestTest");
86+
MenuItem item = new MenuItem("TestTestTestTestTestTestTestTestTestTest");
87+
item.addActionListener(new ActionListener() {
88+
@Override
89+
public void actionPerformed(ActionEvent ev) {
90+
isActionPerformed = true;
91+
}
92+
});
11393
menu.add(item);
114-
mbar.add(menu);
94+
MenuBar mb = new MenuBar();
95+
mb.add(menu);
96+
return mb;
97+
}
11598

116-
return mbar;
99+
private static void performMenuItemTest(Robot robot) {
100+
// Find the menu on the screen menu bar
101+
// The location depends upon the application name which is the name
102+
// of the first menu.
103+
// Unfortunately, the application name can vary based on how the
104+
// application is run.
105+
// The work around is to make the menu and the menu item names very
106+
// long.
107+
int menuBarX = 250;
108+
int menuBarY = 11;
109+
int menuItemX = menuBarX;
110+
int menuItemY = 34;
111+
robot.mouseMove(menuBarX, menuBarY);
112+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
113+
robot.mouseMove(menuItemX, menuItemY);
114+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
115+
robot.waitForIdle();
116+
waitForAction();
117117
}
118118

119+
private static void waitForAction() {
120+
try {
121+
for (int i = 0; i < 10; i++) {
122+
if (isActionPerformed) {
123+
return;
124+
}
125+
Thread.sleep(100);
126+
}
127+
} catch (InterruptedException ex) {
128+
}
129+
}
119130
}

test/jdk/javax/swing/JComboBox/4199622/bug4199622.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
@bug 4199622
2828
@requires (os.family == "windows")
2929
@summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation
30-
@author Vladislav Karnaukhov
3130
@library /test/lib
3231
@modules java.desktop/com.sun.java.swing.plaf.windows
33-
@build jdk.test.libr.Platform
32+
@build jdk.test.lib.Platform
3433
@run main bug4199622
3534
*/
3635

test/jdk/javax/swing/JFrame/NSTexturedJFrame/NSTexturedJFrame.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
* @test
3636
* @key headful
3737
* @bug 7124513
38+
* @requires (os.family == "mac")
3839
* @summary We should support NSTexturedBackgroundWindowMask style on OSX.
39-
* @author Sergey Bylokhov
4040
* @library /test/lib
41+
* /test/jdk/lib/testlibrary/
4142
* @build ExtendedRobot jdk.test.lib.Platform
4243
* @run main NSTexturedJFrame
4344
*/

test/jdk/javax/swing/JPopupMenu/7154841/bug7154841.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
* @test
2626
* @key headful
2727
* @bug 7154841
28+
* @requires (os.family == "mac")
2829
* @summary JPopupMenu is overlapped by a Dock on Mac OS X
29-
* @author Petr Pchelko
3030
* @library /test/lib
31+
* /test/jdk/lib/testlibrary/
3132
* @build ExtendedRobot jdk.test.lib.Platform
3233
* @run main bug7154841
3334
*/

0 commit comments

Comments
 (0)