8081454: [TESTBUG]Some java/awt/Mixing tests fail in OEL 7 only
authorssadetsky
Thu, 20 Apr 2017 08:38:15 -0700
changeset 44776 5fcc7728c117
parent 44775 f9c5f5f38a6a
child 44777 de8620413050
8081454: [TESTBUG]Some java/awt/Mixing tests fail in OEL 7 only Reviewed-by: yan
jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java
jdk/test/java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java
jdk/test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java
jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java	Thu Apr 20 08:23:10 2017 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java	Thu Apr 20 08:38:15 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017 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
@@ -128,7 +128,7 @@
                tests fail starting after failing mixing tests but always pass alone.
              */
             Util.waitForIdle(robot);
-            ancestorLoc.translate(f.getWidth()/2-15, 2);
+            ancestorLoc.translate(isOel7() ? 5 : f.getWidth() / 2 - 15, 2);
             robot.mouseMove(ancestorLoc.x, ancestorLoc.y);
             Util.waitForIdle(robot);
             robot.mousePress(InputEvent.BUTTON1_MASK);
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java	Thu Apr 20 08:23:10 2017 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/HierarchyBoundsListenerMixingTest.java	Thu Apr 20 08:38:15 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -85,7 +85,7 @@
             components[i].addHierarchyBoundsListener(listener);
             frame.add(components[i]);
         }
-        frame.setSize(300, 300);
+        frame.setBounds(100, 100, 300, 300);
         frame.setVisible(true);
     }
 
@@ -391,8 +391,8 @@
     private int resizeCount = 0;
 
     private boolean passed = true;
-    private boolean moveTriggered = false;
-    private boolean resizeTriggered = false;
+    private volatile boolean moveTriggered = false;
+    private volatile boolean resizeTriggered = false;
     private final Object moveLock = new Object();
     private final Object resizeLock = new Object();
 
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java	Thu Apr 20 08:23:10 2017 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/JComboBoxOverlapping.java	Thu Apr 20 08:38:15 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -21,7 +21,6 @@
  * questions.
  */
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Point;
 import java.awt.Robot;
@@ -30,6 +29,7 @@
 import javax.swing.BoxLayout;
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
 import test.java.awt.regtesthelpers.Util;
 
 
@@ -55,16 +55,18 @@
     private boolean lwClicked = false;
     private Point loc;
     private Point loc2;
+    private JComboBox cb;
+    private JFrame frame;
 
     {testEmbeddedFrame = true;}
 
     protected void prepareControls() {
-        final JFrame frame = new JFrame("Mixing : Dropdown Overlapping test");
+        frame = new JFrame("Mixing : Dropdown Overlapping test");
         frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
         frame.setSize(200, 200);
         frame.setVisible(true);
 
-        final JComboBox cb = new JComboBox(petStrings);
+        cb = new JComboBox(petStrings);
         cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));
         cb.addActionListener(new ActionListener() {
 
@@ -78,8 +80,6 @@
         frame.add(cb);
         propagateAWTControls(frame);
         frame.setVisible(true);
-        loc = cb.getLocationOnScreen();
-        loc2 = frame.getContentPane().getLocationOnScreen();
     }
 
     @Override
@@ -87,6 +87,16 @@
         // run robot
         Robot robot = Util.createRobot();
         robot.setAutoDelay(ROBOT_DELAY);
+        robot.waitForIdle();
+        robot.delay(200);
+        try {
+            SwingUtilities.invokeAndWait(() -> {
+                loc = cb.getLocationOnScreen();
+                loc2 = frame.getContentPane().getLocationOnScreen();
+            });
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
 
         loc2.translate(75, 75);
         pixelPreCheck(robot, loc2, currentAwtControl);
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Thu Apr 20 08:23:10 2017 -0700
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Thu Apr 20 08:38:15 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017 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
@@ -142,7 +142,8 @@
         JFrame ancestor = (JFrame)(testedComponent.getTopLevelAncestor());
         if( ancestor != null ) {
             Point ancestorLoc = ancestor.getLocationOnScreen();
-            ancestorLoc.translate(ancestor.getWidth()/2-15, 2);
+            ancestorLoc.translate(isOel7() ? 5 :
+                                             ancestor.getWidth() / 2 - 15, 2);
             robot.mouseMove(ancestorLoc.x, ancestorLoc.y);
             Util.waitForIdle(robot);
             robot.mousePress(InputEvent.BUTTON1_MASK);
@@ -157,5 +158,11 @@
         return wasLWClicked;
     }
 
+    public boolean isOel7() {
+        return System.getProperty("os.name").toLowerCase()
+                .contains("linux") && System.getProperty("os.version")
+                .toLowerCase().contains("el7");
+    }
+
 }