changeset 55859:ef91ba2e6cff

8196096: javax/swing/JPopupMenu/6580930/bug6580930.java fails Reviewed-by: serb
author ssadetsky
date Mon, 03 Jun 2019 08:13:18 -0700
parents 4cfbcfac47aa
children 72bdfcf4cfb5
files test/jdk/ProblemList.txt test/jdk/javax/swing/JPopupMenu/6580930/bug6580930.java
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/ProblemList.txt	Mon Jun 03 11:56:48 2019 +0530
+++ b/test/jdk/ProblemList.txt	Mon Jun 03 08:13:18 2019 -0700
@@ -735,7 +735,7 @@
 javax/swing/JFileChooser/6396844/TwentyThousandTest.java 8198003 generic-all
 javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java 8193942 generic-all
 javax/swing/JList/6462008/bug6462008.java 7156347 generic-all
-javax/swing/JPopupMenu/6580930/bug6580930.java 8196096 windows-all,macosx-all
+javax/swing/JPopupMenu/6580930/bug6580930.java 7124313 macosx-all
 javax/swing/JPopupMenu/6800513/bug6800513.java 7184956 macosx-all
 javax/swing/JPopupMenu/6675802/bug6675802.java 8196097 windows-all
 javax/swing/JTabbedPane/8007563/Test8007563.java 8051591 generic-all
--- a/test/jdk/javax/swing/JPopupMenu/6580930/bug6580930.java	Mon Jun 03 11:56:48 2019 +0530
+++ b/test/jdk/javax/swing/JPopupMenu/6580930/bug6580930.java	Mon Jun 03 08:13:18 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2019, 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
@@ -42,6 +42,8 @@
     private static JPopupMenu popup;
     private static Toolkit toolkit;
     private static volatile boolean skipTest = false;
+    private static Point loc;
+    private static int y;
 
     private static void createGui() {
         frame = new JFrame();
@@ -93,12 +95,15 @@
         if(skipTest) {
             return;
         }
-        Point loc = frame.getLocationOnScreen();
+
+        SwingUtilities.invokeAndWait(() -> loc = frame.getLocationOnScreen());
+        robot.waitForIdle();
 
         robot.mouseMove(loc.x, loc.y);
         showPopup();
         robot.waitForIdle();
-        if (isHeavyWeightMenuVisible()) {
+        if (!System.getProperty("os.name").startsWith("Mac")
+            && isHeavyWeightMenuVisible()) {
             throw new RuntimeException("HeavyWeightPopup is unexpectedly visible");
         }
 
@@ -106,12 +111,16 @@
         robot.keyRelease(KeyEvent.VK_ESCAPE);
 
         int x = loc.x;
-        int y = loc.y + (frame.getHeight() - popup.getPreferredSize().height) + 1;
+        SwingUtilities.invokeAndWait( () -> y = loc.y + (frame.getHeight() -
+                popup.getPreferredSize().height) + 1);
+        robot.waitForIdle();
         robot.mouseMove(x, y);
 
         showPopup();
+        SwingUtilities.invokeAndWait(() -> loc = popup.getLocationOnScreen());
+        robot.waitForIdle();
 
-        if (!popup.getLocationOnScreen().equals(new Point(x, y))) {
+        if (!loc.equals(new Point(x, y))) {
             throw new RuntimeException("Popup is unexpectedly shifted");
         }