java/awt/Choice/PopupPosTest/PopupPosTest.java

Print this page

        

@@ -1,22 +1,29 @@
 /*
   test
   @bug 5044150
   @summary Tests that pupup doesn't popdown if no space to display under
   @author andrei.dmitriev area=awt.choice
+  @library ../../../../lib/testlibrary
+  @build jdk.testlibrary.OSInfo
   @run applet PopupPosTest.html
 */
 
 import java.applet.Applet;
 import java.awt.*;
 import java.awt.event.*;
-import sun.awt.SunToolkit;
+
+import jdk.testlibrary.OSInfo;
 
 public class PopupPosTest extends Applet
 {
     public void start ()
     {
+        if(OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
+            // On OS X, popup isn't under the mouse
+            return;
+        }
         Frame frame = new TestFrame();
     }
 }
 
 class TestFrame extends Frame implements ItemListener {

@@ -39,13 +46,14 @@
         add(choice, BorderLayout.CENTER);
         Dimension screen = tk.getScreenSize();
         setSize(screen.width - 10, screen.height - 70);
         setVisible(true);
         toFront();
-        ((SunToolkit)tk).realSync();
         try {
             robot = new Robot();
+            robot.setAutoDelay(50);
+            robot.waitForIdle();
             // fix for 6175418. When we take "choice.getHeight()/2"
             // divider 2 is not sufficiently big to hit into the
             // small box Choice. We should use bigger divider to get
             // smaller value choice.getHeight()/i. 4 is sufficient.
             Point pt = choice.getLocationOnScreen();

@@ -87,11 +95,11 @@
         openChoice();
         robot.mouseMove(x, y);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.delay(30);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        ((SunToolkit)tk).realSync();
+        robot.waitForIdle();
         //should close choice after each test stage
         closeChoice();
         checkSelectedIndex();
     }
 

@@ -100,16 +108,16 @@
         robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight()/4,
                         pt.y + choice.getHeight()/2);
         robot.mousePress(InputEvent.BUTTON1_MASK);
         robot.delay(30);
         robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        ((SunToolkit)tk).realSync();
+        robot.waitForIdle();
     }
     public void closeChoice(){
         robot.keyPress(KeyEvent.VK_ESCAPE);
         robot.keyRelease(KeyEvent.VK_ESCAPE);
-        ((SunToolkit)tk).realSync();
+        robot.waitForIdle();
     }
 
     public void checkSelectedIndex(){
         if (choice.getSelectedIndex() != INITIAL_ITEM) {
             System.out.println("choice.getSelectedIndex = "+ choice.getSelectedIndex());