8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1
Reviewed-by: pchelko, serb
--- a/jdk/test/com/sun/awt/Translucency/WindowOpacity.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/com/sun/awt/Translucency/WindowOpacity.java Mon Nov 10 16:23:30 2014 +0300
@@ -33,15 +33,12 @@
import java.awt.event.*;
import com.sun.awt.AWTUtilities;
-import sun.awt.SunToolkit;
public class WindowOpacity
{
//*** test-writer defined static variables go here ***
- private static void realSync() {
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
- }
+ private static Robot robot;
private static void init()
@@ -60,6 +57,12 @@
System.out.println("Either the Toolkit or the native system does not support controlling the window opacity level.");
pass();
}
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException ("Unexpected failure");
+ }
boolean passed;
@@ -137,7 +140,7 @@
f.setBounds(100, 100, 300, 200);
f.setVisible(true);
- realSync();
+ robot.waitForIdle();
curOpacity = AWTUtilities.getWindowOpacity(f);
if (curOpacity < 0.75f || curOpacity > 0.75f) {
@@ -147,7 +150,7 @@
AWTUtilities.setWindowOpacity(f, 0.5f);
- realSync();
+ robot.waitForIdle();
curOpacity = AWTUtilities.getWindowOpacity(f);
if (curOpacity < 0.5f || curOpacity > 0.5f) {
--- a/jdk/test/java/awt/Component/NoUpdateUponShow/NoUpdateUponShow.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Component/NoUpdateUponShow/NoUpdateUponShow.java Mon Nov 10 16:23:30 2014 +0300
@@ -36,7 +36,6 @@
*/
import java.awt.*;
-import sun.awt.SunToolkit;
public class NoUpdateUponShow
{
@@ -70,7 +69,13 @@
});
f.setVisible(true);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
if (wasUpdate) {
fail(" Unexpected update. ");
--- a/jdk/test/java/awt/Component/PaintAll/PaintAll.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Component/PaintAll/PaintAll.java Mon Nov 10 16:23:30 2014 +0300
@@ -21,8 +21,6 @@
* questions.
*/
-import sun.awt.SunToolkit;
-
import java.awt.Button;
import java.awt.Canvas;
import java.awt.Checkbox;
@@ -48,6 +46,8 @@
@bug 6596915
@summary Test Component.paintAll() method
@author sergey.bylokhov@oracle.com: area=awt.component
+ @library ../../../../lib/testlibrary/
+ @build ExtendedRobot
@run main PaintAll
*/
public class PaintAll {
@@ -66,6 +66,7 @@
private static volatile boolean scrollPanePainted;
private static volatile boolean textAreaPainted;
private static volatile boolean textFieldPainted;
+ private static ExtendedRobot robot = null;
private static final Button buttonStub = new Button() {
@Override
@@ -283,11 +284,15 @@
}
private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
- try {
- Thread.sleep(500L);
- } catch (InterruptedException ignored) {
+ if(robot == null) {
+ try {
+ robot = new ExtendedRobot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
}
+ robot.waitForIdle(500);
}
private static void fail(final String message) {
--- a/jdk/test/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Focus/ModalBlockedStealsFocusTest/ModalBlockedStealsFocusTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -34,11 +34,9 @@
import java.applet.Applet;
import java.util.concurrent.atomic.AtomicBoolean;
import java.lang.reflect.InvocationTargetException;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
public class ModalBlockedStealsFocusTest extends Applet {
- SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
Frame frame = new Frame("Blocked Frame");
Dialog dialog = new Dialog(frame, "Modal Dialog", Dialog.ModalityType.TOOLKIT_MODAL);
AtomicBoolean lostFocus = new AtomicBoolean(false);
@@ -85,7 +83,13 @@
}).start();
Util.waitTillShown(dialog);
- toolkit.realSync();
+ try {
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
// Test 1. Show a modal blocked frame, check that it doesn't steal focus.
--- a/jdk/test/java/awt/Focus/WindowInitialFocusTest/WindowInitialFocusTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Focus/WindowInitialFocusTest/WindowInitialFocusTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -33,7 +33,6 @@
import java.awt.event.*;
import java.applet.Applet;
import java.util.concurrent.atomic.AtomicBoolean;
-import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
public class WindowInitialFocusTest extends Applet {
@@ -41,7 +40,7 @@
Window window = new Window(frame);
Button button = new Button("button");
AtomicBoolean focused = new AtomicBoolean(false);
- SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
+ Robot robot;
public static void main(String[] args) {
WindowInitialFocusTest app = new WindowInitialFocusTest();
@@ -75,12 +74,18 @@
}});
frame.setVisible(true);
- toolkit.realSync();
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
+ robot.waitForIdle();
// Test 1. Show the window, check that it become focused.
window.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
if (!Util.waitForCondition(focused, 2000L)) {
throw new TestFailedException("the window didn't get focused on its showing!");
@@ -89,13 +94,13 @@
// Test 2. Show unfocusable window, check that it doesn't become focused.
window.setVisible(false);
- toolkit.realSync();
+ robot.waitForIdle();
window.setFocusableWindowState(false);
focused.set(false);
window.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
if (Util.waitForCondition(focused, 2000L)) {
throw new TestFailedException("the unfocusable window got focused on its showing!");
--- a/jdk/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -30,11 +30,8 @@
import java.awt.*;
-import sun.awt.SunToolkit;
-
public class ExceptionOnSetExtendedStateTest {
private static final int[] frameStates = { Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_BOTH };
- private static final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit();
private static boolean validatePlatform() {
String osName = System.getProperty("os.name");
@@ -53,7 +50,13 @@
frame.setSize(200, 200);
frame.setUndecorated(!decoratedFrame);
frame.setVisible(true);
- toolkit.realSync();
+ try {
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
frame.setExtendedState(oldState);
sleep(1000);
--- a/jdk/test/java/awt/Frame/FrameSize/TestFrameSize.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Frame/FrameSize/TestFrameSize.java Mon Nov 10 16:23:30 2014 +0300
@@ -77,7 +77,13 @@
mainWindow.setVisible(true);
- ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure.");
+ }
Dimension clientSize2 = getClientSize(mainWindow);
System.out.println("Client size after showing: " + clientSize2);
--- a/jdk/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Frame/MaximizedByPlatform/MaximizedByPlatform.java Mon Nov 10 16:23:30 2014 +0300
@@ -25,11 +25,12 @@
* @bug 8026143
* @summary [macosx] Maximized state could be inconsistent between peer and frame
* @author Petr Pchelko
+ * @library ../../../../lib/testlibrary
+ * @build jdk.testlibrary.OSInfo
* @run main MaximizedByPlatform
*/
-import sun.awt.OSInfo;
-import sun.awt.SunToolkit;
+import jdk.testlibrary.OSInfo;
import java.awt.*;
@@ -43,6 +44,13 @@
return;
}
+ Robot robot;
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
availableScreenBounds = getAvailableScreenBounds();
// Test 1. The maximized state is set in setBounds
@@ -51,12 +59,12 @@
frame.setBounds(100, 100, 100, 100);
frame.setVisible(true);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
availableScreenBounds.width, availableScreenBounds.height);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
throw new RuntimeException("Maximized state was not set for frame in setBounds");
@@ -73,7 +81,7 @@
availableScreenBounds.width + 100, availableScreenBounds.height);
frame.setVisible(true);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
if (frame.getExtendedState() != Frame.MAXIMIZED_BOTH) {
throw new RuntimeException("Maximized state was not set for frame in setVisible");
--- a/jdk/test/java/awt/Frame/MaximizedToMaximized/MaximizedToMaximized.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Frame/MaximizedToMaximized/MaximizedToMaximized.java Mon Nov 10 16:23:30 2014 +0300
@@ -28,7 +28,7 @@
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
-import sun.awt.SunToolkit;
+import java.awt.Robot;
/**
* @test
@@ -65,7 +65,8 @@
Rectangle frameBounds = frame.getBounds();
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
- ((SunToolkit) toolkit).realSync();
+ Robot robot = new Robot();
+ robot.waitForIdle();
Rectangle maximizedFrameBounds = frame.getBounds();
if (maximizedFrameBounds.width < frameBounds.width
--- a/jdk/test/java/awt/Frame/SlideNotResizableTest/SlideNotResizableTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Frame/SlideNotResizableTest/SlideNotResizableTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -21,8 +21,6 @@
* questions.
*/
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.Dimension;
import java.awt.Point;
@@ -62,8 +60,9 @@
}
}
- private static void sync() throws InterruptedException {
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ private static void sync() throws Exception {
+ Robot robot = new Robot();
+ robot.waitForIdle();
Thread.sleep(1000);
}
}
--- a/jdk/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java Mon Nov 10 16:23:30 2014 +0300
@@ -34,10 +34,17 @@
import static java.awt.GraphicsDevice.WindowTranslucency.*;
-import sun.awt.SunToolkit;
public class TranslucentWindow {
public static void main(String args[]) {
+ Robot robot;
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
+
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
@@ -47,10 +54,10 @@
// First, check it can be made fullscreen window without any effects applied
gd.setFullScreenWindow(f);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
gd.setFullScreenWindow(null);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
// Second, check if it applying any effects doesn't prevent the window
// from going into the fullscreen mode
@@ -64,7 +71,7 @@
f.setBackground(new Color(0, 0, 0, 128));
}
gd.setFullScreenWindow(f);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
// Third, make sure all the effects are unset when entering the fullscreen mode
if (f.getShape() != null) {
--- a/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/GraphicsDevice/IncorrectDisplayModeExitFullscreen.java Mon Nov 10 16:23:30 2014 +0300
@@ -27,16 +27,17 @@
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
-import java.awt.Toolkit;
-
-import sun.awt.SunToolkit;
/**
* @test
* @bug 8019587
* @author Sergey Bylokhov
+ * @library ../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main IncorrectDisplayModeExitFullscreen
*/
public class IncorrectDisplayModeExitFullscreen {
+ static ExtendedRobot robot;
public static void main(final String[] args) {
@@ -64,6 +65,13 @@
return;
}
+ try {
+ robot = new ExtendedRobot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
+
final Frame frame = new Frame();
frame.setBackground(Color.GREEN);
frame.setUndecorated(true);
@@ -85,10 +93,6 @@
}
}
private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
- try {
- Thread.sleep(1500);
- } catch (InterruptedException ignored) {
- }
+ robot.waitForIdle(1500);
}
}
--- a/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -71,7 +71,14 @@
frame.pack();
frame.setVisible(true);
- ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ Robot robot;
+ try {
+ robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
Dimension minSize = jtf.getMinimumSize();
if ( minSize.width + customIpadx != jtf.getSize().width ||
--- a/jdk/test/java/awt/List/ListPeer/R2303044ListSelection.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/List/ListPeer/R2303044ListSelection.java Mon Nov 10 16:23:30 2014 +0300
@@ -21,12 +21,10 @@
* questions.
*/
-import sun.awt.SunToolkit;
-
import java.awt.Frame;
import java.awt.HeadlessException;
import java.awt.List;
-import java.awt.Toolkit;
+import java.awt.Robot;
/**
* @test
@@ -57,9 +55,11 @@
private static void sleep() {
try {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ Robot robot = new Robot();
+ robot.waitForIdle();
Thread.sleep(1000);
- } catch (final InterruptedException ignored) {
+ } catch (final Exception ignored) {
+ ignored.printStackTrace();
}
}
}
--- a/jdk/test/java/awt/List/SingleModeDeselect/SingleModeDeselect.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/List/SingleModeDeselect/SingleModeDeselect.java Mon Nov 10 16:23:30 2014 +0300
@@ -30,7 +30,6 @@
*/
import java.awt.*;
-import sun.awt.SunToolkit;
public class SingleModeDeselect
{
@@ -50,7 +49,13 @@
list.select(0);
list.deselect(1);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Robot robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
if (list.getSelectedIndex() != 0){
throw new RuntimeException("Test failed: List.getSelectedIndex() returns "+list.getSelectedIndex());
--- a/jdk/test/java/awt/Paint/ExposeOnEDT.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Paint/ExposeOnEDT.java Mon Nov 10 16:23:30 2014 +0300
@@ -22,18 +22,19 @@
*/
-import sun.awt.SunToolkit;
-
import java.awt.*;
/**
* @test
* @bug 7090424
* @author Sergey Bylokhov
+ * @library ../../../lib/testlibrary/
+ * @build ExtendedRobot
* @run main ExposeOnEDT
*/
public final class ExposeOnEDT {
+ private static ExtendedRobot robot = null;
private static final Button buttonStub = new Button() {
@Override
public void paint(final Graphics g) {
@@ -275,11 +276,15 @@
}
private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
- try {
- Thread.sleep(1000L);
- } catch (InterruptedException ignored) {
+ if(robot == null) {
+ try {
+ robot = new ExtendedRobot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
}
+ robot.waitForIdle(1000);
}
private static void fail(final String message) {
--- a/jdk/test/java/awt/ScrollPane/ScrollPanePreferredSize/ScrollPanePreferredSize.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/ScrollPane/ScrollPanePreferredSize/ScrollPanePreferredSize.java Mon Nov 10 16:23:30 2014 +0300
@@ -26,12 +26,13 @@
import java.awt.ScrollPane;
import java.awt.Toolkit;
-import sun.awt.SunToolkit;
-
/**
* @test
* @bug 7124213
* @author Sergey Bylokhov
+ * @library ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @run main ScrollPanePreferredSize
*/
public final class ScrollPanePreferredSize {
@@ -54,10 +55,12 @@
}
private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
try {
- Thread.sleep(500L);
- } catch (InterruptedException ignored) {
+ ExtendedRobot robot = new ExtendedRobot();
+ robot.waitForIdle(500);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
}
}
}
--- a/jdk/test/java/awt/TextArea/DisposeTest/TestDispose.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/TextArea/DisposeTest/TestDispose.java Mon Nov 10 16:23:30 2014 +0300
@@ -35,14 +35,12 @@
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextArea;
-import java.awt.Toolkit;
+import java.awt.Robot;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
-
public class TestDispose {
public static Frame frame = null;
@@ -51,7 +49,14 @@
public void testDispose() throws InvocationTargetException,
InterruptedException {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot;
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
+
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -69,7 +74,7 @@
frame.setVisible(true);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -77,7 +82,7 @@
frame.dispose();
}
});
- toolkit.realSync();
+ robot.waitForIdle();
}
public static void main(String[] args) throws Exception{
--- a/jdk/test/java/awt/TextArea/TextAreaCaretVisibilityTest/bug7129742.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/TextArea/TextAreaCaretVisibilityTest/bug7129742.java Mon Nov 10 16:23:30 2014 +0300
@@ -34,7 +34,7 @@
import java.awt.FlowLayout;
import java.awt.TextArea;
-import java.awt.Toolkit;
+import java.awt.Robot;
import java.lang.reflect.Field;
import javax.swing.JFrame;
@@ -42,7 +42,6 @@
import javax.swing.SwingUtilities;
import javax.swing.text.DefaultCaret;
-import sun.awt.SunToolkit;
public class bug7129742 {
@@ -51,7 +50,7 @@
public static boolean fastreturn = false;
public static void main(String[] args) throws Exception {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot = new Robot();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -88,7 +87,7 @@
}
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
--- a/jdk/test/java/awt/TextArea/TextAreaTwicePack/TextAreaTwicePack.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/TextArea/TextAreaTwicePack/TextAreaTwicePack.java Mon Nov 10 16:23:30 2014 +0300
@@ -24,9 +24,8 @@
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.TextArea;
-import java.awt.Toolkit;
+import java.awt.Robot;
-import sun.awt.SunToolkit;
/**
* @test
@@ -55,10 +54,12 @@
}
private static void sleep() {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
try {
+ Robot robot = new Robot();
+ robot.waitForIdle();
Thread.sleep(500L);
- } catch (InterruptedException ignored) {
+ } catch (Exception ignored) {
+ ignored.printStackTrace();
}
}
}
--- a/jdk/test/java/awt/TextField/DisposeTest/TestDispose.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/TextField/DisposeTest/TestDispose.java Mon Nov 10 16:23:30 2014 +0300
@@ -35,14 +35,12 @@
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextField;
-import java.awt.Toolkit;
+import java.awt.Robot;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
-
public class TestDispose {
public static Frame frame = null;
@@ -51,7 +49,13 @@
public void testDispose() throws InvocationTargetException,
InterruptedException {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot;
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -69,7 +73,7 @@
frame.setVisible(true);
}
});
- toolkit.realSync();
+ robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -77,7 +81,7 @@
frame.dispose();
}
});
- toolkit.realSync();
+ robot.waitForIdle();
}
--- a/jdk/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/TrayIcon/PopupMenuLeakTest/PopupMenuLeakTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -26,12 +26,13 @@
@bug 8007220
@summary Reference to the popup leaks after the TrayIcon is removed
@author Petr Pchelko
+ @library ../../../../lib/testlibrary/
+ @build ExtendedRobot
@run main/othervm -Xmx50m PopupMenuLeakTest
*/
import java.awt.*;
import javax.swing.SwingUtilities;
-import sun.awt.SunToolkit;
import java.awt.image.BufferedImage;
import java.lang.ref.WeakReference;
@@ -42,8 +43,10 @@
static final AtomicReference<WeakReference<TrayIcon>> iconWeakReference = new AtomicReference<>();
static final AtomicReference<WeakReference<PopupMenu>> popupWeakReference = new AtomicReference<>();
+ static ExtendedRobot robot;
public static void main(String[] args) throws Exception {
+ robot = new ExtendedRobot();
SwingUtilities.invokeAndWait(PopupMenuLeakTest::createSystemTrayIcon);
sleep();
// To make the test automatic we explicitly call addNotify on a popup to create the peer
@@ -141,9 +144,6 @@
}
private static void sleep() {
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
- try {
- Thread.sleep(100);
- } catch (InterruptedException ignored) { }
+ robot.waitForIdle(100);
}
}
--- a/jdk/test/java/awt/Window/8027025/Test8027025.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Window/8027025/Test8027025.java Mon Nov 10 16:23:30 2014 +0300
@@ -28,8 +28,6 @@
* @run main Test8027025
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.util.concurrent.atomic.AtomicReference;
@@ -49,7 +47,8 @@
window.setVisible(true);
});
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ Robot robot = new Robot();
+ robot.waitForIdle();
AtomicReference<Point> point = new AtomicReference<>();
SwingUtilities.invokeAndWait(() -> point.set(window.getLocationOnScreen()));
--- a/jdk/test/java/awt/Window/AlwaysOnTop/AlwaysOnTopFieldTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Window/AlwaysOnTop/AlwaysOnTopFieldTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -22,9 +22,8 @@
*/
import java.awt.Dialog;
import java.awt.Frame;
-import java.awt.Toolkit;
+import java.awt.Robot;
import java.awt.Window;
-import sun.awt.SunToolkit;
/**
* @test
* @bug 7081594
@@ -35,19 +34,25 @@
public class AlwaysOnTopFieldTest {
public static void main(String[] args) {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+ Robot robot;
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
Window window = new Frame("Window 1");
window.setSize(200, 200);
window.setAlwaysOnTop(true);
window.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
Dialog dialog = new Dialog(window, "Owned dialog 1");
dialog.setSize(200, 200);
dialog.setLocation(100, 100);
dialog.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
try {
if (!window.isAlwaysOnTop()) {
@@ -64,17 +69,17 @@
window = new Frame("Window 2");
window.setSize(200, 200);
window.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
dialog = new Dialog(window, "Owned dialog 2");
dialog.setSize(200, 200);
dialog.setLocation(100, 100);
dialog.setVisible(true);
- toolkit.realSync();
+ robot.waitForIdle();
window.setAlwaysOnTop(true);
- toolkit.realSync();
+ robot.waitForIdle();
try {
if (!window.isAlwaysOnTop()) {
--- a/jdk/test/java/awt/Window/OwnedWindowsSerialization/OwnedWindowsSerialization.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/Window/OwnedWindowsSerialization/OwnedWindowsSerialization.java Mon Nov 10 16:23:30 2014 +0300
@@ -21,8 +21,6 @@
* questions.
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.io.ByteArrayInputStream;
@@ -54,7 +52,8 @@
subDialog = new Dialog(dialog, SUBDIALOG_LABEL);
});
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ Robot robot = new Robot();
+ robot.waitForIdle();
if (!topFrame.isAlwaysOnTop() || !dialog.isAlwaysOnTop() || !subDialog.isAlwaysOnTop()) {
throw new RuntimeException("TEST FAILED: AlwaysOnTop was not set properly");
--- a/jdk/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -30,7 +30,6 @@
*/
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
public class TextEventSequenceTest {
@@ -48,43 +47,50 @@
}
private static void test(String test) {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ Robot robot;
+ try {
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Unexpected failure");
+ }
createAndShowGUI(test);
- toolkit.realSync();
+ robot.waitForIdle();
initCounts();
t.setText("Hello ");
- toolkit.realSync();
+ robot.waitForIdle();
t.append("World! !");
- toolkit.realSync();
+ robot.waitForIdle();
t.insert("from Roger Pham", 13);
- toolkit.realSync();
+ robot.waitForIdle();
t.replaceRange("Java Duke", 18, 28);
- toolkit.realSync();
+ robot.waitForIdle();
checkCounts(0, 4);
initCounts();
t.setText("");
- toolkit.realSync();
+ robot.waitForIdle();
t.setText("");
- toolkit.realSync();
+ robot.waitForIdle();
t.setText("");
- toolkit.realSync();
+ robot.waitForIdle();
checkCounts(1, 0);
initCounts();
tf.setText("Hello There!");
- toolkit.realSync();
+ robot.waitForIdle();
checkCounts(0, 1);
initCounts();
tf.setText("");
- toolkit.realSync();
+ robot.waitForIdle();
tf.setText("");
- toolkit.realSync();
+ robot.waitForIdle();
tf.setText("");
- toolkit.realSync();
+ robot.waitForIdle();
checkCounts(1, 0);
f.dispose();
--- a/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeCrashTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeCrashTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -26,26 +26,25 @@
@bug 8041490
@summary tests that the WarningWindow's surface is invalidated on dispose
@author Petr Pchelko
- @run main/othervm WarningWindowDisposeCrashTest
+ @run main/othervm/policy=policy -Djava.security.manager WarningWindowDisposeCrashTest
*/
-import sun.applet.AppletSecurity;
-import sun.awt.SunToolkit;
import java.awt.*;
public class WarningWindowDisposeCrashTest {
public static void main(String[] args) throws Exception {
- System.setSecurityManager(new AppletSecurity() {
- @Override
- public void checkPackageAccess (String s){
- }
- });
-
Frame f = new Frame();
f.setVisible(true);
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ Robot robot;
+ try{
+ robot = new Robot();
+ robot.waitForIdle();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Cannot create Robot");
+ }
Thread.sleep(1000);
f.dispose();
// If the bug is present VM could crash after this call
--- a/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeTest.java Sun Nov 09 22:17:45 2014 +0300
+++ b/jdk/test/java/awt/security/WarningWindowDisposeTest/WarningWindowDisposeTest.java Mon Nov 10 16:23:30 2014 +0300
@@ -31,12 +31,11 @@
@run main WarningWindowDisposeTest
*/
-import sun.applet.AppletSecurity;
-import sun.awt.SunToolkit;
-
import java.awt.*;
import java.awt.Toolkit;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.security.Permission;
+import java.io.File;
import test.java.awt.regtesthelpers.process.ProcessCommunicator;
import test.java.awt.regtesthelpers.process.ProcessResults;
@@ -57,7 +56,9 @@
}, "TimeoutThread").start();
String classpath = System.getProperty("java.class.path");
- ProcessResults pres = ProcessCommunicator.executeChildProcess(TestApplication.class, classpath, new String[0]);
+ String policyPath = System.getProperty("test.src")+File.separatorChar+"policy";
+ System.out.println("policyPath in main: "+policyPath);
+ ProcessResults pres = ProcessCommunicator.executeChildProcess(TestApplication.class, classpath+" -Djava.security.manager -Djava.security.policy="+policyPath, new String[0]);
passed.set(true);
if (pres.getStdErr() != null && pres.getStdErr().length() > 0) {
System.err.println("========= Child VM System.err ========");
@@ -74,14 +75,16 @@
public static class TestApplication {
public static void main(String[] args) throws Exception {
- System.setSecurityManager(new AppletSecurity() {
- @Override
- public void checkPackageAccess (String s){
- }
- });
+ Robot robot;
+ try{
+ robot = new Robot();
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ throw new RuntimeException("Cannot create Robot");
+ }
Frame f = new Frame("Test frame");
f.setVisible(true);
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
Thread.sleep(500);
f.setVisible(false);
f.dispose();