8015601: [macosx] Test javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java fails on MacOS X
authormcherkas
Fri, 13 Sep 2013 17:48:37 +0400
changeset 20131 59be23579a61
parent 20130 5e4ae22bef47
child 20132 398fd7b83690
8015601: [macosx] Test javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java fails on MacOS X Reviewed-by: alexp, alexsch
jdk/test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java
--- a/jdk/test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java	Fri Sep 13 17:41:47 2013 +0400
+++ b/jdk/test/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java	Fri Sep 13 17:48:37 2013 +0400
@@ -27,19 +27,19 @@
     @author mcherkas
     @run main InternalFrameIsNotCollectedTest
  */
-
 import sun.awt.SunToolkit;
 
 import javax.swing.*;
 import java.awt.*;
-import java.awt.event.KeyEvent;
 import java.beans.PropertyVetoException;
 import java.util.Date;
 
 public class InternalFrameIsNotCollectedTest {
 
-    public static final int waitTime = 10000;
+    public static final int maxWaitTime = 100000;
+    public static final int waitTime = 5000;
     private static Robot robot;
+    private static CustomInternalFrame iFrame;
 
     public static void sync() {
 
@@ -62,12 +62,13 @@
         });
         sync();
         invokeGC();
+        System.runFinalization();
         Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later
         Date startWaiting = new Date();
         synchronized (CustomInternalFrame.waiter) {
             // Sync with finalization thread.
             Date now = new Date();
-            while (now.getTime() - startWaiting.getTime() < waitTime && !CustomInternalFrame.finalized) {
+            while (now.getTime() - startWaiting.getTime() < maxWaitTime && !CustomInternalFrame.finalized) {
                 CustomInternalFrame.waiter.wait(waitTime);
                 now = new Date();
             }
@@ -83,10 +84,8 @@
     }
 
     private static void closeInternalFrame() throws PropertyVetoException {
-        robot.keyPress(KeyEvent.VK_CONTROL);
-        robot.keyPress(KeyEvent.VK_F4);
-        robot.keyRelease(KeyEvent.VK_F4);
-        robot.keyRelease(KeyEvent.VK_CONTROL);
+        iFrame.setClosed(true);
+        iFrame = null;
     }
 
     private static void initUI() {
@@ -96,7 +95,7 @@
         desktopPane.setDesktopManager(new DefaultDesktopManager());
         frame.getContentPane().add(desktopPane, BorderLayout.CENTER);
 
-        CustomInternalFrame iFrame = new CustomInternalFrame("Dummy Frame");
+        iFrame = new CustomInternalFrame("Dummy Frame");
 
         iFrame.setSize(200, 200);
         iFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);