From 035f6b8d1b420e1d5084b484296cf3b7d046e024 Mon Sep 17 00:00:00 2001 From: Alexander Stepanov Date: Tue, 29 Jul 2014 15:03:05 +0400 Subject: [PATCH] 8050885: move awt automated tests from AWT_Modality to OpenJDK repository - part 4 Reviewed-by: pchelko --- .../ToFront/DialogToFrontAppModalTest.java | 47 ++++ .../ToFront/DialogToFrontDocModalTest.java | 47 ++++ .../DialogToFrontModalBlockedTest.java | 135 ++++++++++++ .../Modal/ToFront/DialogToFrontModalTest.java | 44 ++++ .../ToFront/DialogToFrontModeless1Test.java | 43 ++++ .../ToFront/DialogToFrontModelessTest.java | 105 +++++++++ .../ToFront/DialogToFrontNonModalTest.java | 43 ++++ .../ToFront/DialogToFrontTKModalTest.java | 47 ++++ .../ToFront/FrameToFrontAppModal1Test.java | 48 ++++ .../ToFront/FrameToFrontAppModal2Test.java | 48 ++++ .../ToFront/FrameToFrontAppModal3Test.java | 48 ++++ .../ToFront/FrameToFrontAppModal4Test.java | 48 ++++ .../ToFront/FrameToFrontAppModal5Test.java | 48 ++++ .../ToFront/FrameToFrontDocModal1Test.java | 48 ++++ .../ToFront/FrameToFrontDocModal2Test.java | 53 +++++ .../Modal/ToFront/FrameToFrontModal1Test.java | 46 ++++ .../Modal/ToFront/FrameToFrontModal2Test.java | 46 ++++ .../Modal/ToFront/FrameToFrontModal3Test.java | 46 ++++ .../Modal/ToFront/FrameToFrontModal4Test.java | 46 ++++ .../Modal/ToFront/FrameToFrontModal5Test.java | 46 ++++ .../ToFront/FrameToFrontModalBlockedTest.java | 207 ++++++++++++++++++ .../ToFront/FrameToFrontModeless1Test.java | 44 ++++ .../ToFront/FrameToFrontModelessTest.java | 98 +++++++++ .../ToFront/FrameToFrontNonModalTest.java | 44 ++++ .../ToFront/FrameToFrontTKModal1Test.java | 48 ++++ .../ToFront/FrameToFrontTKModal2Test.java | 48 ++++ .../ToFront/FrameToFrontTKModal3Test.java | 48 ++++ .../ToFront/FrameToFrontTKModal4Test.java | 48 ++++ .../ToFront/FrameToFrontTKModal5Test.java | 48 ++++ .../java/awt/Modal/helpers/TestDialog.java | 47 +++- .../java/awt/Modal/helpers/TestFrame.java | 43 +++- .../java/awt/Modal/helpers/TestWindow.java | 42 +++- 32 files changed, 1820 insertions(+), 27 deletions(-) create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontAppModalTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontDocModalTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontModalBlockedTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontModalTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontModelessTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontNonModalTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/DialogToFrontTKModalTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal1Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal2Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal3Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal4Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal5Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal1Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal2Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModal1Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModal2Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModal3Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModal4Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModal5Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModalBlockedTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModeless1Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontModelessTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontNonModalTest.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal1Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal2Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal3Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal4Test.java create mode 100644 jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal5Test.java diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontAppModalTest.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontAppModalTest.java new file mode 100644 index 00000000000..41d27d979f3 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontAppModalTest.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontDocModalTest.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontDocModalTest.java new file mode 100644 index 00000000000..65cf9ffc71b --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontDocModalTest.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalBlockedTest.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalBlockedTest.java new file mode 100644 index 00000000000..7912e5c46c6 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalBlockedTest.java @@ -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); + } + } + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalTest.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalTest.java new file mode 100644 index 00000000000..6c20549cf63 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModalTest.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java new file mode 100644 index 00000000000..be5da090994 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModeless1Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontModelessTest.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModelessTest.java new file mode 100644 index 00000000000..080488c0560 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontModelessTest.java @@ -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(); } + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontNonModalTest.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontNonModalTest.java new file mode 100644 index 00000000000..6e6b70f83df --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontNonModalTest.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/DialogToFrontTKModalTest.java b/jdk/test/java/awt/Modal/ToFront/DialogToFrontTKModalTest.java new file mode 100644 index 00000000000..c48eac093ca --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/DialogToFrontTKModalTest.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal1Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal1Test.java new file mode 100644 index 00000000000..0b32758a3ae --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal1Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal2Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal2Test.java new file mode 100644 index 00000000000..7a8e8ebea4e --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal2Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal3Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal3Test.java new file mode 100644 index 00000000000..d57d1e32d02 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal3Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal4Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal4Test.java new file mode 100644 index 00000000000..447a13ec0c7 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal4Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal5Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal5Test.java new file mode 100644 index 00000000000..3165711cddb --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontAppModal5Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal1Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal1Test.java new file mode 100644 index 00000000000..357be00b444 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal1Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal2Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal2Test.java new file mode 100644 index 00000000000..4524afbbe87 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontDocModal2Test.java @@ -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(); + } + } + + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal1Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal1Test.java new file mode 100644 index 00000000000..eb1d4e7dff0 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal1Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal2Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal2Test.java new file mode 100644 index 00000000000..4e1ab89ec66 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal2Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal3Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal3Test.java new file mode 100644 index 00000000000..da6dc06e1c9 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal3Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal4Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal4Test.java new file mode 100644 index 00000000000..e967d4b63fd --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal4Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal5Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal5Test.java new file mode 100644 index 00000000000..ba3ae7d9338 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModal5Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModalBlockedTest.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModalBlockedTest.java new file mode 100644 index 00000000000..2a7e0de9da8 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModalBlockedTest.java @@ -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); + } + } + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModeless1Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModeless1Test.java new file mode 100644 index 00000000000..29be38f5cfa --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModeless1Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontModelessTest.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModelessTest.java new file mode 100644 index 00000000000..03ceb6e022d --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontModelessTest.java @@ -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(); } + } +} + diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontNonModalTest.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontNonModalTest.java new file mode 100644 index 00000000000..5e16f141446 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontNonModalTest.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal1Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal1Test.java new file mode 100644 index 00000000000..528847e7e68 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal1Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal2Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal2Test.java new file mode 100644 index 00000000000..7cd3122d2c8 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal2Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal3Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal3Test.java new file mode 100644 index 00000000000..90eff046b4e --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal3Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal4Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal4Test.java new file mode 100644 index 00000000000..625ced92854 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal4Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal5Test.java b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal5Test.java new file mode 100644 index 00000000000..1e91e9a5488 --- /dev/null +++ b/jdk/test/java/awt/Modal/ToFront/FrameToFrontTKModal5Test.java @@ -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(); + } +} diff --git a/jdk/test/java/awt/Modal/helpers/TestDialog.java b/jdk/test/java/awt/Modal/helpers/TestDialog.java index d547886cddc..1a45154ae0a 100644 --- a/jdk/test/java/awt/Modal/helpers/TestDialog.java +++ b/jdk/test/java/awt/Modal/helpers/TestDialog.java @@ -211,36 +211,63 @@ public class TestDialog extends Dialog implements ActionListener, } 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 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(); - 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); - 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 { diff --git a/jdk/test/java/awt/Modal/helpers/TestFrame.java b/jdk/test/java/awt/Modal/helpers/TestFrame.java index cbe0feac0c6..f7b341281e1 100644 --- a/jdk/test/java/awt/Modal/helpers/TestFrame.java +++ b/jdk/test/java/awt/Modal/helpers/TestFrame.java @@ -203,19 +203,37 @@ public class TestFrame extends Frame implements ActionListener, } 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 class TestFrame extends Frame implements ActionListener, } 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(); - 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 { diff --git a/jdk/test/java/awt/Modal/helpers/TestWindow.java b/jdk/test/java/awt/Modal/helpers/TestWindow.java index 4e7cdb6fe79..a81746b180f 100644 --- a/jdk/test/java/awt/Modal/helpers/TestWindow.java +++ b/jdk/test/java/awt/Modal/helpers/TestWindow.java @@ -210,30 +210,54 @@ public class TestWindow extends Window implements ActionListener, } 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 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(); - 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(); - 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,