jdk/test/java/awt/Modal/helpers/TestWindow.java
author avstepan
Wed, 09 Jul 2014 12:56:03 +0400
changeset 25759 625be49758c1
parent 25202 a617d3450e3e
child 26014 e50160ba221c
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:
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     1
/*
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     2
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     4
 *
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     8
 *
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    13
 * accompanied this code).
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    14
 *
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    18
 *
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    21
 * questions.
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    22
 */
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    23
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    24
import java.awt.*;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    25
import java.awt.event.*;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    26
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    27
import static jdk.testlibrary.Asserts.*;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    28
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    29
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    30
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    31
public class TestWindow extends Window implements ActionListener,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    32
    FocusListener, WindowFocusListener, WindowListener {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    33
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    34
    public Button closeButton, openButton, dummyButton;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    35
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    36
    public Flag closeClicked, openClicked, dummyClicked;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    37
    public Flag closeGained,  openGained,  dummyGained;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    38
    public Flag closeLost,    openLost,    dummyLost;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    39
    public Flag focusGained, focusLost;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    40
    public Flag activated;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    41
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    42
    public static int delay = 500;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    43
    public static int keyDelay = 100;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    44
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    45
    public TestWindow(Frame owner) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    46
        super(owner);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    47
        initializeGUI();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    48
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    49
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    50
    public TestWindow(Window window) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    51
        super(window);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    52
        initializeGUI();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    53
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    54
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    55
    public void resetStatus() {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    56
        activated.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    57
        focusGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    58
        closeGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    59
        openGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    60
        closeClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    61
        openClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    62
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    63
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    64
    private void initFlags() {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    65
        closeClicked = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    66
        openClicked  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    67
        dummyClicked = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    68
        closeGained  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    69
        openGained   = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    70
        dummyGained  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    71
        closeLost    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    72
        openLost     = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    73
        dummyLost    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    74
        focusGained  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    75
        focusLost    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    76
        activated    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    77
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    78
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    79
    private void initializeGUI() {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    80
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    81
        initFlags();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    82
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    83
        this.addWindowFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    84
        this.addWindowListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    85
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    86
        this.setLayout(new GridLayout(3, 1));
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    87
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    88
        Panel topPanel;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    89
        topPanel = new Panel();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    90
        topPanel.setFocusable(false);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    91
        this.add(topPanel);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    92
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    93
        Panel p = new Panel();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    94
        p.setLayout(new GridLayout(1, 3));
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    95
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    96
        closeButton = new Button("Close");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    97
        closeButton.addActionListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    98
        closeButton.addFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    99
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   100
        openButton = new Button("Open");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   101
        openButton.addActionListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   102
        openButton.addFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   103
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   104
        dummyButton = new Button("Dummy");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   105
        dummyButton.addActionListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   106
        dummyButton.addFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   107
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   108
        p.add(closeButton);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   109
        p.add(openButton);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   110
        p.add(dummyButton);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   111
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   112
        this.add(p);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   113
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   114
        Panel bottomPanel = new Panel();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   115
        bottomPanel.setFocusable(false);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   116
        this.add(bottomPanel);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   117
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   118
        setSize(150, 150);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   119
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   120
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   121
    public void doOpenAction()  {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   122
    public void doCloseAction() {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   123
    public void doDummyAction() {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   124
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   125
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   126
    public void actionPerformed(ActionEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   127
        if (closeButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   128
            closeClicked.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   129
            doCloseAction();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   130
        } else if (openButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   131
            openClicked.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   132
            doOpenAction();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   133
        } else if (dummyButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   134
            dummyClicked.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   135
            doDummyAction();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   136
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   137
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   138
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   139
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   140
    public void focusGained(FocusEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   141
        if (closeButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   142
            closeGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   143
        } else if (openButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   144
            openGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   145
        } else if (dummyButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   146
            dummyGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   147
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   148
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   149
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   150
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   151
    public void focusLost(FocusEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   152
        if (closeButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   153
            closeLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   154
        } else if (openButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   155
            openLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   156
        } else if (dummyButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   157
            dummyLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   158
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   159
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   160
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   161
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   162
    public void windowGainedFocus(WindowEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   163
        focusGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   164
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   165
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   166
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   167
    public void windowLostFocus(WindowEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   168
        focusLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   169
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   170
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   171
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   172
    public void windowActivated(WindowEvent e) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   173
        activated.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   174
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   175
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   176
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   177
    public void windowClosed(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   178
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   179
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   180
    public void windowClosing(WindowEvent e) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   181
        System.err.println("User closed window!");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   182
        System.exit(1);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   183
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   184
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   185
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   186
    public void windowDeactivated(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   187
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   188
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   189
    public void windowDeiconified(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   190
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   191
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   192
    public void windowIconified(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   193
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   194
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   195
    public void windowOpened(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   196
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   197
    public void clickButton(Button b, ExtendedRobot robot) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   198
        try {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   199
            Flag.waitTillShown(b);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   200
        } catch (InterruptedException e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   201
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   202
        if ((closeButton.equals(b) || openButton.equals(b) ||
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   203
            dummyButton.equals(b)) && robot != null) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   204
            robot.mouseMove((int) b.getLocationOnScreen().x + b.getSize().width / 2,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   205
                            (int) b.getLocationOnScreen().y + b.getSize().height / 2);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   206
            robot.delay(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   207
            robot.click();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   208
            robot.delay(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   209
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   210
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   211
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   212
    public void clickOpenButton(ExtendedRobot robot) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   213
        openClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   214
        clickButton(openButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   215
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   216
        openClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   217
        assertTrue(openClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   218
            "clicking the window Open button did not trigger an action");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   219
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   220
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   221
    public void clickCloseButton(ExtendedRobot robot) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   222
        closeClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   223
        clickButton(closeButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   224
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   225
        closeClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   226
        assertTrue(closeClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   227
            "clicking the window Close button did not trigger an action");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   228
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   229
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   230
    public void clickDummyButton(ExtendedRobot robot) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   231
        dummyClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   232
        clickButton(dummyButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   233
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   234
        dummyClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   235
        assertTrue(dummyClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   236
            "clicking the window Dummy button did not trigger an action");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   237
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   238
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   239
    public void checkBlockedWindow(ExtendedRobot robot,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   240
                                   String message) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   241
        dummyGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   242
        dummyClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   243
        focusGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   244
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   245
        clickButton(dummyButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   246
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   247
        robot.waitForIdle(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   248
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   249
        assertFalse(dummyClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   250
            "DummyButton on blocked Window triggered action when clicked. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   251
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   252
        assertFalse(dummyGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   253
            "DummyButton on blocked Window gained focus when clicked. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   254
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   255
        assertFalse(focusGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   256
            "A blocked window gained focus when component clicked. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   257
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   258
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   259
    public void checkUnblockedWindowWithBlockedParent(
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   260
            ExtendedRobot robot, String message) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   261
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   262
        dummyGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   263
        dummyClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   264
        clickButton(dummyButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   265
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   266
        dummyClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   267
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   268
        assertTrue(dummyClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   269
            "DummyButton on Window did not trigger action when clicked. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   270
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   271
        assertFalse(dummyGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   272
            "DummyButton on Window gained focus " +
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   273
            "when its parent is non-focusable. "  + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   274
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   275
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   276
    public void checkUnblockedWindow(ExtendedRobot robot,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   277
                                     String message) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   278
        dummyGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   279
        dummyClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   280
        clickButton(dummyButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   281
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   282
        dummyGained.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   283
        assertTrue(dummyGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   284
            "DummyButton on Window did not gain focus on clicking. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   285
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   286
        assertTrue(dummyClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   287
            "DummyButton on Window did not trigger action on clicking. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   288
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   289
        closeGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   290
        robot.type(KeyEvent.VK_TAB);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   291
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   292
        closeGained.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   293
        assertTrue(closeGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   294
            "Tab navigation did not happen properly on Window. First " +
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   295
            "button did not gain focus on tab press. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   296
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   297
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   298
    public void checkCloseButtonFocusGained(boolean refState) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   299
        checkCloseButtonFocusGained(refState, Flag.ATTEMPTS);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   300
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   301
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   302
    public void checkCloseButtonFocusGained(boolean refState, int attempts) {
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   303
        try {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   304
            closeGained.waitForFlagTriggered(attempts);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   305
        } catch (InterruptedException e) {}
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   306
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   307
        String msg = "window Close button ";
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   308
        msg += (refState ? "did not gain focus" :
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   309
                "gained focus when it should not");
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   310
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   311
        assertTrue(closeGained.flag() == refState, msg);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   312
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   313
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   314
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   315
    public void checkOpenButtonFocusGained(boolean refState) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   316
        checkOpenButtonFocusGained(refState, Flag.ATTEMPTS);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   317
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   318
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   319
    public void checkOpenButtonFocusGained(boolean refState, int attempts) {
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   320
        try {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   321
            openGained.waitForFlagTriggered(attempts);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   322
        } catch (InterruptedException e) {}
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   323
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   324
        String msg = "window Open button ";
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   325
        msg += (refState ? "did not gain focus" :
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   326
                "gained focus when it should not");
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   327
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   328
        assertTrue(openGained.flag() == refState, msg);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   329
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   330
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   331
    public void checkOpenButtonFocusLost(boolean refState) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   332
        checkOpenButtonFocusLost(refState, Flag.ATTEMPTS);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   333
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   334
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   335
    public void checkOpenButtonFocusLost(boolean refState, int attempts) {
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   336
        try {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   337
            openLost.waitForFlagTriggered(attempts);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   338
        } catch (InterruptedException e) {}
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   339
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   340
        String msg = "window Open button ";
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   341
        msg += (refState ? "did not lose focus" :
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   342
                "lost focus when it should not");
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   343
        assertTrue(openLost.flag()== refState, msg);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   344
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   345
}