8044429: move awt automated tests for AWT_Modality to OpenJDK repository
Reviewed-by: pchelko
Contributed-by: Alexander Stepanov <alexander.v.stepanov@oracle.com>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ApplicationExcludeDialogFileTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * 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 8047179 8044429
+ * @summary Check whether a FileDialog blocks an application modality excluded Dialog
+ * (it shouldn't). Checks also whether setting a parent dialog to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestWindow
+ * @run main ApplicationExcludeDialogFileTest
+ */
+
+public class ApplicationExcludeDialogFileTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeDialogTest test = new ExcludeDialogTest(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE,
+ ExcludeDialogTest.DialogToShow.FILE_DIALOG);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ApplicationExcludeDialogPageSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a pageDialog blocks an application modality excluded Dialog
+ * (it shouldn't). Checks also whether setting a parent dialog to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestWindow
+ * @run main ApplicationExcludeDialogPageSetupTest
+ */
+
+public class ApplicationExcludeDialogPageSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeDialogTest test = new ExcludeDialogTest(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE,
+ ExcludeDialogTest.DialogToShow.PAGE_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ApplicationExcludeDialogPrintSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,49 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a printDialog blocks an application modality excluded Dialog
+ * (it shouldn't). Checks also whether setting a parent dialog to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestWindow
+ * @run main ApplicationExcludeDialogPrintSetupTest
+ */
+
+public class ApplicationExcludeDialogPrintSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeDialogTest test = new ExcludeDialogTest(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE,
+ ExcludeDialogTest.DialogToShow.PRINT_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ApplicationExcludeFrameFileTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 8047179 8044429
+ * @summary Check whether a FileDialog blocks an application modality excluded Frame
+ * (it shouldn't). Checks also whether setting a parent frame to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ApplicationExcludeFrameFileTest
+ */
+
+public class ApplicationExcludeFrameFileTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeFrameTest test = new ExcludeFrameTest(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE,
+ ExcludeFrameTest.DialogToShow.FILE_DIALOG);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ApplicationExcludeFramePageSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a pageDialog blocks an application modality excluded Frame
+ * (it shouldn't). Checks also whether setting a parent frame to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ApplicationExcludeFramePageSetupTest
+ */
+
+public class ApplicationExcludeFramePageSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeFrameTest test = new ExcludeFrameTest(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE,
+ ExcludeFrameTest.DialogToShow.PAGE_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ApplicationExcludeFramePrintSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a printDialog blocks an application modality excluded Frame
+ * (it shouldn't). Checks also whether setting a parent frame to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ApplicationExcludeFramePrintSetupTest
+ */
+
+public class ApplicationExcludeFramePrintSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeFrameTest test = new ExcludeFrameTest(
+ Dialog.ModalExclusionType.APPLICATION_EXCLUDE,
+ ExcludeFrameTest.DialogToShow.PRINT_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ExcludeDialogTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,199 @@
+/*
+ * 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 java.awt.event.*;
+import java.awt.print.*;
+
+import static jdk.testlibrary.Asserts.*;
+
+
+public class ExcludeDialogTest implements AWTEventListener {
+
+ class ParentDialog extends TestDialog {
+
+ public ParentDialog() {
+ super((Frame) null);
+ }
+
+ @Override
+ public void doOpenAction() {
+ if (window != null) {
+ window.setVisible(true);
+ }
+ }
+ }
+
+ class CustomDialog extends TestDialog {
+
+ public CustomDialog(Dialog dialog) {
+ super(dialog);
+ }
+
+ @Override
+ public void doOpenAction() {
+
+ switch (childDialogType) {
+ case PRINT_SETUP:
+ PrinterJob.getPrinterJob().printDialog();
+ break;
+ case PAGE_SETUP:
+ PrinterJob.getPrinterJob().pageDialog(new PageFormat());
+ break;
+ case FILE_DIALOG:
+ fileDialog = new FileDialog((Dialog) null);
+ fileDialog.setLocation(20, 200);
+ fileDialog.setVisible(true);
+ break;
+ }
+ }
+ }
+
+ class CustomWindow extends TestWindow {
+
+ public CustomWindow(Dialog parent) {
+ super(parent);
+ }
+
+ @Override
+ public void doOpenAction() {
+ if (dialog != null) {
+ dialog.setVisible(true);
+ }
+ }
+ }
+
+ private TestWindow window;
+ private TestDialog dialog;
+ private ParentDialog parent;
+ private FileDialog fileDialog;
+
+ private static final int delay = 1000;
+
+ private final ExtendedRobot robot;
+
+ private boolean windowAppeared = false;
+ private final Object windowLock;
+
+ private final Dialog.ModalExclusionType exclusionType;
+
+ public enum DialogToShow {PAGE_SETUP, PRINT_SETUP, FILE_DIALOG};
+ private DialogToShow childDialogType;
+ private String type;
+
+ @Override
+ public void eventDispatched(AWTEvent event) {
+ if (event.getID() == WindowEvent.WINDOW_OPENED) {
+ windowAppeared = true;
+ synchronized (windowLock) {
+ windowLock.notifyAll();
+ }
+ }
+ }
+
+ ExcludeDialogTest(Dialog.ModalExclusionType exclType,
+ DialogToShow dialogType) throws Exception {
+ exclusionType = exclType;
+ childDialogType = dialogType;
+
+ type = "File";
+ if (dialogType == DialogToShow.PAGE_SETUP) {
+ type = "Page setup";
+ } else if (dialogType == DialogToShow.PRINT_SETUP) {
+ type = "Print setup";
+ }
+
+ robot = new ExtendedRobot();
+ windowLock = new Object();
+ EventQueue.invokeAndWait( this::createGUI );
+ }
+
+ private void createGUI() {
+ parent = new ParentDialog();
+ parent.setLocation(20, 20);
+ parent.setModalExclusionType(exclusionType);
+ dialog = new CustomDialog(parent);
+ dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
+ dialog.setLocation(220, 20);
+ window = new CustomWindow(parent);
+ window.setLocation(420, 20);
+ Toolkit.getDefaultToolkit().addAWTEventListener(
+ ExcludeDialogTest.this, AWTEvent.WINDOW_EVENT_MASK);
+ parent.setVisible(true);
+ }
+
+ private void closeAll() {
+ if (dialog != null) { dialog.dispose(); }
+ if (parent != null) { parent.dispose(); }
+ if (window != null) { window.dispose(); }
+ if (fileDialog != null) {
+ fileDialog.dispose();
+ } else {
+ robot.type(KeyEvent.VK_ESCAPE);
+ }
+ }
+
+ public void doTest() throws Exception {
+
+ robot.waitForIdle(delay);
+
+ parent.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ window.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ dialog.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ if (! windowAppeared) {
+ synchronized (windowLock) {
+ try {
+ windowLock.wait(10 * delay);
+ } catch (InterruptedException e) {}
+ }
+ }
+
+ assertTrue(windowAppeared, type + " dialog didn't appear");
+
+ parent.toFront();
+ robot.waitForIdle(delay);
+
+ String excl = "";
+ if (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
+ excl = "Application";
+ } else if (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE) {
+ excl = "Toolkit";
+ }
+
+ parent.checkUnblockedDialog(robot, excl + " modal " + type +
+ " dialog should not block this modal excluded Dialog");
+ dialog.checkUnblockedDialog(robot, excl + " modal " + type +
+ " dialog should not block this modal excluded app. modal Dialog");
+ window.checkUnblockedWindow(robot, excl + " modal " + type +
+ " dialog should not block this modal excluded Window");
+
+ robot.waitForIdle();
+ closeAll();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ExcludeFrameTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,192 @@
+/*
+ * 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 java.awt.event.*;
+import java.awt.print.*;
+
+import static jdk.testlibrary.Asserts.*;
+
+
+public class ExcludeFrameTest implements AWTEventListener {
+ class CustomFrame extends TestFrame {
+
+ @Override
+ public void doOpenAction() {
+ if (window != null) {
+ window.setVisible(true);
+ }
+ }
+ }
+
+ class CustomDialog extends TestDialog {
+
+ public CustomDialog(Frame frame) {
+ super(frame);
+ }
+
+ @Override
+ public void doOpenAction() {
+ switch (childDialogType) {
+ case PRINT_SETUP:
+ PrinterJob.getPrinterJob().printDialog();
+ break;
+ case PAGE_SETUP:
+ PrinterJob.getPrinterJob().pageDialog(new PageFormat());
+ break;
+ case FILE_DIALOG:
+ fileDialog = new FileDialog((Frame) null);
+ fileDialog.setLocation(20, 200);
+ fileDialog.setVisible(true);
+ break;
+ }
+ }
+ }
+
+ class CustomWindow extends TestWindow {
+
+ public CustomWindow(Frame frame) {
+ super(frame);
+ }
+
+ @Override
+ public void doOpenAction() {
+ if (dialog != null) {
+ dialog.setVisible(true);
+ }
+ }
+ }
+
+ private TestDialog dialog;
+ private TestFrame frame;
+ private TestWindow window;
+ private FileDialog fileDialog;
+
+ private boolean windowAppeared = false;
+ private final Object windowLock;
+
+ private static final int delay = 1000;
+ private final ExtendedRobot robot;
+
+ private final Dialog.ModalExclusionType exclusionType;
+
+ public enum DialogToShow {PAGE_SETUP, PRINT_SETUP, FILE_DIALOG};
+ private final DialogToShow childDialogType;
+ private String type;
+
+ public ExcludeFrameTest(Dialog.ModalExclusionType exclType,
+ DialogToShow dialogType) throws Exception {
+ exclusionType = exclType;
+ childDialogType = dialogType;
+
+ type = "File";
+ if (dialogType == DialogToShow.PAGE_SETUP) {
+ type = "Page setup";
+ } else if (dialogType == DialogToShow.PRINT_SETUP) {
+ type = "Print setup";
+ }
+
+ windowLock = new Object();
+ robot = new ExtendedRobot();
+ EventQueue.invokeAndWait( this::createGUI );
+ }
+
+ @Override
+ public void eventDispatched(AWTEvent event) {
+ if (event.getID() == WindowEvent.WINDOW_OPENED) {
+ windowAppeared = true;
+ synchronized (windowLock) {
+ windowLock.notifyAll();
+ }
+ }
+ }
+
+ private void createGUI() {
+ frame = new CustomFrame();
+ frame.setLocation(20, 20);
+ frame.setModalExclusionType(exclusionType);
+ dialog = new CustomDialog(frame);
+ dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
+ dialog.setLocation(220, 20);
+ window = new CustomWindow(frame);
+ window.setLocation(420, 20);
+ Toolkit.getDefaultToolkit().addAWTEventListener(
+ ExcludeFrameTest.this, AWTEvent.WINDOW_EVENT_MASK);
+ frame.setVisible(true);
+ }
+
+ private void closeAll() {
+ if (dialog != null) { dialog.dispose(); }
+ if (frame != null) { frame.dispose(); }
+ if (window != null) { window.dispose(); }
+ if (fileDialog != null) {
+ fileDialog.dispose();
+ } else {
+ robot.type(KeyEvent.VK_ESCAPE);
+ }
+ }
+
+ public void doTest() throws Exception {
+
+ robot.waitForIdle(delay);
+
+ frame.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ window.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ dialog.clickOpenButton(robot);
+ robot.waitForIdle(delay);
+
+ if (! windowAppeared) {
+ synchronized (windowLock) {
+ try {
+ windowLock.wait(10 * delay);
+ } catch (InterruptedException e) {}
+ }
+ }
+
+ assertTrue(windowAppeared, type + " dialog didn't appear");
+
+ frame.toFront();
+ robot.waitForIdle(delay);
+
+ String excl = "";
+ if (exclusionType == Dialog.ModalExclusionType.APPLICATION_EXCLUDE) {
+ excl = "Application";
+ } else if (exclusionType == Dialog.ModalExclusionType.TOOLKIT_EXCLUDE) {
+ excl = "Toolkit";
+ }
+
+ frame.checkUnblockedFrame(robot, excl + " modal " + type +
+ " dialog should not block this modal excluded Frame");
+ dialog.checkUnblockedDialog(robot, excl + " modal " + type +
+ " dialog should not block this modal excluded app. modal Dialog");
+ window.checkUnblockedWindow(robot, excl + " modal " + type +
+ " dialog should not block this modal excluded Window");
+
+ robot.waitForIdle();
+ closeAll();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ToolkitExcludeDialogFileTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 8047179 8044429
+ * @summary Check whether a FileDialog blocks a toolkit modality excluded Dialog
+ * (it shouldn't). Checks also whether setting a parent dialog to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ToolkitExcludeDialogFileTest
+ */
+
+public class ToolkitExcludeDialogFileTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeDialogTest test = new ExcludeDialogTest(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE,
+ ExcludeDialogTest.DialogToShow.FILE_DIALOG);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ToolkitExcludeDialogPageSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a pageDialog blocks a toolkit modality excluded Dialog
+ * (it shouldn't). Checks also whether setting a parent dialog to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ToolkitExcludeDialogPageSetupTest
+ */
+
+public class ToolkitExcludeDialogPageSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeDialogTest test = new ExcludeDialogTest(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE,
+ ExcludeDialogTest.DialogToShow.PAGE_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ToolkitExcludeDialogPrintSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a printDialog blocks a toolkit modality excluded Dialog
+ * (it shouldn't). Checks also whether setting a parent dialog to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ToolkitExcludeDialogPrintSetupTest
+ */
+
+public class ToolkitExcludeDialogPrintSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeDialogTest test = new ExcludeDialogTest(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE,
+ ExcludeDialogTest.DialogToShow.PRINT_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ToolkitExcludeFrameFileTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 8047179 8044429
+ * @summary Check whether a FileDialog blocks a toolkit modality excluded Frame
+ * (it shouldn't). Checks also whether setting a parent frame to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ToolkitExcludeFrameFileTest
+ */
+
+public class ToolkitExcludeFrameFileTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeFrameTest test = new ExcludeFrameTest(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE,
+ ExcludeFrameTest.DialogToShow.FILE_DIALOG);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ToolkitExcludeFramePageSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a pageDialog blocks a toolkit modality excluded Frame
+ * (it shouldn't). Checks also whether setting a parent frame to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ToolkitExcludeFramePageSetupTest
+ */
+
+public class ToolkitExcludeFramePageSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeFrameTest test = new ExcludeFrameTest(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE,
+ ExcludeFrameTest.DialogToShow.PAGE_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/ModalExclusionTests/ToolkitExcludeFramePrintSetupTest.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,50 @@
+/*
+ * 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 7125054 8044429
+ * @summary Check whether a printDialog blocks a toolkit modality excluded Frame
+ * (it shouldn't). Checks also whether setting a parent frame to be
+ * modality excluded excludes its children from being blocked too.
+ *
+ * @library ../helpers ../../../../lib/testlibrary/
+ * @build ExtendedRobot
+ * @build Flag
+ * @build TestDialog
+ * @build TestFrame
+ * @build TestWindow
+ * @run main ToolkitExcludeFramePrintSetupTest
+ */
+
+public class ToolkitExcludeFramePrintSetupTest {
+
+ public static void main(String[] args) throws Exception {
+ ExcludeFrameTest test = new ExcludeFrameTest(
+ Dialog.ModalExclusionType.TOOLKIT_EXCLUDE,
+ ExcludeFrameTest.DialogToShow.PRINT_SETUP);
+ test.doTest();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/helpers/Flag.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,84 @@
+/*
+ * 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.Component;
+import java.awt.IllegalComponentStateException;
+
+public class Flag {
+
+ public static final int ATTEMPTS = 50;
+
+ private volatile boolean flag;
+ private final Object monitor = new Object();
+ private final long delay;
+
+ public Flag() {
+ this.delay = 500;
+ }
+
+ public void reset() {
+ flag = false;
+ }
+
+ public void flagTriggered() {
+ synchronized (monitor) {
+ flag = true;
+ monitor.notifyAll();
+ }
+ }
+
+ public boolean flag() {
+ return flag;
+ }
+
+ public void waitForFlagTriggered() throws InterruptedException {
+ waitForFlagTriggered(delay, ATTEMPTS);
+ }
+
+ public void waitForFlagTriggered(int attempts) throws InterruptedException {
+ waitForFlagTriggered(delay, attempts);
+ }
+
+ public void waitForFlagTriggered(long delay) throws InterruptedException {
+ waitForFlagTriggered(delay, ATTEMPTS);
+ }
+
+ private void waitForFlagTriggered(long delay, int attempts) throws InterruptedException {
+ int a = 0;
+ synchronized (monitor) {
+ while (!flag && (a++ < attempts)) {
+ monitor.wait(delay);
+ }
+ }
+ }
+
+ public static void waitTillShown(final Component comp) throws InterruptedException {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ comp.getLocationOnScreen();
+ break;
+ } catch (IllegalComponentStateException e) {}
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/helpers/TestDialog.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,366 @@
+/*
+ * 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 java.awt.event.*;
+
+import static jdk.testlibrary.Asserts.*;
+
+
+
+public class TestDialog extends Dialog implements ActionListener,
+ FocusListener, WindowFocusListener, WindowListener {
+
+ public Button closeButton, openButton, dummyButton;
+
+ public Flag closeClicked, openClicked, dummyClicked;
+ public Flag closeGained, openGained, dummyGained;
+ public Flag closeLost, openLost, dummyLost;
+ public Flag focusGained, focusLost;
+ public Flag activated;
+
+ public Panel topPanel;
+
+ public static int delay = 500;
+ public static int keyDelay = 100;
+
+ public TestDialog(Frame frame) {
+ super(frame);
+ initializeGUI();
+ }
+
+ public TestDialog(Dialog dialog) {
+ super(dialog);
+ initializeGUI();
+ }
+
+ public void resetStatus() {
+ activated.reset();
+ focusGained.reset();
+ closeGained.reset();
+ openGained.reset();
+ closeClicked.reset();
+ openClicked.reset();
+ }
+
+ private void initFlags() {
+ closeClicked = new Flag();
+ openClicked = new Flag();
+ dummyClicked = new Flag();
+ closeGained = new Flag();
+ openGained = new Flag();
+ dummyGained = new Flag();
+ closeLost = new Flag();
+ openLost = new Flag();
+ dummyLost = new Flag();
+ focusGained = new Flag();
+ focusLost = new Flag();
+ activated = new Flag();
+ }
+
+ private void initializeGUI() {
+
+ initFlags();
+ this.setTitle("Dialog");
+
+ this.addWindowFocusListener(this);
+ this.addWindowListener(this);
+
+ this.setLayout(new GridLayout(3, 1));
+
+ topPanel = new Panel();
+ topPanel.setFocusable(false);
+ this.add(topPanel);
+
+ Panel p = new Panel();
+ p.setLayout(new GridLayout(1, 3));
+
+ closeButton = new Button("Close");
+ closeButton.addActionListener(this);
+ closeButton.addFocusListener(this);
+
+ openButton = new Button("Open");
+ openButton.addActionListener(this);
+ openButton.addFocusListener(this);
+
+ dummyButton = new Button("Dummy");
+ dummyButton.addActionListener(this);
+ dummyButton.addFocusListener(this);
+
+ p.add(closeButton);
+ p.add(openButton);
+ p.add(dummyButton);
+
+ this.add(p);
+
+ Panel bottomPanel = new Panel();
+ bottomPanel.setFocusable(false);
+ this.add(bottomPanel);
+
+ setSize(150, 150);
+ }
+
+ public void doOpenAction() {}
+ public void doCloseAction() {}
+ public void doDummyAction() {}
+
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeClicked.flagTriggered();
+ doCloseAction();
+ } else if (openButton.equals(event.getSource())) {
+ openClicked.flagTriggered();
+ doOpenAction();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyClicked.flagTriggered();
+ doDummyAction();
+ }
+ }
+
+ @Override
+ public void focusGained(FocusEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeGained.flagTriggered();
+ } else if (openButton.equals(event.getSource())) {
+ openGained.flagTriggered();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyGained.flagTriggered();
+ }
+ }
+
+ @Override
+ public void focusLost(FocusEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeLost.flagTriggered();
+ } else if (openButton.equals(event.getSource())) {
+ openLost.flagTriggered();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyLost.flagTriggered();
+ }
+ }
+
+ @Override
+ public void windowGainedFocus(WindowEvent event) {
+ focusGained.flagTriggered();
+ }
+
+ @Override
+ public void windowLostFocus(WindowEvent event) {
+ focusLost.flagTriggered();
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ activated.flagTriggered();
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ assertTrue(false, "user closed window");
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {}
+ @Override
+ public void windowDeiconified(WindowEvent e) {}
+ @Override
+ public void windowIconified(WindowEvent e) {}
+ @Override
+ public void windowOpened(WindowEvent e) {}
+
+ public void clickButton(Button b, ExtendedRobot robot) {
+
+ try {
+ Flag.waitTillShown(b);
+ } catch (InterruptedException e) {}
+
+ if ((closeButton.equals(b) || openButton.equals(b) ||
+ dummyButton.equals(b)) && robot != null) {
+ robot.mouseMove((int) b.getLocationOnScreen().x + b.getSize().width / 2,
+ (int) b.getLocationOnScreen().y + b.getSize().height / 2);
+ robot.delay(delay);
+ robot.click();
+ robot.delay(delay);
+ }
+ }
+
+ public void clickOpenButton(ExtendedRobot robot) throws Exception {
+ openClicked.reset();
+ clickButton(openButton, robot);
+
+ openClicked.waitForFlagTriggered();
+ assertTrue(openClicked.flag(),
+ "clicking the dialog Open button did not trigger an action");
+ }
+
+ public void clickCloseButton(ExtendedRobot robot) throws Exception {
+ closeClicked.reset();
+ clickButton(closeButton, robot);
+
+ closeClicked.waitForFlagTriggered();
+ assertTrue(closeClicked.flag(),
+ "clicking the dialog Close button did not trigger an action");
+ }
+
+ public void clickDummyButton(ExtendedRobot robot) throws Exception {
+ clickDummyButton(robot, Flag.ATTEMPTS);
+ }
+
+ public void clickDummyButton(ExtendedRobot robot, int attempts) throws Exception {
+ dummyClicked.reset();
+ clickButton(dummyButton, robot);
+
+ dummyClicked.waitForFlagTriggered(attempts);
+ assertTrue(dummyClicked.flag(),
+ "clicking the dialog Dummy button did not trigger an action");
+ }
+
+ private void clickInside(ExtendedRobot robot) throws Exception {
+
+ try {
+ Flag.waitTillShown(topPanel);
+ } catch (InterruptedException e) {}
+
+ if (robot != null) {
+ robot.mouseMove((int) topPanel.getLocationOnScreen().x + topPanel.getSize().width / 2,
+ (int) topPanel.getLocationOnScreen().y + topPanel.getSize().height / 2);
+ robot.delay(delay);
+ robot.click();
+ robot.delay(delay);
+ }
+ }
+
+ public void transferFocusToDialog(ExtendedRobot robot,
+ String message,
+ Button b) throws Exception {
+ focusGained.reset();
+ clickInside(robot);
+ focusGained.waitForFlagTriggered();
+ assertTrue(focusGained.flag(),
+ "clicking inside the Dialog did not make it focused. " + message);
+
+ robot.waitForIdle(delay);
+ if (b != null) {
+ assertTrue(b.hasFocus(), "button " + b.getLabel() +
+ " did not gain focus when Dialog brought to top");
+ }
+ }
+
+ public void transferFocusToBlockedDialog(ExtendedRobot robot,
+ String message,
+ Button b) throws Exception {
+ focusGained.reset();
+ clickInside(robot);
+ robot.waitForIdle(delay);
+
+ assertFalse(focusGained.flag(),
+ "clicking inside a blocked Dialog made it focused. " + message);
+
+ robot.waitForIdle(delay);
+ if (b != null) {
+ assertFalse(b.hasFocus(),
+ "button " + b.getLabel() + " present in a blocked dialog gained focus");
+ }
+ }
+
+ public void checkBlockedDialog(ExtendedRobot robot,
+ String message) throws Exception {
+ dummyGained.reset();
+ dummyClicked.reset();
+ focusGained.reset();
+
+ clickButton(dummyButton, robot);
+
+ robot.waitForIdle(delay);
+
+ assertFalse(dummyClicked.flag(),
+ "DummyButton on blocked Dialog triggered action when clicked. " + message);
+
+ assertFalse(dummyGained.flag(),
+ "DummyButton on blocked Dialog gained focus when clicked. " + message);
+
+ assertFalse(focusGained.flag(),
+ "A blocked Dialog gained focus when component clicked. " + message);
+ }
+
+ public void checkUnblockedDialog(ExtendedRobot robot,
+ String message) throws Exception {
+ dummyGained.reset();
+ dummyClicked.reset();
+ clickButton(dummyButton, robot);
+
+ dummyGained.waitForFlagTriggered();
+ assertTrue(dummyGained.flag(),
+ "DummyButton on Dialog did not gain focus when clicked. " + message);
+
+ dummyClicked.waitForFlagTriggered();
+ assertTrue(dummyClicked.flag(),
+ "DummyButton on Dialog did not trigger action when clicked. " + message);
+
+ closeGained.reset();
+ robot.type(KeyEvent.VK_TAB);
+
+ closeGained.waitForFlagTriggered();
+ assertTrue(closeGained.flag(),
+ "Tab navigation on Dialog did not happen properly. First " +
+ "button did not gain focus. " + message);
+ }
+
+ public void checkCloseButtonFocusGained() {
+ checkCloseButtonFocusGained(Flag.ATTEMPTS);
+ }
+
+ public void checkCloseButtonFocusGained(int attempts) {
+ try {
+ closeGained.waitForFlagTriggered(attempts);
+ } catch (InterruptedException e) {}
+ assertTrue(closeGained.flag(),
+ "dialog Close button did not gain focus");
+ }
+
+ public void checkOpenButtonFocusGained() {
+ try {
+ openGained.waitForFlagTriggered();
+ } catch (InterruptedException e) {}
+ assertTrue(openGained.flag(),
+ "dialog Open button did not gain focus");
+ }
+
+ public void checkOpenButtonFocusLost() {
+ checkOpenButtonFocusLost(Flag.ATTEMPTS);
+ }
+
+ public void checkOpenButtonFocusLost(int attempts) {
+ try {
+ openLost.waitForFlagTriggered(attempts);
+ } catch (InterruptedException e) {}
+ assertTrue(openLost.flag(),
+ "dialog Open button did not lose focus");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/helpers/TestFrame.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,369 @@
+/*
+ * 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 java.awt.event.*;
+
+import static jdk.testlibrary.Asserts.*;
+
+
+
+public class TestFrame extends Frame implements ActionListener,
+ FocusListener, WindowFocusListener, WindowListener {
+
+ public Button closeButton, openButton, dummyButton;
+
+ public Flag closeClicked, openClicked, dummyClicked;
+ public Flag closeGained, openGained, dummyGained;
+ public Flag closeLost, openLost, dummyLost;
+ public Flag focusGained, focusLost;
+ public Flag activated;
+
+ public Panel topPanel;
+
+ public static int delay = 500;
+ public static int keyDelay = 100;
+
+ public TestFrame() {
+ super();
+ initializeGUI();
+ }
+
+ private void initFlags() {
+ closeClicked = new Flag();
+ openClicked = new Flag();
+ dummyClicked = new Flag();
+ closeGained = new Flag();
+ openGained = new Flag();
+ dummyGained = new Flag();
+ closeLost = new Flag();
+ openLost = new Flag();
+ dummyLost = new Flag();
+ focusGained = new Flag();
+ focusLost = new Flag();
+ activated = new Flag();
+ }
+
+ public void resetStatus() {
+ activated.reset();
+ focusGained.reset();
+ closeGained.reset();
+ openGained.reset();
+ closeClicked.reset();
+ openClicked.reset();
+ }
+
+ private void initializeGUI() {
+
+ initFlags();
+ this.setTitle("Frame");
+
+ this.addWindowFocusListener(this);
+ this.addWindowListener(this);
+
+ this.setLayout(new GridLayout(3, 1));
+
+ topPanel = new Panel();
+ topPanel.setFocusable(false);
+ this.add(topPanel);
+
+ Panel p = new Panel();
+ p.setLayout(new GridLayout(1, 3));
+
+ closeButton = new Button("Close");
+ closeButton.addActionListener(this);
+ closeButton.addFocusListener(this);
+
+ openButton = new Button("Open");
+ openButton.addActionListener(this);
+ openButton.addFocusListener(this);
+
+ dummyButton = new Button("Dummy");
+ dummyButton.addActionListener(this);
+ dummyButton.addFocusListener(this);
+
+ p.add(closeButton);
+ p.add(openButton);
+ p.add(dummyButton);
+
+ this.add(p);
+
+ Panel bottomPanel = new Panel();
+ bottomPanel.setFocusable(false);
+ this.add(bottomPanel);
+
+ setSize(150, 150);
+ }
+
+ public void doOpenAction() {}
+ public void doCloseAction() {}
+ public void doDummyAction() {}
+
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeClicked.flagTriggered();
+ doCloseAction();
+ } else if (openButton.equals(event.getSource())) {
+ openClicked.flagTriggered();
+ doOpenAction();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyClicked.flagTriggered();
+ doDummyAction();
+ }
+ }
+
+ @Override
+ public void focusGained(FocusEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeGained.flagTriggered();
+ } else if (openButton.equals(event.getSource())) {
+ openGained.flagTriggered();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyGained.flagTriggered();
+ }
+ }
+
+ @Override
+ public void focusLost(FocusEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeLost.flagTriggered();
+ } else if (openButton.equals(event.getSource())) {
+ openLost.flagTriggered();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyLost.flagTriggered();
+ }
+ }
+
+ @Override
+ public void windowGainedFocus(WindowEvent event) {
+ focusGained.flagTriggered();
+ }
+
+ @Override
+ public void windowLostFocus(WindowEvent event) {
+ focusLost.flagTriggered();
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ activated.flagTriggered();
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {}
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ assertTrue(false, "user closed window");
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {}
+ @Override
+ public void windowDeiconified(WindowEvent e) {}
+ @Override
+ public void windowIconified(WindowEvent e) {}
+ @Override
+ public void windowOpened(WindowEvent e) {}
+
+ public void clickButton(Button b, ExtendedRobot robot) {
+ try {
+ Flag.waitTillShown(b);
+ } catch (InterruptedException e) {}
+
+ if ((closeButton.equals(b) || openButton.equals(b) ||
+ dummyButton.equals(b)) && robot != null) {
+ robot.mouseMove((int) b.getLocationOnScreen().x + b.getSize().width / 2,
+ (int) b.getLocationOnScreen().y + b.getSize().height / 2);
+ robot.delay(delay);
+ robot.click();
+ robot.delay(delay);
+ }
+ }
+
+ public void clickOpenButton(ExtendedRobot robot) throws Exception {
+ openClicked.reset();
+ clickButton(openButton, robot);
+ openClicked.waitForFlagTriggered();
+ assertTrue(openClicked.flag(),
+ "clicking the frame Open button did not trigger an action");
+ }
+
+ public void clickCloseButton(ExtendedRobot robot) throws Exception {
+ closeClicked.reset();
+ clickButton(closeButton, robot);
+ closeClicked.waitForFlagTriggered();
+ assertTrue(closeClicked.flag(),
+ "clicking the frame Close button did not trigger an action");
+ }
+
+ public void clickDummyButton(ExtendedRobot robot) throws Exception {
+ clickDummyButton(robot, Flag.ATTEMPTS);
+ }
+
+ public void clickDummyButton(ExtendedRobot robot,
+ int amountOfAttempts) throws Exception {
+ dummyClicked.reset();
+ clickButton(dummyButton, robot);
+
+ dummyClicked.waitForFlagTriggered();
+ assertTrue(dummyClicked.flag(),
+ "clicking the frame Dummy button did not trigger an action");
+ }
+
+ public void clickInside(ExtendedRobot robot) throws Exception {
+ try {
+ Flag.waitTillShown(topPanel);
+ } catch (InterruptedException e) {}
+
+ if (robot != null) {
+ robot.mouseMove((int) topPanel.getLocationOnScreen().x + topPanel.getSize().width / 2,
+ (int) topPanel.getLocationOnScreen().y + topPanel.getSize().height / 2);
+ robot.delay(delay);
+ robot.click();
+ robot.delay(delay);
+ }
+ }
+
+ public void transferFocusToFrame(ExtendedRobot robot,
+ String message,
+ Button b) throws Exception {
+ focusGained.reset();
+ clickInside(robot);
+
+ focusGained.waitForFlagTriggered();
+ assertTrue(focusGained.flag(),
+ "Clicking inside the Frame did not make it focused. " + message);
+
+ if (b != null) {
+ assertTrue(b.hasFocus(), "Button " + b.getLabel() +
+ " did not gain focus when Frame brought to top");
+ }
+ }
+
+ public void transferFocusToBlockedFrame(ExtendedRobot robot,
+ String message,
+ Button b) throws Exception {
+ focusGained.reset();
+ clickInside(robot);
+
+ robot.waitForIdle(delay);
+
+ assertFalse(focusGained.flag(),
+ "Clicking inside a blocked Frame made it focused. " + message);
+
+ robot.waitForIdle(delay);
+ if (b != null) {
+ assertFalse(b.hasFocus(), "Button " + b.getLabel() +
+ " present in a blocked frame gained focus");
+ }
+ }
+
+ public void checkBlockedFrame(
+ ExtendedRobot robot, String message) throws Exception {
+
+ dummyGained.reset();
+ dummyClicked.reset();
+ focusGained.reset();
+
+ clickButton(dummyButton, robot);
+
+ robot.waitForIdle(delay);
+
+ assertFalse(dummyClicked.flag(),
+ "DummyButton on blocked Window triggered action when clicked. " + message);
+
+ assertFalse(dummyGained.flag(),
+ "DummyButton on blocked Window gained focus when clicked. " + message);
+
+ assertFalse(focusGained.flag(),
+ "A blocked Dialog gained focus when component clicked. " + message);
+ }
+
+ public void checkUnblockedFrame(ExtendedRobot robot,
+ String message) throws Exception {
+ dummyGained.reset();
+ dummyClicked.reset();
+ clickButton(dummyButton, robot);
+
+ dummyGained.waitForFlagTriggered();
+ assertTrue(dummyGained.flag(),
+ "DummyButton on Frame did not gain focus on clicking. " + message);
+
+ dummyClicked.waitForFlagTriggered();
+ assertTrue(dummyClicked.flag(),
+ "DummyButton on Frame did not trigger action on clicking. " + message);
+
+ closeGained.reset();
+ robot.type(KeyEvent.VK_TAB);
+
+ closeGained.waitForFlagTriggered();
+ assertTrue(closeGained.flag(),
+ "FAIL: Tab navigation did not happen properly on Frame. First " +
+ "button did not gain focus on tab press. " + message);
+ }
+
+ public void checkCloseButtonFocusGained() {
+ checkCloseButtonFocusGained(Flag.ATTEMPTS);
+ }
+
+ public void checkCloseButtonFocusGained(int attempts) {
+
+ try {
+ closeGained.waitForFlagTriggered(attempts);
+ } catch (InterruptedException e) {}
+
+ if (closeGained.flag()) {
+ Component focusOwner =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+ assertTrue(closeButton.equals(focusOwner),
+ "close button gained focus, but it is not the current focus owner");
+ } else {
+ assertTrue(false, "frame Close button did not gain focus");
+ }
+ }
+
+ public void checkOpenButtonFocusGained() {
+ try {
+ openGained.waitForFlagTriggered();
+ } catch (InterruptedException e) {}
+
+ if (openGained.flag()) {
+ Component focusOwner =
+ KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
+ assertTrue(openButton.equals(focusOwner),
+ "open button gained focus, but it is not the current focus owner");
+ } else {
+ assertTrue(false, "frame Open button did not gain focus");
+ }
+ }
+
+ public void checkOpenButtonFocusLost() {
+ try {
+ openLost.waitForFlagTriggered();
+ } catch (InterruptedException e) {}
+
+ assertTrue(openLost.flag(), "frame Open button did not lose focus");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Modal/helpers/TestWindow.java Thu Jun 19 12:44:41 2014 +0400
@@ -0,0 +1,333 @@
+/*
+ * 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 java.awt.event.*;
+
+import static jdk.testlibrary.Asserts.*;
+
+
+
+public class TestWindow extends Window implements ActionListener,
+ FocusListener, WindowFocusListener, WindowListener {
+
+ public Button closeButton, openButton, dummyButton;
+
+ public Flag closeClicked, openClicked, dummyClicked;
+ public Flag closeGained, openGained, dummyGained;
+ public Flag closeLost, openLost, dummyLost;
+ public Flag focusGained, focusLost;
+ public Flag activated;
+
+ public static int delay = 500;
+ public static int keyDelay = 100;
+
+ public TestWindow(Frame owner) {
+ super(owner);
+ initializeGUI();
+ }
+
+ public TestWindow(Window window) {
+ super(window);
+ initializeGUI();
+ }
+
+ public void resetStatus() {
+ activated.reset();
+ focusGained.reset();
+ closeGained.reset();
+ openGained.reset();
+ closeClicked.reset();
+ openClicked.reset();
+ }
+
+ private void initFlags() {
+ closeClicked = new Flag();
+ openClicked = new Flag();
+ dummyClicked = new Flag();
+ closeGained = new Flag();
+ openGained = new Flag();
+ dummyGained = new Flag();
+ closeLost = new Flag();
+ openLost = new Flag();
+ dummyLost = new Flag();
+ focusGained = new Flag();
+ focusLost = new Flag();
+ activated = new Flag();
+ }
+
+ private void initializeGUI() {
+
+ initFlags();
+
+ this.addWindowFocusListener(this);
+ this.addWindowListener(this);
+
+ this.setLayout(new GridLayout(3, 1));
+
+ Panel topPanel;
+ topPanel = new Panel();
+ topPanel.setFocusable(false);
+ this.add(topPanel);
+
+ Panel p = new Panel();
+ p.setLayout(new GridLayout(1, 3));
+
+ closeButton = new Button("Close");
+ closeButton.addActionListener(this);
+ closeButton.addFocusListener(this);
+
+ openButton = new Button("Open");
+ openButton.addActionListener(this);
+ openButton.addFocusListener(this);
+
+ dummyButton = new Button("Dummy");
+ dummyButton.addActionListener(this);
+ dummyButton.addFocusListener(this);
+
+ p.add(closeButton);
+ p.add(openButton);
+ p.add(dummyButton);
+
+ this.add(p);
+
+ Panel bottomPanel = new Panel();
+ bottomPanel.setFocusable(false);
+ this.add(bottomPanel);
+
+ setSize(150, 150);
+ }
+
+ public void doOpenAction() {}
+ public void doCloseAction() {}
+ public void doDummyAction() {}
+
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeClicked.flagTriggered();
+ doCloseAction();
+ } else if (openButton.equals(event.getSource())) {
+ openClicked.flagTriggered();
+ doOpenAction();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyClicked.flagTriggered();
+ doDummyAction();
+ }
+ }
+
+ @Override
+ public void focusGained(FocusEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeGained.flagTriggered();
+ } else if (openButton.equals(event.getSource())) {
+ openGained.flagTriggered();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyGained.flagTriggered();
+ }
+ }
+
+ @Override
+ public void focusLost(FocusEvent event) {
+ if (closeButton.equals(event.getSource())) {
+ closeLost.flagTriggered();
+ } else if (openButton.equals(event.getSource())) {
+ openLost.flagTriggered();
+ } else if (dummyButton.equals(event.getSource())) {
+ dummyLost.flagTriggered();
+ }
+ }
+
+ @Override
+ public void windowGainedFocus(WindowEvent event) {
+ focusGained.flagTriggered();
+ }
+
+ @Override
+ public void windowLostFocus(WindowEvent event) {
+ focusLost.flagTriggered();
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ activated.flagTriggered();
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {}
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ System.err.println("User closed window!");
+ System.exit(1);
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {}
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {}
+
+ @Override
+ public void windowIconified(WindowEvent e) {}
+
+ @Override
+ public void windowOpened(WindowEvent e) {}
+
+ public void clickButton(Button b, ExtendedRobot robot) {
+ try {
+ Flag.waitTillShown(b);
+ } catch (InterruptedException e) {}
+
+ if ((closeButton.equals(b) || openButton.equals(b) ||
+ dummyButton.equals(b)) && robot != null) {
+ robot.mouseMove((int) b.getLocationOnScreen().x + b.getSize().width / 2,
+ (int) b.getLocationOnScreen().y + b.getSize().height / 2);
+ robot.delay(delay);
+ robot.click();
+ robot.delay(delay);
+ }
+ }
+
+ public void clickOpenButton(ExtendedRobot robot) throws Exception {
+ openClicked.reset();
+ clickButton(openButton, robot);
+
+ openClicked.waitForFlagTriggered();
+ assertTrue(openClicked.flag(),
+ "clicking the window Open button did not trigger an action");
+ }
+
+ public void clickCloseButton(ExtendedRobot robot) throws Exception {
+ closeClicked.reset();
+ clickButton(closeButton, robot);
+
+ closeClicked.waitForFlagTriggered();
+ assertTrue(closeClicked.flag(),
+ "clicking the window Close button did not trigger an action");
+ }
+
+ public void clickDummyButton(ExtendedRobot robot) throws Exception {
+ dummyClicked.reset();
+ clickButton(dummyButton, robot);
+
+ dummyClicked.waitForFlagTriggered();
+ assertTrue(dummyClicked.flag(),
+ "clicking the window Dummy button did not trigger an action");
+ }
+
+ public void checkBlockedWindow(ExtendedRobot robot,
+ String message) throws Exception {
+ dummyGained.reset();
+ dummyClicked.reset();
+ focusGained.reset();
+
+ clickButton(dummyButton, robot);
+
+ robot.waitForIdle(delay);
+
+ assertFalse(dummyClicked.flag(),
+ "DummyButton on blocked Window triggered action when clicked. " + message);
+
+ assertFalse(dummyGained.flag(),
+ "DummyButton on blocked Window gained focus when clicked. " + message);
+
+ assertFalse(focusGained.flag(),
+ "A blocked window gained focus when component clicked. " + message);
+ }
+
+ public void checkUnblockedWindowWithBlockedParent(
+ ExtendedRobot robot, String message) throws Exception {
+
+ dummyGained.reset();
+ dummyClicked.reset();
+ clickButton(dummyButton, robot);
+
+ dummyClicked.waitForFlagTriggered();
+
+ assertTrue(dummyClicked.flag(),
+ "DummyButton on Window did not trigger action when clicked. " + message);
+
+ assertFalse(dummyGained.flag(),
+ "DummyButton on Window gained focus " +
+ "when its parent is non-focusable. " + message);
+ }
+
+ public void checkUnblockedWindow(ExtendedRobot robot,
+ String message) throws Exception {
+ dummyGained.reset();
+ dummyClicked.reset();
+ clickButton(dummyButton, robot);
+
+ dummyGained.waitForFlagTriggered();
+ assertTrue(dummyGained.flag(),
+ "DummyButton on Window did not gain focus on clicking. " + message);
+
+ assertTrue(dummyClicked.flag(),
+ "DummyButton on Window did not trigger action on clicking. " + message);
+
+ closeGained.reset();
+ robot.type(KeyEvent.VK_TAB);
+
+ closeGained.waitForFlagTriggered();
+ assertTrue(closeGained.flag(),
+ "Tab navigation did not happen properly on Window. First " +
+ "button did not gain focus on tab press. " + message);
+ }
+
+ public void checkCloseButtonFocusGained() {
+ checkCloseButtonFocusGained(Flag.ATTEMPTS);
+ }
+
+ public void checkCloseButtonFocusGained(int attempts) {
+ try {
+ closeGained.waitForFlagTriggered(attempts);
+ } catch (InterruptedException e) {}
+ assertTrue(closeGained.flag(),
+ "window Close button did not gain focus");
+ }
+
+ public void checkOpenButtonFocusGained() {
+ checkOpenButtonFocusGained(Flag.ATTEMPTS);
+ }
+
+ public void checkOpenButtonFocusGained(int attempts) {
+ try {
+ openGained.waitForFlagTriggered(attempts);
+ } catch (InterruptedException e) {}
+ assertTrue(openGained.flag(),
+ "window Open button did not gain focus");
+ }
+
+ public void checkOpenButtonFocusLost() {
+ checkOpenButtonFocusLost(Flag.ATTEMPTS);
+ }
+
+ public void checkOpenButtonFocusLost(int attempts) {
+ try {
+ openLost.waitForFlagTriggered(attempts);
+ } catch (InterruptedException e) {}
+ assertTrue(openLost.flag(),
+ "window Open button did not lose focus");
+ }
+}