changeset 28069:907a72cb0feb

8054143: move awt automated tests from AWT_Modality to OpenJDK repository - part 6 Reviewed-by: pchelko
author avstepan
date Wed, 19 Nov 2014 14:12:59 +0400
parents e0916ce5b3fc
children 001f640e7016
files jdk/test/java/awt/Modal/ToBack/ToBackAppModal1Test.java jdk/test/java/awt/Modal/ToBack/ToBackAppModal2Test.java jdk/test/java/awt/Modal/ToBack/ToBackAppModal3Test.java jdk/test/java/awt/Modal/ToBack/ToBackAppModal4Test.java jdk/test/java/awt/Modal/ToBack/ToBackAppModal5Test.java jdk/test/java/awt/Modal/ToBack/ToBackAppModal6Test.java jdk/test/java/awt/Modal/ToBack/ToBackDDFTest.java jdk/test/java/awt/Modal/ToBack/ToBackDocModal1Test.java jdk/test/java/awt/Modal/ToBack/ToBackDocModal2Test.java jdk/test/java/awt/Modal/ToBack/ToBackDocModal3Test.java jdk/test/java/awt/Modal/ToBack/ToBackDocModal4Test.java jdk/test/java/awt/Modal/ToBack/ToBackDocModal5Test.java jdk/test/java/awt/Modal/ToBack/ToBackDocModal6Test.java jdk/test/java/awt/Modal/ToBack/ToBackFDFTest.java jdk/test/java/awt/Modal/ToBack/ToBackModal1Test.java jdk/test/java/awt/Modal/ToBack/ToBackModal2Test.java jdk/test/java/awt/Modal/ToBack/ToBackModal3Test.java jdk/test/java/awt/Modal/ToBack/ToBackModal4Test.java jdk/test/java/awt/Modal/ToBack/ToBackModal5Test.java jdk/test/java/awt/Modal/ToBack/ToBackModal6Test.java jdk/test/java/awt/Modal/ToBack/ToBackModeless1Test.java jdk/test/java/awt/Modal/ToBack/ToBackModeless2Test.java jdk/test/java/awt/Modal/ToBack/ToBackModeless3Test.java jdk/test/java/awt/Modal/ToBack/ToBackModeless4Test.java jdk/test/java/awt/Modal/ToBack/ToBackModeless5Test.java jdk/test/java/awt/Modal/ToBack/ToBackModeless6Test.java jdk/test/java/awt/Modal/ToBack/ToBackNonModal1Test.java jdk/test/java/awt/Modal/ToBack/ToBackNonModal2Test.java jdk/test/java/awt/Modal/ToBack/ToBackNonModal3Test.java jdk/test/java/awt/Modal/ToBack/ToBackNonModal4Test.java jdk/test/java/awt/Modal/ToBack/ToBackNonModal5Test.java jdk/test/java/awt/Modal/ToBack/ToBackNonModal6Test.java jdk/test/java/awt/Modal/ToBack/ToBackTKModal1Test.java jdk/test/java/awt/Modal/ToBack/ToBackTKModal2Test.java jdk/test/java/awt/Modal/ToBack/ToBackTKModal3Test.java jdk/test/java/awt/Modal/ToBack/ToBackTKModal4Test.java jdk/test/java/awt/Modal/ToBack/ToBackTKModal5Test.java jdk/test/java/awt/Modal/ToBack/ToBackTKModal6Test.java
diffstat 38 files changed, 2134 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal1Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether an application modal dialog having a null Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal1Test
+ */
+
+public class ToBackAppModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+            ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal2Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether an application modal dialog having a null Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal2Test
+ */
+
+public class ToBackAppModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+            ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal3Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether an application modal dialog having a hidden Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal3Test
+ */
+
+public class ToBackAppModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+            ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal4Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether an application modal dialog having a hidden Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal4Test
+ */
+
+public class ToBackAppModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+            ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal5Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether an application modal dialog having a visible Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal5Test
+ */
+
+public class ToBackAppModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.APPLICATION_MODAL,
+            ToBackFDFTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackAppModal6Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether an application modal dialog having a visible Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackAppModal6Test
+ */
+
+public class ToBackAppModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackDDFTest(Dialog.ModalityType.APPLICATION_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDDFTest.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,183 @@
+/*
+ * 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.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+// DDF: Dialog->Dialog->Frame
+
+public class ToBackDDFTest {
+
+    private volatile TestDialog leftDialog;
+    private volatile TestFrame  rightFrame;
+    private volatile CustomDialog dialog;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private Frame hiddenFrame;
+
+    private volatile boolean setModal;
+
+    private Dialog.ModalityType modalityType;
+
+    private ToBackDDFTest(Dialog.ModalityType modType,
+                          boolean             modal) throws Exception {
+        modalityType = modType;
+        setModal = modal;
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    public ToBackDDFTest(Dialog.ModalityType modalityType) throws Exception {
+        this(modalityType, false);
+    }
+
+    public ToBackDDFTest(boolean modal) throws Exception { this(null, modal); }
+
+    private void createGUI() {
+
+        hiddenFrame = new Frame();
+        leftDialog = new TestDialog(hiddenFrame);
+        leftDialog.setLocation(50, 50);
+        leftDialog.setBackground(Color.BLUE);
+        leftDialog.setVisible(true);
+
+        dialog = new CustomDialog(leftDialog);
+
+        if (modalityType == null) {
+            dialog.setModal(setModal);
+            modalityType = dialog.getModalityType();
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setBackground(Color.WHITE);
+        dialog.setLocation(150, 50);
+
+        rightFrame = new TestFrame();
+        rightFrame.setLocation(250, 50);
+        rightFrame.setBackground(Color.RED);
+
+        if (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);
+    }
+
+    private void checkLeftDialogIsOverlapped(String msg) {
+
+        Point p = leftDialog.getLocationOnScreen();
+        int x = p.x + (int)(leftDialog.getWidth()  * 0.9);
+        int y = p.y + (int)(leftDialog.getHeight() * 0.9);
+        boolean f = robot.getPixelColor(x, y).equals(leftDialog.getBackground());
+        assertFalse(f, msg);
+    }
+
+    private void checkRightFrameIsOverlaped(String msg) {
+
+        Point p = rightFrame.getLocationOnScreen();
+        int x = p.x + (int)(rightFrame.getWidth()  * 0.1);
+        int y = p.y + (int)(rightFrame.getHeight() * 0.9);
+        boolean f = robot.getPixelColor(x, y).equals(rightFrame.getBackground());
+        assertFalse(f, msg);
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+            robot.waitForIdle(delay);
+
+            dialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            dialog.clickCloseButton(robot);
+            robot.waitForIdle(delay);
+
+            EventQueue.invokeAndWait(() -> { dialog.toBack(); });
+            robot.waitForIdle(delay);
+
+            String type = modalityType.toString().toLowerCase().replace('_', ' ');
+
+            boolean isModeless = (modalityType == Dialog.ModalityType.MODELESS);
+
+            final String msg1;
+            if (isModeless) {
+                msg1 = "The modeless dialog was overlapped by the " +
+                    "parent dialog after calling toBack method.";
+            } else {
+                msg1 = "The " + type + " dialog was overlapped by the blocked dialog.";
+            }
+            EventQueue.invokeAndWait(() -> { checkLeftDialogIsOverlapped(msg1); });
+
+            if (isModeless) {
+                EventQueue.invokeAndWait(() -> { dialog.toFront(); });
+            } else {
+                EventQueue.invokeAndWait(() -> { leftDialog.toFront(); });
+            }
+            robot.waitForIdle(delay);
+
+            final String msg2 = "The dialog is still behind the right frame after " +
+                "calling toFront method for " + (isModeless ? "it." : "its parent.");
+
+            EventQueue.invokeAndWait(() -> { checkRightFrameIsOverlaped(msg2); });
+
+            final String msg3;
+            if (isModeless) {
+                msg3 = "The modeless dialog is still behind the parent dialog.";
+            } else {
+                msg3 = "The " + type + " dialog was overlapped by the blocked " +
+                "dialog after calling toFront method for the blocked dialog.";
+            }
+            EventQueue.invokeAndWait(() -> { checkLeftDialogIsOverlapped(msg3); });
+
+        } finally {
+            EventQueue.invokeAndWait(this::closeAll);
+        }
+    }
+
+    private void closeAll() {
+        if (dialog      != null) {      dialog.dispose(); }
+        if (leftDialog  != null) {  leftDialog.dispose(); }
+        if (rightFrame  != null) {  rightFrame.dispose(); }
+        if (hiddenFrame != null) { hiddenFrame.dispose(); }
+    }
+
+
+    class CustomDialog extends TestDialog {
+
+        public CustomDialog(Dialog d) { super(d); }
+
+        @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/ToBack/ToBackDocModal1Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ *          a document modal dialog with null Frame parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal1Test
+ */
+
+public class ToBackDocModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal2Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ *          a document modal dialog with null Dialog parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal2Test
+ */
+
+public class ToBackDocModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal3Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ *          a document modal dialog with hidden Frame parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal3Test
+ */
+
+public class ToBackDocModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal4Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for
+ *          a document modal dialog with hidden Dialog parent.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal4Test
+ */
+
+public class ToBackDocModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal5Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a document modal dialog having a visible Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal5Test
+ */
+
+public class ToBackDocModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.DOCUMENT_MODAL,
+            ToBackFDFTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackDocModal6Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a document modal dialog having a visible Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackDocModal6Test
+ */
+
+public class ToBackDocModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackDDFTest(Dialog.ModalityType.DOCUMENT_MODAL)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackFDFTest.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,291 @@
+/*
+ * 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.*;
+import static jdk.testlibrary.Asserts.*;
+
+
+// FDF: Frame->Dialog->Frame
+
+public class ToBackFDFTest {
+
+    private volatile CustomDialog dialog;
+    private volatile TestFrame leftFrame, rightFrame;
+
+    private static final int delay = 500;
+    private final ExtendedRobot robot;
+
+    private Dialog hiddenDialog;
+    private Frame  hiddenFrame;
+
+    public enum DialogOwner {HIDDEN_DIALOG, NULL_DIALOG, HIDDEN_FRAME, NULL_FRAME, FRAME};
+
+    private DialogOwner owner;
+    private volatile boolean setModal;
+
+    private Dialog.ModalityType modalityType;
+
+    private ToBackFDFTest(Dialog.ModalityType modType,
+                          boolean             modal,
+                          DialogOwner         o) throws Exception {
+        modalityType = modType;
+        setModal = modal;
+        owner = o;
+
+        robot = new ExtendedRobot();
+        EventQueue.invokeLater(this::createGUI);
+    }
+
+    public ToBackFDFTest(Dialog.ModalityType modalityType,
+                         DialogOwner         o) throws Exception {
+        this(modalityType, false, o);
+    }
+
+    public ToBackFDFTest(boolean modal, DialogOwner o) throws Exception {
+        this(null, modal, o);
+    }
+
+    private void createGUI() {
+
+        leftFrame = new TestFrame();
+        leftFrame.setLocation(50, 50);
+        leftFrame.setBackground(Color.BLUE);
+        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 (modalityType == null) {
+            dialog.setModal(setModal);
+            modalityType = dialog.getModalityType();
+        } else if (modalityType != null) {
+            dialog.setModalityType(modalityType);
+        }
+
+        dialog.setBackground(Color.WHITE);
+        dialog.setLocation(150, 50);
+
+        rightFrame = new TestFrame();
+        rightFrame.setLocation(250, 50);
+        rightFrame.setBackground(Color.RED);
+
+        if (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);
+    }
+
+    private void checkIfLeftOnTop(boolean refState, String msg) {
+
+        Point p = leftFrame.getLocationOnScreen();
+        int x = p.x + (int)(leftFrame.getWidth()  * 0.9);
+        int y = p.y + (int)(leftFrame.getHeight() * 0.9);
+        boolean f = robot.getPixelColor(x, y).equals(leftFrame.getBackground());
+        assertEQ(refState, f, msg);
+    }
+
+    private void checkIfRightOnTop(boolean refState, String msg) {
+
+        Point p = rightFrame.getLocationOnScreen();
+        int x = p.x + (int)(rightFrame.getWidth()  * 0.1);
+        int y = p.y + (int)(rightFrame.getHeight() * 0.9);
+        boolean f = robot.getPixelColor(x, y).equals(rightFrame.getBackground());
+        assertEQ(refState, f, msg);
+    }
+
+    private void Test() throws Exception {
+
+        String type =
+            dialog.getModalityType().toString().toLowerCase().replace('_', ' ');
+
+        final String msg1 = "The " + type + "dialog was " +
+            "overlapped by the blocked frame.";
+        EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg1); });
+
+        EventQueue.invokeAndWait(() -> { leftFrame.toFront(); });
+        robot.waitForIdle(delay);
+
+        final String msg2 = "The dialog is still overlapped by the right frame" +
+            " after calling toFront method for the blocked (left) frame.";
+        EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg2); });
+
+        final String msg3 = "The " + type + " dialog was overlapped by the " +
+            "blocked frame after calling toFront method for the blocked frame.";
+        EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg3); });
+
+
+        if (owner == DialogOwner.FRAME) { return; }
+
+        EventQueue.invokeAndWait(() -> { leftFrame.toBack(); });
+        robot.waitForIdle(delay);
+
+        final String msg4 = "Calling toBack " +
+            "for the blocked frame pushed the blocking dialog to back.";
+        EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg4); });
+
+        final String msg5 = "The " + type + " dialog was overlapped " +
+            "by the blocked frame after toBack was called for the left frame.";
+        EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg5); });
+    }
+
+    private void docTest() throws Exception {
+
+        if (owner == DialogOwner.FRAME) { Test(); }
+        else {
+
+            final String msg1 = "toBack was called for the dialog.";
+            EventQueue.invokeAndWait(() -> {  checkIfLeftOnTop(true, msg1); });
+            EventQueue.invokeAndWait(() -> { checkIfRightOnTop(true, msg1); });
+
+            EventQueue.invokeAndWait(() -> { dialog.toFront(); });
+            robot.waitForIdle(delay);
+
+            final String msg2 = "Dialog still behind " +
+                "the right frame even after calling toFront method.";
+            EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg2); });
+            final String msg3 = "The document modal dialog " +
+                "gone behind the blocked left frame.";
+            EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg3); });
+
+            EventQueue.invokeAndWait(() -> { leftFrame.toBack(); });
+            robot.waitForIdle(delay);
+
+            final String msg4 = "Calling toBack for the left " +
+                "frame pushed the document modal dialog to back.";
+            EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg4); });
+            final String msg5 = "The document modal dialog " +
+                "was pushed behind the left frame when toBack called for the frame.";
+            EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg5); });
+        }
+    }
+
+    private void modelessTest() throws Exception {
+
+        if (owner == DialogOwner.FRAME) {
+            final String msg = "The modeless dialog was " +
+                "pushed behind the parent left frame after toBack call.";
+            EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg); });
+        } else {
+            final String msg =
+                "Dialog should not overlap the frame after calling toBack.";
+            EventQueue.invokeAndWait(() -> {  checkIfLeftOnTop(true, msg); });
+            EventQueue.invokeAndWait(() -> { checkIfRightOnTop(true, msg); });
+        }
+
+        EventQueue.invokeAndWait(() -> { dialog.toFront(); });
+        robot.waitForIdle(delay);
+
+        final String msg1 = "The frames should not overlap the dialog " +
+            "after calling toFront for it.";
+        EventQueue.invokeAndWait(() -> {  checkIfLeftOnTop(false, msg1); });
+        EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg1); });
+
+        if (owner == DialogOwner.FRAME) { return; }
+
+        EventQueue.invokeAndWait(() -> { leftFrame.toBack(); });
+        robot.waitForIdle(delay);
+
+        final String msg2 = "Calling toBack method for the " +
+            "left frame pushed the modeless dialog to back.";
+        EventQueue.invokeAndWait(() -> { checkIfRightOnTop(false, msg2); });
+        final String msg3 = "The modeless dialog was pushed " +
+            "behind the left frame after toBack was called for the frame.";
+        EventQueue.invokeAndWait(() -> { checkIfLeftOnTop(false, msg3); });
+    }
+
+    public void doTest() throws Exception {
+
+        try {
+            robot.waitForIdle(delay);
+
+            dialog.clickOpenButton(robot);
+            robot.waitForIdle(delay);
+
+            dialog.clickCloseButton(robot);
+            robot.waitForIdle(delay);
+
+            EventQueue.invokeAndWait(() -> { dialog.toBack(); });
+            robot.waitForIdle(delay);
+
+            switch (modalityType) {
+                case APPLICATION_MODAL:
+                case TOOLKIT_MODAL:
+                    Test();
+                    break;
+                case DOCUMENT_MODAL:
+                    docTest();
+                    break;
+                case MODELESS:
+                    modelessTest();
+                    break;
+            }
+        } 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/ToBack/ToBackModal1Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modal dialog having a null Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal1Test
+ */
+
+public class ToBackModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            true, ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal2Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a modal dialog having a null Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal2Test
+ */
+
+public class ToBackModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            true, ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal3Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a modal dialog having a hidden Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal3Test
+ */
+
+public class ToBackModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            true, ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal4Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a modal dialog having a hidden Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal4Test
+ */
+
+public class ToBackModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            true, ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal5Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a modal dialog having a visible Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal5Test
+ */
+
+public class ToBackModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            true, ToBackFDFTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModal6Test.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * 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 8054143
+ * @summary Check whether a modal dialog having a visible Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModal6Test
+ */
+
+public class ToBackModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackDDFTest(true)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless1Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a null Frame constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless1Test
+ */
+
+public class ToBackModeless1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+            ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless2Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a null Dialog constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless2Test
+ */
+
+public class ToBackModeless2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+            ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless3Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a hidden Frame constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless3Test
+ */
+
+public class ToBackModeless3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+            ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless4Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a modeless dialog having a hidden Dialog constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless4Test
+ */
+
+public class ToBackModeless4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+            ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless5Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check if toBack method works correctly for a modeless dialog
+ *          having a visible Frame constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless5Test
+ */
+
+public class ToBackModeless5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.MODELESS,
+            ToBackFDFTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless6Test.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * 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 8054143
+ * @summary Check if toBack method works correctly for a modeless dialog
+ *          having a visible Dialog constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackModeless6Test
+ */
+
+public class ToBackModeless6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackDDFTest(Dialog.ModalityType.MODELESS)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal1Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a non-modal dialog having a null Frame constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal1Test
+ */
+
+public class ToBackNonModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            false, ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal2Test.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * 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 8054143
+ * @summary Check whether a non-modal dialog having a null Dialog constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal2Test
+ */
+
+public class ToBackNonModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            false, ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal3Test.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * 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 8054143
+ * @summary Check whether a non-modal dialog having a hidden Frame constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal3Test
+ */
+
+public class ToBackNonModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            false, ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal4Test.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * 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 8054143
+ * @summary Check whether a non-modal dialog having a hidden Dialog constructor
+ *          goes behind other windows when toBack is called for it.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal4Test
+ */
+
+public class ToBackNonModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            false, ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal5Test.java	Wed Nov 19 14:12:59 2014 +0400
@@ -0,0 +1,45 @@
+/*
+ * 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 8054143
+ * @summary Check if toBack method works correctly for a non-modal dialog
+ *          having a visible Frame constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal5Test
+ */
+
+public class ToBackNonModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(
+            false, ToBackFDFTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal6Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check if toBack method works correctly for a non-modal dialog
+ *          having a visible Dialog constructor.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackNonModal6Test
+ */
+
+public class ToBackNonModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackDDFTest(false)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal1Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a toolkit modal dialog having a null Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal1Test
+ */
+
+public class ToBackTKModal1Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+            ToBackFDFTest.DialogOwner.NULL_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal2Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a toolkit modal dialog having a null Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal2Test
+ */
+
+public class ToBackTKModal2Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+            ToBackFDFTest.DialogOwner.NULL_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal3Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a toolkit modal dialog having a hidden Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal3Test
+ */
+
+public class ToBackTKModal3Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+            ToBackFDFTest.DialogOwner.HIDDEN_FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal4Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a toolkit modal dialog having a hidden Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal4Test
+ */
+
+public class ToBackTKModal4Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+            ToBackFDFTest.DialogOwner.HIDDEN_DIALOG)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal5Test.java	Wed Nov 19 14:12:59 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 8054143
+ * @summary Check whether a toolkit modal dialog having a visible Frame
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal5Test
+ */
+
+public class ToBackTKModal5Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackFDFTest(Dialog.ModalityType.TOOLKIT_MODAL,
+            ToBackFDFTest.DialogOwner.FRAME)).doTest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackTKModal6Test.java	Wed Nov 19 14:12:59 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.
+ */
+
+import java.awt.Dialog;
+
+/*
+ * @test
+ * @bug 8054143
+ * @summary Check whether a toolkit modal dialog having a visible Dialog
+ *          constructor still stays on top of the blocked windows even
+ *          after calling toBack for the dialog.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @run main ToBackTKModal6Test
+ */
+
+public class ToBackTKModal6Test {
+
+    public static void main(String[] args) throws Exception {
+        (new ToBackDDFTest(Dialog.ModalityType.TOOLKIT_MODAL)).doTest();
+    }
+}