jdk/test/java/awt/Modal/ModalFocusTransferTests/FocusTransferDWFTest.java
author avstepan
Wed, 09 Jul 2014 12:56:03 +0400
changeset 25759 625be49758c1
permissions -rw-r--r--
8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2 Reviewed-by: pchelko
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     1
/*
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     2
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     4
 *
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     8
 *
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    13
 * accompanied this code).
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    14
 *
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    18
 *
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    21
 * questions.
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    22
 */
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    23
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    24
import java.awt.*;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    25
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    26
import static jdk.testlibrary.Asserts.*;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    27
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    28
// DWF: Dialog -> Window -> Frame
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    29
public class FocusTransferDWFTest {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    30
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    31
    class CustomDialog extends TestDialog {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    32
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    33
        public CustomDialog(Frame f) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    34
            super(f);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    35
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    36
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    37
        @Override
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    38
        public void doOpenAction() {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    39
            if (window != null) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    40
                window.setVisible(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    41
            }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    42
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    43
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    44
        @Override
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    45
        public void doCloseAction() {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    46
            this.dispose();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    47
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    48
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    49
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    50
    class CustomFrame extends TestFrame {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    51
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    52
        @Override
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    53
        public void doCloseAction() {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    54
            this.dispose();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    55
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    56
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    57
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    58
    class CustomWindow extends TestWindow {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    59
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    60
        public CustomWindow(Dialog d) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    61
            super(d);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    62
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    63
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    64
        @Override
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    65
        public void doOpenAction() {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    66
            if (frame != null) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    67
                frame.setVisible(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    68
            }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    69
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    70
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    71
        @Override
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    72
        public void doCloseAction() {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    73
            this.dispose();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    74
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    75
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    76
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    77
    private TestDialog dialog;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    78
    private TestFrame  frame;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    79
    private TestWindow window;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    80
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    81
    private static final int delay = 1000;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    82
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    83
    private final ExtendedRobot robot;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    84
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    85
    private Dialog.ModalityType modalityType;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    86
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    87
    FocusTransferDWFTest(Dialog.ModalityType modType) throws Exception {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    88
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    89
        modalityType = modType;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    90
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    91
        robot = new ExtendedRobot();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    92
        EventQueue.invokeLater(this::createGUI);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    93
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    94
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    95
    private void createGUI() {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    96
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    97
        frame = new CustomFrame();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    98
        frame.setLocation(50, 50);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
    99
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   100
        dialog = new CustomDialog((Frame) null);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   101
        if (modalityType == null) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   102
            modalityType = Dialog.ModalityType.MODELESS;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   103
        } else {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   104
            dialog.setModalityType(modalityType);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   105
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   106
        dialog.setLocation(250, 50);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   107
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   108
        window = new CustomWindow(dialog);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   109
        window.setLocation(450, 50);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   110
        dialog.setVisible(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   111
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   112
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   113
    private void closeAll() {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   114
        if (dialog != null) { dialog.dispose(); }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   115
        if ( frame != null) {  frame.dispose(); }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   116
        if (window != null) { window.dispose(); }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   117
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   118
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   119
    public void doTest() throws Exception {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   120
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   121
        robot.waitForIdle(delay);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   122
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   123
        try {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   124
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   125
            dialog.checkCloseButtonFocusGained(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   126
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   127
            dialog.clickOpenButton(robot);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   128
            robot.waitForIdle(delay);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   129
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   130
            window.checkCloseButtonFocusGained(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   131
            dialog.checkOpenButtonFocusLost(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   132
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   133
            window.clickOpenButton(robot);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   134
            robot.waitForIdle(delay);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   135
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   136
            switch (modalityType) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   137
                case APPLICATION_MODAL:
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   138
                    frame.checkCloseButtonFocusGained(false, 10);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   139
                    window.checkOpenButtonFocusLost(false, 10);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   140
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   141
                    frame.closeGained.reset();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   142
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   143
                    dialog.clickCloseButton(robot);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   144
                    robot.waitForIdle(delay);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   145
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   146
                    frame.checkCloseButtonFocusGained(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   147
                    assertFalse(window.isVisible(), "window shouldn't be visible");
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   148
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   149
                    break;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   150
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   151
                case DOCUMENT_MODAL:
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   152
                case MODELESS:
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   153
                    frame.checkCloseButtonFocusGained(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   154
                    window.checkOpenButtonFocusLost(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   155
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   156
                    window.openGained.reset();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   157
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   158
                    frame.clickCloseButton(robot);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   159
                    robot.waitForIdle(delay);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   160
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   161
                    window.checkOpenButtonFocusGained(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   162
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   163
                    dialog.openGained.reset();
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   164
                    window.clickCloseButton(robot);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   165
                    robot.waitForIdle(delay);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   166
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   167
                    dialog.checkOpenButtonFocusGained(true);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   168
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   169
                    break;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   170
            }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   171
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   172
        } catch (Exception e) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   173
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   174
            // make screenshot before exit
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   175
            Rectangle rect = new Rectangle(0, 0, 650, 250);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   176
            java.awt.image.BufferedImage img = robot.createScreenCapture(rect);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   177
            javax.imageio.ImageIO.write(img, "jpg", new java.io.File("NOK.jpg"));
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   178
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   179
            throw e;
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   180
        }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   181
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   182
        robot.waitForIdle(delay);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   183
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   184
        EventQueue.invokeAndWait(this::closeAll);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   185
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents:
diff changeset
   186
}