8063102: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 1

Reviewed-by: pchelko, serb
This commit is contained in:
Yuri Nesterenko 2014-11-10 16:23:30 +03:00
parent e8c7cc1187
commit 043868fac7
28 changed files with 233 additions and 143 deletions

View File

@ -33,15 +33,12 @@ import java.awt.*;
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 @@ public class WindowOpacity
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 @@ public class WindowOpacity
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 @@ public class WindowOpacity
AWTUtilities.setWindowOpacity(f, 0.5f);
realSync();
robot.waitForIdle();
curOpacity = AWTUtilities.getWindowOpacity(f);
if (curOpacity < 0.5f || curOpacity > 0.5f) {

View File

@ -36,7 +36,6 @@
*/
import java.awt.*;
import sun.awt.SunToolkit;
public class NoUpdateUponShow
{
@ -70,7 +69,13 @@ public class NoUpdateUponShow
});
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. ");

View File

@ -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 @@ import java.awt.image.BufferedImage;
@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 @@ public class PaintAll {
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 @@ public class PaintAll {
}
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) {

View File

@ -34,11 +34,9 @@ import java.awt.event.*;
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 @@ public class ModalBlockedStealsFocusTest extends Applet {
}).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.

View File

@ -33,7 +33,6 @@ import java.awt.*;
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 @@ public class WindowInitialFocusTest extends Applet {
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 @@ public class WindowInitialFocusTest extends Applet {
}});
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 @@ public class WindowInitialFocusTest extends Applet {
// 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!");

View File

@ -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 @@ public class ExceptionOnSetExtendedStateTest {
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);

View File

@ -77,7 +77,13 @@ public class TestFrameSize {
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);

View File

@ -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 @@ public class MaximizedByPlatform {
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 @@ public class MaximizedByPlatform {
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 @@ public class MaximizedByPlatform {
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");

View File

@ -28,7 +28,7 @@ import java.awt.GraphicsEnvironment;
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 @@ public class MaximizedToMaximized {
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

View File

@ -21,8 +21,6 @@
* questions.
*/
import sun.awt.SunToolkit;
import java.awt.*;
import java.awt.Dimension;
import java.awt.Point;
@ -62,8 +60,9 @@ public class SlideNotResizableTest {
}
}
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);
}
}

View File

@ -34,10 +34,17 @@ import java.awt.geom.*;
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 @@ public class TranslucentWindow {
// 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 @@ public class TranslucentWindow {
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) {

View File

@ -27,16 +27,17 @@ import java.awt.DisplayMode;
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 @@ public class IncorrectDisplayModeExitFullscreen {
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 @@ public class IncorrectDisplayModeExitFullscreen {
}
}
private static void sleep() {
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
try {
Thread.sleep(1500);
} catch (InterruptedException ignored) {
}
robot.waitForIdle(1500);
}
}

View File

@ -71,7 +71,14 @@ public class GridBagLayoutIpadXYTest extends Applet
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 ||

View File

@ -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 @@ public final class R2303044ListSelection {
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();
}
}
}

View File

@ -30,7 +30,6 @@
*/
import java.awt.*;
import sun.awt.SunToolkit;
public class SingleModeDeselect
{
@ -50,7 +49,13 @@ public class SingleModeDeselect
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());

View File

@ -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 @@ public final class ExposeOnEDT {
}
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) {

View File

@ -26,12 +26,13 @@ import java.awt.Frame;
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 @@ public final class ScrollPanePreferredSize {
}
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");
}
}
}

View File

@ -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 class TestDispose {
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 @@ public class TestDispose {
frame.setVisible(true);
}
});
toolkit.realSync();
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@ -77,7 +82,7 @@ public class TestDispose {
frame.dispose();
}
});
toolkit.realSync();
robot.waitForIdle();
}
public static void main(String[] args) throws Exception{

View File

@ -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.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.text.DefaultCaret;
import sun.awt.SunToolkit;
public class bug7129742 {
@ -51,7 +50,7 @@ public class bug7129742 {
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 @@ public class bug7129742 {
}
}
});
toolkit.realSync();
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override

View File

@ -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 @@ public final class TextAreaTwicePack {
}
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();
}
}
}

View File

@ -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 class TestDispose {
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 @@ public class TestDispose {
frame.setVisible(true);
}
});
toolkit.realSync();
robot.waitForIdle();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@ -77,7 +81,7 @@ public class TestDispose {
frame.dispose();
}
});
toolkit.realSync();
robot.waitForIdle();
}

View File

@ -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 @@ public class PopupMenuLeakTest {
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 @@ public class PopupMenuLeakTest {
}
private static void sleep() {
((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
try {
Thread.sleep(100);
} catch (InterruptedException ignored) { }
robot.waitForIdle(100);
}
}

View File

@ -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 @@ public class Test8027025 {
window.setVisible(true);
});
((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
Robot robot = new Robot();
robot.waitForIdle();
AtomicReference<Point> point = new AtomicReference<>();
SwingUtilities.invokeAndWait(() -> point.set(window.getLocationOnScreen()));

View File

@ -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 @@ import sun.awt.SunToolkit;
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 @@ public class AlwaysOnTopFieldTest {
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()) {

View File

@ -21,8 +21,6 @@
* questions.
*/
import sun.awt.SunToolkit;
import javax.swing.*;
import java.awt.*;
import java.io.ByteArrayInputStream;
@ -54,7 +52,8 @@ public class OwnedWindowsSerialization {
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");

View File

@ -30,7 +30,6 @@
*/
import java.awt.*;
import java.awt.event.*;
import sun.awt.SunToolkit;
public class TextEventSequenceTest {
@ -48,43 +47,50 @@ public class TextEventSequenceTest {
}
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();

View File

@ -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

View File

@ -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 @@ public class WarningWindowDisposeTest {
}, "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 class WarningWindowDisposeTest {
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();