changeset 55798:fe5395d16475

8214469: [macos] PIT: java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.java fails Reviewed-by: psadhukhan
author serb
date Tue, 18 Jun 2019 21:40:50 -0700
parents 2db64810f4fc
children f72de31c98cd
files test/jdk/ProblemList.txt test/jdk/java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.java
diffstat 2 files changed, 24 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/ProblemList.txt	Sun Jun 09 18:14:48 2019 -0700
+++ b/test/jdk/ProblemList.txt	Tue Jun 18 21:40:50 2019 -0700
@@ -186,7 +186,7 @@
 java/awt/Mixing/AWT_Mixing/JTextFieldInGlassPaneOverlapping.java 8158801 windows-all
 java/awt/Mixing/AWT_Mixing/JTextFieldOverlapping.java 8158801 windows-all
 java/awt/Mixing/AWT_Mixing/JToggleButtonInGlassPaneOverlapping.java 8158801 windows-all
-java/awt/Mixing/AWT_Mixing/JToggleButtonOverlapping.java 8158801 windows-all	
+java/awt/Mixing/AWT_Mixing/JToggleButtonOverlapping.java 8158801 windows-all
 java/awt/Mixing/NonOpaqueInternalFrame.java 7124549 macosx-all
 java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java 6829264 generic-all
 java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java 8080982 generic-all
@@ -284,7 +284,6 @@
 java/awt/PrintJob/PrinterException.java 8196301 windows-all,macosx-all
 java/awt/Choice/PopupPosTest/PopupPosTest.java  8197811 windows-all
 java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java 7100044 macosx-all,linux-all
-java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.java 8214469 macosx-all
 java/awt/Component/CreateImage/CreateImage.java 8198334  windows-all
 java/awt/Component/GetScreenLocTest/GetScreenLocTest.java 4753654 generic-all
 java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java 8165863 macosx-all
--- a/test/jdk/java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.java	Sun Jun 09 18:14:48 2019 -0700
+++ b/test/jdk/java/awt/Choice/ChoiceKeyEventReaction/ChoiceKeyEventReaction.java	Tue Jun 18 21:40:50 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -30,18 +30,18 @@
  * @run main ChoiceKeyEventReaction
  */
 
+import java.awt.Choice;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Point;
 import java.awt.Robot;
-import java.awt.Choice;
-import java.awt.Point;
+import java.awt.TextField;
 import java.awt.Toolkit;
-import java.awt.TextField;
-import java.awt.FlowLayout;
 import java.awt.event.InputEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.KeyAdapter;
-import java.awt.event.ItemListener;
-import java.awt.Frame;
 
 public class ChoiceKeyEventReaction
 {
@@ -60,6 +60,7 @@
         try {
             robot = new Robot();
             robot.setAutoDelay(100);
+            robot.waitForIdle();
 
             moveFocusToTextField();
             testKeyOnChoice(InputEvent.BUTTON1_MASK, KeyEvent.VK_UP);
@@ -99,6 +100,7 @@
         frame.add(choice1);
         frame.setLayout (new FlowLayout());
         frame.setSize (200,200);
+        frame.setLocationRelativeTo(null);
         frame.setVisible(true);
     }
 
@@ -108,33 +110,31 @@
 
         robot.mousePress(button);
         robot.mouseRelease(button);
+        robot.waitForIdle();
 
         robot.keyPress(key);
         robot.keyRelease(key);
+        robot.waitForIdle();
 
         System.out.println("keyTypedOnTextField = "+keyTypedOnTextField +": itemChanged = " + itemChanged);
         if (itemChanged) {
             throw new RuntimeException("Test failed. ItemChanged event occur on Choice.");
         }
 
-       // We may just write
-       // if (toolkit.equals("sun.awt.windows.WToolkit") == keyTypedOnTextField) {fail;}
-       // but  must report differently in these cases so put two separate if statements for simplicity.
-       if (toolkit.equals("sun.awt.windows.WToolkit") &&
-           !keyTypedOnTextField) {
-           throw new RuntimeException("Test failed. (Win32) KeyEvent wasn't addressed to TextField. ");
-       }
+        // We may just write
+        // if (toolkit.equals("sun.awt.windows.WToolkit") == keyTypedOnTextField) {fail;}
+        // but  must report differently in these cases so put two separate if statements for simplicity.
+        if (!toolkit.equals("sun.awt.X11.XToolkit") &&
+               !keyTypedOnTextField) {
+           throw new RuntimeException("Test failed. (Win32/MacOS) KeyEvent wasn't addressed to TextField. ");
+        }
 
-       if (!toolkit.equals("sun.awt.windows.WToolkit") &&
-          keyTypedOnTextField) {
-           throw new RuntimeException("Test failed. (XToolkit/MToolkit). KeyEvent was addressed to TextField.");
+        if (toolkit.equals("sun.awt.X11.XToolkit") &&
+                keyTypedOnTextField) {
+            throw new RuntimeException("Test failed. (XToolkit/MToolkit). KeyEvent was addressed to TextField.");
         }
 
         System.out.println("Test passed. Unfocusable Choice doesn't react on keys.");
-
-        //close opened choice
-        robot.keyPress(KeyEvent.VK_ESCAPE);
-        robot.keyRelease(KeyEvent.VK_ESCAPE);
     }
 
     public static void moveFocusToTextField() {