8050885: move awt automated tests from AWT_Modality to OpenJDK repository - part 4
authoravstepan
Tue, 29 Jul 2014 15:03:05 +0400
changeset 26014 e50160ba221c
parent 26013 83b99f14245f
child 26015 627f46c41588
8050885: move awt automated tests from AWT_Modality to OpenJDK repository - part 4 Reviewed-by: pchelko
jdk/test/java/awt/Modal/ToFront/DialogToFrontAppModalTest.java
jdk/test/java/awt/Modal/ToFront/DialogToFrontDocModalTest.java
jdk/test/java/awt/Modal/ToFront/DialogToFrontModalBlockedTest.java
jdk/test/java/awt/Modal/ToFront/DialogToFrontModalTest.java
jdk/test/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java
jdk/test/java/awt/Modal/ToFront/DialogToFrontModelessTest.java
jdk/test/java/awt/Modal/ToFront/DialogToFrontNonModalTest.java
jdk/test/java/awt/Modal/ToFront/DialogToFrontTKModalTest.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal1Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal2Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal3Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal4Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal5Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal1Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal2Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModal1Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModal2Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModal3Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModal4Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModal5Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModalBlockedTest.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModeless1Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontModelessTest.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontNonModalTest.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal1Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal2Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal3Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal4Test.java
jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal5Test.java
jdk/test/java/awt/Modal/helpers/TestDialog.java
jdk/test/java/awt/Modal/helpers/TestFrame.java
jdk/test/java/awt/Modal/helpers/TestWindow.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontAppModalTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a dialog in presence of
+ *          blocking application modal dialog does not bring it to the top
+ *          of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main DialogToFrontAppModalTest
+ */
+
+public class DialogToFrontAppModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new DialogToFrontModalBlockedTest(
+             Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontDocModalTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a dialog in presence of
+ *          blocking document modal dialog does not bring it to the top
+ *          of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main DialogToFrontDocModalTest
+ */
+
+public class DialogToFrontDocModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new DialogToFrontModalBlockedTest(
+             Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalBlockedTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+public class DialogToFrontModalBlockedTest {
+
+    private volatile CustomDialog dialog;
+    private volatile TestDialog leftDialog;
+    private volatile TestFrame  rightFrame;
+    private volatile Frame parent;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private DialogToFrontModalBlockedTest(Dialog.ModalityType modalityType,
+                                          boolean             setModal) throws Exception {
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(() -> {
+            createGUI(modalityType, setModal);
+        });
+    }
+
+    public DialogToFrontModalBlockedTest(Dialog.ModalityType modalityType) throws Exception {
+        this(modalityType, false);
+    }
+
+    public DialogToFrontModalBlockedTest() throws Exception {
+        this(null, true);
+    }
+
+    private void createGUI(Dialog.ModalityType modalityType,
+                           boolean             setModal) {
+
+        parent = new Frame();
+        leftDialog = new TestDialog(parent);
+        leftDialog.setSize(200, 100);
+        leftDialog.setLocation(50, 50);
+        leftDialog.setVisible(true);
+
+        dialog = new CustomDialog(leftDialog);
+
+        if (setModal) { dialog.setModal(true); }
+        else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setSize(200, 100);
+        dialog.setLocation(150, 50);
+
+        rightFrame = new TestFrame();
+        rightFrame.setSize(200, 100);
+        rightFrame.setLocation(250, 50);
+
+        if (setModal || modalityType == Dialog.ModalityType.APPLICATION_MODAL) {
+            rightFrame.setModalExclusionType(
+                Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
+        } else if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) {
+            rightFrame.setModalExclusionType(
+                Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
+        }
+
+        dialog.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+            robot.waitForIdle(delay);
+
+            dialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            rightFrame.clickCloseButton(robot);
+            robot.waitForIdle(delay);
+
+            EventQueue.invokeAndWait(() -> { leftDialog.toFront(); });
+            robot.waitForIdle(delay);
+
+            rightFrame.clickDummyButton(robot);
+
+            EventQueue.invokeAndWait(() -> { leftDialog.toFront(); });
+            robot.waitForIdle(delay);
+
+            leftDialog.clickDummyButton(robot, 7, false, "Calling toFront " +
+                    "for Dialog blocked by " + dialog.getModalityType() +
+                    "dialog brought it to the top of the modal dialog");
+
+            robot.waitForIdle(delay);
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog != null) { dialog.dispose(); }
+        if (parent != null) { parent.dispose(); }
+        if (leftDialog != null) { leftDialog.dispose(); }
+        if (rightFrame != null) { rightFrame.dispose(); }
+    }
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog d) { super(d); }
+        public CustomDialog(Frame  f) { super(f); }
+
+        @Override
+        public void doOpenAction() {
+            if (rightFrame != null) {
+                rightFrame.setVisible(true);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a dialog in presence of
+ *          blocking modal dialog does not bring it to the top
+ *          of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main DialogToFrontModalTest
+ */
+
+public class DialogToFrontModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new DialogToFrontModalBlockedTest()).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method does not bring a dialog to the top
+ *          of a child modeless dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main DialogToFrontModeless1Test
+ */
+
+public class DialogToFrontModeless1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new DialogToFrontModelessTest()).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModelessTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+public class DialogToFrontModelessTest {
+
+    private volatile TestDialog dialog, leftDialog;
+    private volatile TestFrame  rightFrame;
+    private volatile Frame parent;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private boolean isModeless;
+
+    public DialogToFrontModelessTest(boolean modeless) throws Exception {
+        isModeless = modeless;
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    public DialogToFrontModelessTest() throws Exception { this(true); }
+
+    private void createGUI() {
+
+        parent = new Frame();
+
+        leftDialog = new TestDialog(parent);
+        leftDialog.setSize(200, 100);
+        leftDialog.setLocation(50, 50);
+        leftDialog.setVisible(true);
+
+        dialog = new TestDialog(leftDialog);
+
+        if (isModeless) { dialog.setModalityType(Dialog.ModalityType.MODELESS); }
+
+        dialog.setSize(200, 100);
+        dialog.setLocation(150, 50);
+
+        rightFrame = new TestFrame();
+        rightFrame.setSize(200, 100);
+        rightFrame.setLocation(250, 50);
+
+        dialog.setVisible(true);
+        rightFrame.setVisible(true);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+            robot.waitForIdle(delay);
+
+            rightFrame.clickCloseButton(robot);
+            robot.waitForIdle(delay);
+
+            EventQueue.invokeAndWait(() -> { leftDialog.toFront(); });
+            robot.waitForIdle(delay);
+
+            leftDialog.clickDummyButton(robot, 7, false,
+                "Calling toFront method for the parent left dialog " +
+                "brought it to the top of the child dialog.");
+            robot.waitForIdle(delay);
+
+            rightFrame.clickDummyButton(robot);
+            robot.waitForIdle(delay);
+
+            String msg = "The " + (isModeless ? "modeless" : "non-modal") +
+            " dialog still on top of the right frame" +
+            " even after a button on the frame is clicked.";
+            dialog.clickDummyButton(robot, 7, false, msg);
+            robot.waitForIdle(delay);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog != null) { dialog.dispose(); }
+        if (parent != null) { parent.dispose(); }
+        if (leftDialog != null) { leftDialog.dispose(); }
+        if (rightFrame != null) { rightFrame.dispose(); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontNonModalTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method does not bring a dialog to the top
+ *          of a non-modal child dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main DialogToFrontNonModalTest
+ */
+
+public class DialogToFrontNonModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new DialogToFrontModelessTest(false)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontTKModalTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a dialog in presence of
+ *          blocking toolkit modal dialog does not bring it to the top
+ *          of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main DialogToFrontTKModalTest
+ */
+
+public class DialogToFrontTKModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new DialogToFrontModalBlockedTest(
+             Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal1Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking application modal dialog having a null Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontAppModal1Test
+ */
+
+public class FrameToFrontAppModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.APPLICATION_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal2Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking application modal dialog having a null Dialog parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontAppModal2Test
+ */
+
+public class FrameToFrontAppModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.APPLICATION_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal3Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking application modal dialog having a hidden Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontAppModal3Test
+ */
+
+public class FrameToFrontAppModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.APPLICATION_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal4Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking application modal dialog having a hidden Dialog parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontAppModal4Test
+ */
+
+public class FrameToFrontAppModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.APPLICATION_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal5Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking application modal dialog having a visible Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontAppModal5Test
+ */
+
+public class FrameToFrontAppModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.APPLICATION_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal1Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking document modal dialog having a visible Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontDocModal1Test
+ */
+
+public class FrameToFrontDocModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.DOCUMENT_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal2Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check if toFront method works correctly for a document modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontDocModal2Test
+ */
+
+public class FrameToFrontDocModal2Test {
+
+    public static void main(String[] args) throws Exception {
+
+        for (FrameToFrontModalBlockedTest.DialogOwner o:
+                FrameToFrontModalBlockedTest.DialogOwner.values()) {
+
+            if (o != FrameToFrontModalBlockedTest.DialogOwner.FRAME) {
+                (new FrameToFrontModalBlockedTest(
+                    Dialog.ModalityType.DOCUMENT_MODAL, o)).doTest();
+            }
+        }
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal1Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking modal dialog having a null Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontModal1Test
+ */
+
+public class FrameToFrontModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             FrameToFrontModalBlockedTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal2Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking modal dialog having a null Dialog parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontModal2Test
+ */
+
+public class FrameToFrontModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             FrameToFrontModalBlockedTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal3Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking modal dialog having a hidden Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontModal3Test
+ */
+
+public class FrameToFrontModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             FrameToFrontModalBlockedTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal4Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking modal dialog having a hidden Dialog parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontModal4Test
+ */
+
+public class FrameToFrontModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             FrameToFrontModalBlockedTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal5Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking modal dialog having a visible Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontModal5Test
+ */
+
+public class FrameToFrontModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             FrameToFrontModalBlockedTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModalBlockedTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.*;
+
+
+public class FrameToFrontModalBlockedTest {
+
+    private volatile CustomDialog dialog;
+    private volatile TestFrame leftFrame, rightFrame;
+    private volatile Dialog hiddenDialog;
+    private volatile Frame  hiddenFrame;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    public enum DialogOwner {HIDDEN_DIALOG, NULL_DIALOG, HIDDEN_FRAME, NULL_FRAME, FRAME};
+
+    private DialogOwner owner;
+    boolean setModal;
+
+    Dialog.ModalityType modalityType;
+
+    private FrameToFrontModalBlockedTest(Dialog.ModalityType modType,
+                                         boolean             modal,
+                                         DialogOwner         o) throws Exception {
+        modalityType = modType;
+        setModal = modal;
+        owner = o;
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    public FrameToFrontModalBlockedTest(Dialog.ModalityType modalityType,
+                                        DialogOwner         o) throws Exception {
+        this(modalityType, false, o);
+    }
+
+    public FrameToFrontModalBlockedTest(DialogOwner o) throws Exception {
+        this(null, true, o);
+    }
+
+    private void createGUI() {
+
+        leftFrame = new TestFrame();
+        leftFrame.setSize(200, 100);
+        leftFrame.setLocation(50, 50);
+        leftFrame.setVisible(true);
+
+        switch (owner) {
+            case HIDDEN_DIALOG:
+                hiddenDialog = new Dialog((Frame) null);
+                dialog = new CustomDialog(hiddenDialog);
+                break;
+            case NULL_DIALOG:
+                dialog = new CustomDialog((Dialog) null);
+                break;
+            case HIDDEN_FRAME:
+                hiddenFrame = new Frame();
+                dialog = new CustomDialog(hiddenFrame);
+                break;
+            case NULL_FRAME:
+                dialog = new CustomDialog((Frame) null);
+                break;
+            case FRAME:
+                dialog = new CustomDialog(leftFrame);
+                break;
+        }
+
+        if (setModal) {
+            dialog.setModal(true);
+            modalityType = dialog.getModalityType();
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setSize(200, 100);
+        dialog.setLocation(230, 50);
+
+        rightFrame = new TestFrame();
+        rightFrame.setSize(200, 100);
+        rightFrame.setLocation(280, 50);
+
+        if  (setModal ||
+            (modalityType == Dialog.ModalityType.APPLICATION_MODAL)) {
+            rightFrame.setModalExclusionType(
+                    Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
+        }
+
+        if (modalityType == Dialog.ModalityType.TOOLKIT_MODAL) {
+            rightFrame.setModalExclusionType(
+                    Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
+        }
+
+        dialog.setVisible(true);
+    }
+
+    private void blockingTest() throws Exception {
+
+        dialog.clickOpenButton(robot);
+        robot.waitForIdle(delay);
+
+        rightFrame.clickCloseButton(robot);
+        robot.waitForIdle(delay);
+
+        EventQueue.invokeAndWait(() -> { leftFrame.toFront(); });
+        robot.waitForIdle(delay);
+
+        rightFrame.clickDummyButton(robot);
+        robot.waitForIdle(delay);
+
+        EventQueue.invokeAndWait(() -> { leftFrame.toFront(); });
+        robot.waitForIdle(delay);
+
+        leftFrame.clickDummyButton(robot, 7, false,
+            "Calling toFront for Frame blocked by " + dialog.getModalityType() +
+            " dialog brought it to the top of the modal dialog.");
+        robot.waitForIdle(delay);
+    }
+
+    private void docModalTest() throws Exception {
+
+        if (owner == DialogOwner.FRAME) { blockingTest(); }
+        else {
+            EventQueue.invokeAndWait(() -> { leftFrame.toFront(); });
+            robot.waitForIdle(delay);
+
+            leftFrame.clickDummyButton(robot);
+            robot.waitForIdle(delay);
+
+            EventQueue.invokeAndWait(() -> { dialog.toFront(); });
+            robot.waitForIdle(delay);
+
+            dialog.clickDummyButton(robot);
+            robot.waitForIdle(delay);
+        }
+
+    }
+
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            switch (modalityType) {
+                case APPLICATION_MODAL:
+                case TOOLKIT_MODAL:
+                    blockingTest();
+                    break;
+                case DOCUMENT_MODAL:
+                    docModalTest();
+                    break;
+                default:
+                    throw new RuntimeException(
+                        "improper modality type, please do not use it for this test");
+            }
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog != null) { dialog.dispose(); }
+        if (leftFrame  != null) {  leftFrame.dispose(); }
+        if (rightFrame != null) { rightFrame.dispose(); }
+        if (hiddenDialog != null) { hiddenDialog.dispose(); }
+        if (hiddenFrame  != null) {  hiddenFrame.dispose(); }
+    }
+
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog d) { super(d); }
+        public CustomDialog(Frame  f) { super(f); }
+
+        @Override
+        public void doOpenAction() {
+            if (rightFrame != null) {
+                rightFrame.setVisible(true);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModeless1Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method does not bring a frame to the top of
+ *          a modeless child dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontModeless1Test
+ */
+
+public class FrameToFrontModeless1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModelessTest(true)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModelessTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.*;
+
+
+public class FrameToFrontModelessTest {
+
+    private volatile TestDialog dialog;
+    private volatile TestFrame  leftFrame, rightFrame;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private boolean isModeless;
+
+    public FrameToFrontModelessTest(boolean modeless) throws Exception {
+        isModeless = modeless;
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    private void createGUI() {
+
+        leftFrame = new TestFrame();
+        leftFrame.setSize(200, 100);
+        leftFrame.setLocation(50, 50);
+        leftFrame.setVisible(true);
+
+        dialog = new TestDialog(leftFrame);
+        if (isModeless) { dialog.setModalityType(Dialog.ModalityType.MODELESS); }
+        dialog.setSize(200, 100);
+        dialog.setLocation(150, 50);
+        dialog.setVisible(true);
+
+        rightFrame = new TestFrame();
+        rightFrame.setSize(200, 100);
+        rightFrame.setLocation(250, 50);
+        rightFrame.setVisible(true);
+    }
+
+
+    public void doTest() throws Exception {
+
+        try {
+
+            robot.waitForIdle(delay);
+
+            EventQueue.invokeAndWait(() -> { leftFrame.toFront(); });
+            robot.waitForIdle(delay);
+
+            leftFrame.clickDummyButton(
+                robot, 7, false, "Calling toFront method on the parent " +
+                "left frame brought it to the top of the child dialog");
+            robot.waitForIdle(delay);
+
+            // show the right frame appear on top of the dialog
+            rightFrame.clickDummyButton(robot);
+            robot.waitForIdle(delay);
+
+            String msg = "The " + (isModeless ? "modeless" : "non-modal") +
+                " dialog still on top of the right frame" +
+                " even after a button on the frame is clicked";
+            dialog.clickDummyButton(robot, 7, false, msg);
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog != null) { dialog.dispose(); }
+        if (leftFrame  != null) {  leftFrame.dispose(); }
+        if (rightFrame != null) { rightFrame.dispose(); }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontNonModalTest.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method does not bring a frame to the top
+ *          of a non-modal child dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontNonModalTest
+ */
+
+public class FrameToFrontNonModalTest {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModelessTest(false)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal1Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking modal toolkit dialog having a null Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontTKModal1Test
+ */
+
+public class FrameToFrontTKModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.TOOLKIT_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal2Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking toolkit modal dialog having a null Dialog parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontTKModal2Test
+ */
+
+public class FrameToFrontTKModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.TOOLKIT_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal3Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking toolkit modal dialog having a hidden Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontTKModal3Test
+ */
+
+public class FrameToFrontTKModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.TOOLKIT_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal4Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking toolkit modal dialog having a hidden Dialog parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontTKModal4Test
+ */
+
+public class FrameToFrontTKModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.TOOLKIT_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal5Test.java	Tue Jul 29 15:03:05 2014 +0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8050885
+ * @summary Check that calling toFront method for a frame in presence of
+ *          blocking toolkit modal dialog having a visible Frame parent
+ *          does not bring the frame to the top of the modal dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main FrameToFrontTKModal5Test
+ */
+
+public class FrameToFrontTKModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new FrameToFrontModalBlockedTest(
+             Dialog.ModalityType.TOOLKIT_MODAL,
+             FrameToFrontModalBlockedTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- a/jdk/test/java/awt/Modal/helpers/TestDialog.java	Tue Jul 29 12:55:08 2014 +0400
+++ b/jdk/test/java/awt/Modal/helpers/TestDialog.java	Tue Jul 29 15:03:05 2014 +0400
@@ -211,36 +211,63 @@
     }
 
     public void clickOpenButton(ExtendedRobot robot) throws Exception {
+        clickOpenButton(robot, true, "");
+    }
+
+    public void clickOpenButton(ExtendedRobot robot,
+                                boolean       refState,
+                                String        message) throws Exception {
         openClicked.reset();
         clickButton(openButton, robot);
+        openClicked.waitForFlagTriggered();
 
-        openClicked.waitForFlagTriggered();
-        assertTrue(openClicked.flag(),
-            "clicking the dialog Open button did not trigger an action");
+        String msg = "Clicking the dialog Open button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(openClicked.flag(), refState, msg + " " + message);
     }
 
     public void clickCloseButton(ExtendedRobot robot) throws Exception {
+        clickCloseButton(robot, true, "");
+    }
+
+    public void clickCloseButton(ExtendedRobot robot,
+                                 boolean       refState,
+                                 String        message) throws Exception {
         closeClicked.reset();
         clickButton(closeButton, robot);
+        closeClicked.waitForFlagTriggered();
 
-        closeClicked.waitForFlagTriggered();
-        assertTrue(closeClicked.flag(),
-            "clicking the dialog Close button did not trigger an action");
+        String msg = "Clicking the dialog Close button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(closeClicked.flag(), refState, msg + " " + message);
     }
 
     public void clickDummyButton(ExtendedRobot robot) throws Exception {
         clickDummyButton(robot, Flag.ATTEMPTS);
     }
 
-    public void clickDummyButton(ExtendedRobot robot, int attempts) throws Exception {
+    public void clickDummyButton(ExtendedRobot robot,
+                                 int           attempts) throws Exception {
+        clickDummyButton(robot, attempts, true, "");
+    }
+
+    public void clickDummyButton(ExtendedRobot robot,
+                                 int           attempts,
+                                 boolean       refState,
+                                 String        message) throws Exception {
         dummyClicked.reset();
         clickButton(dummyButton, robot);
+        dummyClicked.waitForFlagTriggered(attempts);
 
-        dummyClicked.waitForFlagTriggered(attempts);
-        assertTrue(dummyClicked.flag(),
-            "clicking the dialog Dummy button did not trigger an action");
+        String msg = "Clicking the dialog Dummy button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(dummyClicked.flag(), refState, msg + " " + message);
     }
 
+
     private void clickInside(ExtendedRobot robot) throws Exception {
 
         try {
--- a/jdk/test/java/awt/Modal/helpers/TestFrame.java	Tue Jul 29 12:55:08 2014 +0400
+++ b/jdk/test/java/awt/Modal/helpers/TestFrame.java	Tue Jul 29 15:03:05 2014 +0400
@@ -203,19 +203,37 @@
     }
 
     public void clickOpenButton(ExtendedRobot robot) throws Exception {
+        clickOpenButton(robot, true, "");
+    }
+
+    public void clickOpenButton(ExtendedRobot robot,
+                                boolean       refState,
+                                String        message) throws Exception {
         openClicked.reset();
         clickButton(openButton, robot);
         openClicked.waitForFlagTriggered();
-        assertTrue(openClicked.flag(),
-            "clicking the frame Open button did not trigger an action");
+
+        String msg = "Clicking the frame Open button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(openClicked.flag(), refState, msg + " " + message);
     }
 
     public void clickCloseButton(ExtendedRobot robot) throws Exception {
+        clickCloseButton(robot, true, "");
+    }
+
+    public void clickCloseButton(ExtendedRobot robot,
+                                 boolean       refState,
+                                 String        message) throws Exception {
         closeClicked.reset();
         clickButton(closeButton, robot);
         closeClicked.waitForFlagTriggered();
-        assertTrue(closeClicked.flag(),
-            "clicking the frame Close button did not trigger an action");
+
+        String msg = "Clicking the frame Close button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(closeClicked.flag(), refState, msg + " " + message);
     }
 
     public void clickDummyButton(ExtendedRobot robot) throws Exception {
@@ -223,13 +241,22 @@
     }
 
     public void clickDummyButton(ExtendedRobot robot,
-                                 int amountOfAttempts) throws Exception {
+                                 int           attempts) throws Exception {
+        clickDummyButton(robot, attempts, true, "");
+    }
+
+    public void clickDummyButton(ExtendedRobot robot,
+                                 int           attempts,
+                                 boolean       refState,
+                                 String        message) throws Exception {
         dummyClicked.reset();
         clickButton(dummyButton, robot);
+        dummyClicked.waitForFlagTriggered();
 
-        dummyClicked.waitForFlagTriggered();
-        assertTrue(dummyClicked.flag(),
-            "clicking the frame Dummy button did not trigger an action");
+        String msg = "Clicking the frame Dummy button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(dummyClicked.flag(), refState, msg + " " + message);
     }
 
     public void clickInside(ExtendedRobot robot) throws Exception {
--- a/jdk/test/java/awt/Modal/helpers/TestWindow.java	Tue Jul 29 12:55:08 2014 +0400
+++ b/jdk/test/java/awt/Modal/helpers/TestWindow.java	Tue Jul 29 15:03:05 2014 +0400
@@ -210,30 +210,54 @@
     }
 
     public void clickOpenButton(ExtendedRobot robot) throws Exception {
+        clickOpenButton(robot, true, "");
+    }
+
+    public void clickOpenButton(ExtendedRobot robot,
+                                boolean       refState,
+                                String        message) throws Exception {
         openClicked.reset();
         clickButton(openButton, robot);
+        openClicked.waitForFlagTriggered();
 
-        openClicked.waitForFlagTriggered();
-        assertTrue(openClicked.flag(),
-            "clicking the window Open button did not trigger an action");
+        String msg = "Clicking the window Open button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(openClicked.flag(), refState, msg + " " + message);
     }
 
     public void clickCloseButton(ExtendedRobot robot) throws Exception {
+        clickCloseButton(robot, true, "");
+    }
+
+    public void clickCloseButton(ExtendedRobot robot,
+                                 boolean       refState,
+                                 String        message) throws Exception {
         closeClicked.reset();
         clickButton(closeButton, robot);
+        closeClicked.waitForFlagTriggered();
 
-        closeClicked.waitForFlagTriggered();
-        assertTrue(closeClicked.flag(),
-            "clicking the window Close button did not trigger an action");
+        String msg = "Clicking the window Close button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(closeClicked.flag(), refState, msg + " " + message);
     }
 
     public void clickDummyButton(ExtendedRobot robot) throws Exception {
+        clickDummyButton(robot, true, "");
+    }
+
+    public void clickDummyButton(ExtendedRobot robot,
+                                 boolean       refState,
+                                 String        message) throws Exception {
         dummyClicked.reset();
         clickButton(dummyButton, robot);
+        dummyClicked.waitForFlagTriggered();
 
-        dummyClicked.waitForFlagTriggered();
-        assertTrue(dummyClicked.flag(),
-            "clicking the window Dummy button did not trigger an action");
+        String msg = "Clicking the window Dummy button " + (refState ?
+            "did not trigger an action." :
+            "triggered an action when it should not.");
+        assertEQ(dummyClicked.flag(), refState, msg + " " + message);
     }
 
     public void checkBlockedWindow(ExtendedRobot robot,