提交 b02756b0 编写于 作者: M mcherkas

8015601: [macosx] Test...

8015601: [macosx] Test javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java fails on MacOS X
Reviewed-by: alexp, alexsch
上级 e630ffe8
...@@ -27,19 +27,19 @@ ...@@ -27,19 +27,19 @@
@author mcherkas @author mcherkas
@run main InternalFrameIsNotCollectedTest @run main InternalFrameIsNotCollectedTest
*/ */
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.util.Date; import java.util.Date;
public class InternalFrameIsNotCollectedTest { 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 Robot robot;
private static CustomInternalFrame iFrame;
public static void sync() { public static void sync() {
...@@ -62,12 +62,13 @@ public class InternalFrameIsNotCollectedTest { ...@@ -62,12 +62,13 @@ public class InternalFrameIsNotCollectedTest {
}); });
sync(); sync();
invokeGC(); invokeGC();
System.runFinalization();
Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later Thread.sleep(1000); // it's better to wait 1 sec now then 10 sec later
Date startWaiting = new Date(); Date startWaiting = new Date();
synchronized (CustomInternalFrame.waiter) { synchronized (CustomInternalFrame.waiter) {
// Sync with finalization thread. // Sync with finalization thread.
Date now = new Date(); Date now = new Date();
while (now.getTime() - startWaiting.getTime() < waitTime && !CustomInternalFrame.finalized) { while (now.getTime() - startWaiting.getTime() < maxWaitTime && !CustomInternalFrame.finalized) {
CustomInternalFrame.waiter.wait(waitTime); CustomInternalFrame.waiter.wait(waitTime);
now = new Date(); now = new Date();
} }
...@@ -83,10 +84,8 @@ public class InternalFrameIsNotCollectedTest { ...@@ -83,10 +84,8 @@ public class InternalFrameIsNotCollectedTest {
} }
private static void closeInternalFrame() throws PropertyVetoException { private static void closeInternalFrame() throws PropertyVetoException {
robot.keyPress(KeyEvent.VK_CONTROL); iFrame.setClosed(true);
robot.keyPress(KeyEvent.VK_F4); iFrame = null;
robot.keyRelease(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_CONTROL);
} }
private static void initUI() { private static void initUI() {
...@@ -96,7 +95,7 @@ public class InternalFrameIsNotCollectedTest { ...@@ -96,7 +95,7 @@ public class InternalFrameIsNotCollectedTest {
desktopPane.setDesktopManager(new DefaultDesktopManager()); desktopPane.setDesktopManager(new DefaultDesktopManager());
frame.getContentPane().add(desktopPane, BorderLayout.CENTER); frame.getContentPane().add(desktopPane, BorderLayout.CENTER);
CustomInternalFrame iFrame = new CustomInternalFrame("Dummy Frame"); iFrame = new CustomInternalFrame("Dummy Frame");
iFrame.setSize(200, 200); iFrame.setSize(200, 200);
iFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); iFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册