jdk/test/java/awt/Modal/FileDialog/FileDialogDWDTest.java
author avstepan
Tue, 18 Nov 2014 17:10:34 +0400
changeset 28068 e0916ce5b3fc
permissions -rw-r--r--
8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8 Summary: Some new tests to check FileDialog modality behavior Reviewed-by: alexsch, pchelko
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28068
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     1
/*
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     2
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     4
 *
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     8
 *
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    13
 * accompanied this code).
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    14
 *
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    18
 *
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    21
 * questions.
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    22
 */
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    23
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    24
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    25
import java.awt.*;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    26
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    27
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    28
// DWD: Dialog, Window, Dialog
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    29
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    30
public class FileDialogDWDTest {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    31
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    32
    private volatile FileDialog fileDialog;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    33
    private volatile ParentDialog parent;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    34
    private volatile CustomDialog dialog;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    35
    private volatile TestWindow window;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    36
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    37
    private static final int delay = 500;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    38
    private final ExtendedRobot robot;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    39
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    40
    boolean setModal;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    41
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    42
    Dialog.ModalityType modalityType;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    43
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    44
    private FileDialogDWDTest(Dialog.ModalityType modType,
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    45
                              boolean             modal) throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    46
        modalityType = modType;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    47
        setModal = modal;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    48
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    49
        robot = new ExtendedRobot();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    50
        EventQueue.invokeLater(this::createGUI);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    51
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    52
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    53
    public FileDialogDWDTest(Dialog.ModalityType modalityType) throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    54
        this(modalityType, false);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    55
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    56
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    57
    public FileDialogDWDTest() throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    58
        this(null, true);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    59
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    60
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    61
    private void createGUI() {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    62
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    63
        parent = new ParentDialog();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    64
        dialog = new CustomDialog(parent);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    65
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    66
        if (setModal) {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    67
            dialog.setModal(true);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    68
            modalityType = dialog.getModalityType();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    69
        } else if (modalityType != null) {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    70
            dialog.setModalityType(modalityType);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    71
        }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    72
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    73
        window = new CustomWindow(parent);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    74
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    75
        int x = Toolkit.getDefaultToolkit().getScreenSize().width -
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    76
            parent.getWidth() - 50;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    77
        int y = 50;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    78
        parent.setLocation(x, y);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    79
        y += (parent.getHeight() + 50);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    80
        window.setLocation(x, y);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    81
        y += (window.getHeight() + 50);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    82
        dialog.setLocation(x, y);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    83
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    84
        parent.setVisible(true);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    85
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    86
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    87
    private void openAll() throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    88
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    89
        parent.clickOpenButton(robot);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    90
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    91
        window.clickOpenButton(robot);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    92
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    93
        dialog.clickOpenButton(robot);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    94
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    95
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    96
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    97
    private void checkBlockedWindows() throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    98
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
    99
        String msg = "FileDialog should block this ";
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   100
        parent.checkBlockedDialog(robot, msg + "Dialog.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   101
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   102
        window.checkBlockedWindow(robot, msg + "Window.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   103
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   104
        dialog.checkBlockedDialog(robot, msg + "Dialog.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   105
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   106
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   107
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   108
    private void checkUnblockedWindows() throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   109
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   110
        String msg = "Blocking dialogs were closed.";
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   111
        parent.checkUnblockedDialog(robot, msg + "Frame.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   112
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   113
        window.checkUnblockedWindow(robot, msg + "Window.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   114
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   115
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   116
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   117
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   118
    private void modalTest(String type) throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   119
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   120
        checkBlockedWindows();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   121
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   122
        EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   123
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   124
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   125
        String msg = "FileDialog was closed, " +
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   126
            "but the " + type + " modal dialog should block this ";
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   127
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   128
        parent.checkBlockedDialog(robot, msg + "Dialog.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   129
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   130
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   131
        window.checkBlockedWindow(robot, msg + "Window.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   132
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   133
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   134
        dialog.checkUnblockedDialog(robot, "FileDialog was closed.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   135
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   136
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   137
        dialog.clickCloseButton(robot);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   138
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   139
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   140
        checkUnblockedWindows();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   141
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   142
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   143
    private void nonModalTest() throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   144
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   145
        checkBlockedWindows();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   146
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   147
        EventQueue.invokeAndWait(() -> { fileDialog.dispose(); });
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   148
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   149
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   150
        dialog.checkUnblockedDialog(robot, "FileDialog was closed.");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   151
        robot.waitForIdle(delay);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   152
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   153
        checkUnblockedWindows();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   154
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   155
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   156
    public void doTest() throws Exception {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   157
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   158
        try {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   159
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   160
            openAll();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   161
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   162
            if (modalityType == null) {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   163
                nonModalTest();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   164
                return;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   165
            }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   166
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   167
            switch (modalityType) {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   168
                case APPLICATION_MODAL:
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   169
                    modalTest("application");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   170
                    break;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   171
                case DOCUMENT_MODAL:
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   172
                    modalTest("document");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   173
                    break;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   174
                case TOOLKIT_MODAL:
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   175
                    modalTest("toolkit");
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   176
                    break;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   177
                case MODELESS:
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   178
                    nonModalTest();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   179
                    break;
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   180
            }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   181
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   182
        } finally {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   183
            EventQueue.invokeAndWait(this::closeAll);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   184
        }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   185
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   186
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   187
    private void closeAll() {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   188
        if (parent != null) { parent.dispose(); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   189
        if (dialog != null) { dialog.dispose(); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   190
        if (window != null) { window.dispose(); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   191
        if (fileDialog != null) { fileDialog.dispose(); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   192
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   193
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   194
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   195
    class ParentDialog extends TestDialog {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   196
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   197
        public ParentDialog() { super((Frame) null); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   198
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   199
        @Override
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   200
        public void doOpenAction() {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   201
            if (window != null) { window.setVisible(true); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   202
        }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   203
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   204
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   205
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   206
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   207
    class CustomDialog extends TestDialog {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   208
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   209
        public CustomDialog(Dialog d) { super(d); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   210
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   211
        @Override
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   212
        public void doOpenAction() {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   213
            fileDialog = new FileDialog((Frame) null);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   214
            fileDialog.setLocation(50, 50);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   215
            fileDialog.setVisible(true);
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   216
        }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   217
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   218
        @Override
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   219
        public void doCloseAction() {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   220
            this.dispose();
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   221
        }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   222
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   223
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   224
    class CustomWindow extends TestWindow {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   225
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   226
        public CustomWindow(Dialog d) { super(d); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   227
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   228
        @Override
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   229
        public void doOpenAction() {
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   230
            if (dialog != null) { dialog.setVisible(true); }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   231
        }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   232
    }
e0916ce5b3fc 8054359: move awt automated tests from AWT_Modality to OpenJDK repository - part 8
avstepan
parents:
diff changeset
   233
}