jdk/test/java/awt/Modal/helpers/TestFrame.java
author avstepan
Mon, 21 Jul 2014 13:17:43 +0400
changeset 25787 f1c606e8b3f8
parent 25759 625be49758c1
child 26014 e50160ba221c
permissions -rw-r--r--
8049617: move awt automated tests from AWT_Modality to OpenJDK repository - part 3 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 TestFrame extends Frame 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 Panel topPanel;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    43
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    44
    public static int delay = 500;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    45
    public static int keyDelay = 100;
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    46
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    47
    public TestFrame() {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    48
        super();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    49
        initializeGUI();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    50
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    51
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    52
    private void initFlags() {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    53
        closeClicked = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    54
        openClicked  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    55
        dummyClicked = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    56
        closeGained  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    57
        openGained   = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    58
        dummyGained  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    59
        closeLost    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    60
        openLost     = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    61
        dummyLost    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    62
        focusGained  = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    63
        focusLost    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    64
        activated    = new Flag();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    65
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    66
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    67
    public void resetStatus() {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    68
        activated.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    69
        focusGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    70
        closeGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    71
        openGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    72
        closeClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    73
        openClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    74
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    75
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    76
    private void initializeGUI() {
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
        initFlags();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    79
        this.setTitle("Frame");
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
        this.addWindowFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    82
        this.addWindowListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    83
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    84
        this.setLayout(new GridLayout(3, 1));
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
        topPanel = new Panel();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    87
        topPanel.setFocusable(false);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    88
        this.add(topPanel);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    89
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    90
        Panel p = new Panel();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    91
        p.setLayout(new GridLayout(1, 3));
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
        closeButton = new Button("Close");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    94
        closeButton.addActionListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    95
        closeButton.addFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    96
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    97
        openButton = new Button("Open");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    98
        openButton.addActionListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
    99
        openButton.addFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   100
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   101
        dummyButton = new Button("Dummy");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   102
        dummyButton.addActionListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   103
        dummyButton.addFocusListener(this);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   104
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   105
        p.add(closeButton);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   106
        p.add(openButton);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   107
        p.add(dummyButton);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   108
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   109
        this.add(p);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   110
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   111
        Panel bottomPanel = new Panel();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   112
        bottomPanel.setFocusable(false);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   113
        this.add(bottomPanel);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   114
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   115
        setSize(150, 150);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   116
    }
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
    public void doOpenAction()  {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   119
    public void doCloseAction() {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   120
    public void doDummyAction() {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   121
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   122
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   123
    public void actionPerformed(ActionEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   124
        if (closeButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   125
            closeClicked.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   126
            doCloseAction();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   127
        } else if (openButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   128
            openClicked.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   129
            doOpenAction();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   130
        } else if (dummyButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   131
            dummyClicked.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   132
            doDummyAction();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   133
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   134
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   135
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   136
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   137
    public void focusGained(FocusEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   138
        if (closeButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   139
            closeGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   140
        } else if (openButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   141
            openGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   142
        } else if (dummyButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   143
            dummyGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   144
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   145
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   146
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   147
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   148
    public void focusLost(FocusEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   149
        if (closeButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   150
            closeLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   151
        } else if (openButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   152
            openLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   153
        } else if (dummyButton.equals(event.getSource())) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   154
            dummyLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   155
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   156
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   157
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   158
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   159
    public void windowGainedFocus(WindowEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   160
        focusGained.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   161
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   162
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   163
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   164
    public void windowLostFocus(WindowEvent event) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   165
        focusLost.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   166
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   167
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   168
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   169
    public void windowActivated(WindowEvent e) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   170
        activated.flagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   171
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   172
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   173
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   174
    public void windowClosed(WindowEvent e) {}
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 windowClosing(WindowEvent e) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   178
        assertTrue(false, "user closed window");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   179
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   180
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   181
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   182
    public void windowDeactivated(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   183
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   184
    public void windowDeiconified(WindowEvent e) {}
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 windowIconified(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   187
    @Override
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   188
    public void windowOpened(WindowEvent e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   189
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   190
    public void clickButton(Button b, ExtendedRobot robot) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   191
        try {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   192
            Flag.waitTillShown(b);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   193
        } catch (InterruptedException e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   194
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   195
        if ((closeButton.equals(b) || openButton.equals(b) ||
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   196
            dummyButton.equals(b)) && robot != null) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   197
            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
   198
                            (int) b.getLocationOnScreen().y + b.getSize().height / 2);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   199
            robot.delay(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   200
            robot.click();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   201
            robot.delay(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   202
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   203
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   204
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   205
    public void clickOpenButton(ExtendedRobot robot) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   206
        openClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   207
        clickButton(openButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   208
        openClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   209
        assertTrue(openClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   210
            "clicking the frame Open button did not trigger an action");
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
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   213
    public void clickCloseButton(ExtendedRobot robot) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   214
        closeClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   215
        clickButton(closeButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   216
        closeClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   217
        assertTrue(closeClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   218
            "clicking the frame Close 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 clickDummyButton(ExtendedRobot robot) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   222
        clickDummyButton(robot, Flag.ATTEMPTS);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   223
    }
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
    public void clickDummyButton(ExtendedRobot robot,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   226
                                 int amountOfAttempts) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   227
        dummyClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   228
        clickButton(dummyButton, robot);
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
        dummyClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   231
        assertTrue(dummyClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   232
            "clicking the frame Dummy button did not trigger an action");
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
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   235
    public void clickInside(ExtendedRobot robot) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   236
        try {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   237
            Flag.waitTillShown(topPanel);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   238
        } catch (InterruptedException e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   239
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   240
        if (robot != null) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   241
            robot.mouseMove((int) topPanel.getLocationOnScreen().x + topPanel.getSize().width / 2,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   242
                            (int) topPanel.getLocationOnScreen().y + topPanel.getSize().height / 2);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   243
            robot.delay(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   244
            robot.click();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   245
            robot.delay(delay);
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
    }
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
    public void transferFocusToFrame(ExtendedRobot robot,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   250
                                     String message,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   251
                                     Button b) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   252
        focusGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   253
        clickInside(robot);
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
        focusGained.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   256
        assertTrue(focusGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   257
            "Clicking inside the Frame did not make it focused. " + message);
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
        if (b != null) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   260
            assertTrue(b.hasFocus(), "Button " + b.getLabel() +
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   261
                " did not gain focus when Frame brought to top");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   262
        }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   263
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   264
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   265
    public void transferFocusToBlockedFrame(ExtendedRobot robot,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   266
                                            String message,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   267
                                            Button b) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   268
        focusGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   269
        clickInside(robot);
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
        robot.waitForIdle(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   272
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   273
        assertFalse(focusGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   274
            "Clicking inside a blocked Frame made it focused. " + message);
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
        robot.waitForIdle(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   277
        if (b != null) {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   278
            assertFalse(b.hasFocus(), "Button " + b.getLabel() +
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   279
                " present in a blocked frame gained focus");
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   280
        }
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
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   283
    public void checkBlockedFrame(
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   284
            ExtendedRobot robot, String message) throws Exception {
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
        dummyGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   287
        dummyClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   288
        focusGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   289
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   290
        clickButton(dummyButton, robot);
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
        robot.waitForIdle(delay);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   293
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   294
        assertFalse(dummyClicked.flag(),
25787
f1c606e8b3f8 8049617: move awt automated tests from AWT_Modality to OpenJDK repository - part 3
avstepan
parents: 25759
diff changeset
   295
            "DummyButton on blocked Frame triggered action when clicked. " + message);
25202
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
        assertFalse(dummyGained.flag(),
25787
f1c606e8b3f8 8049617: move awt automated tests from AWT_Modality to OpenJDK repository - part 3
avstepan
parents: 25759
diff changeset
   298
            "DummyButton on blocked Frame gained focus when clicked. " + message);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   299
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   300
        assertFalse(focusGained.flag(),
25787
f1c606e8b3f8 8049617: move awt automated tests from AWT_Modality to OpenJDK repository - part 3
avstepan
parents: 25759
diff changeset
   301
            "A blocked Frame gained focus when component clicked. " + message);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   302
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   303
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   304
    public void checkUnblockedFrame(ExtendedRobot robot,
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   305
                                    String message) throws Exception {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   306
        dummyGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   307
        dummyClicked.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   308
        clickButton(dummyButton, robot);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   309
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   310
        dummyGained.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   311
        assertTrue(dummyGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   312
            "DummyButton on Frame did not gain focus on clicking. " + message);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   313
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   314
        dummyClicked.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   315
        assertTrue(dummyClicked.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   316
            "DummyButton on Frame did not trigger action on clicking. " + message);
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
        closeGained.reset();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   319
        robot.type(KeyEvent.VK_TAB);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   320
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   321
        closeGained.waitForFlagTriggered();
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   322
        assertTrue(closeGained.flag(),
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   323
            "FAIL: Tab navigation did not happen properly on Frame. First " +
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   324
            "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
   325
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   326
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   327
    public void checkCloseButtonFocusGained(boolean refState) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   328
        checkCloseButtonFocusGained(refState, Flag.ATTEMPTS);
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 checkCloseButtonFocusGained(boolean refState, int attempts) {
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   332
        try {
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   333
            closeGained.waitForFlagTriggered(attempts);
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   334
        } catch (InterruptedException e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   335
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   336
        String msg = "frame Close button ";
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   337
        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
   338
                "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
   339
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   340
        assertTrue(closeGained.flag() == refState, msg);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   341
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   342
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   343
    public void checkOpenButtonFocusGained(boolean refState) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   344
        checkOpenButtonFocusGained(refState, Flag.ATTEMPTS);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   345
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   346
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   347
    public void checkOpenButtonFocusGained(boolean refState, int attempts) {
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   348
        try {
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   349
            openGained.waitForFlagTriggered(attempts);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   350
        } catch (InterruptedException e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   351
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   352
        String msg = "frame Open button ";
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   353
        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
   354
                "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
   355
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   356
        assertTrue(openGained.flag() == refState, msg);
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   357
    }
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   358
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   359
    public void checkOpenButtonFocusLost(boolean refState) {
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   360
        checkOpenButtonFocusLost(refState, Flag.ATTEMPTS);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   361
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   362
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   363
    public void checkOpenButtonFocusLost(boolean refState, int attempts) {
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   364
        try {
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   365
            openLost.waitForFlagTriggered(attempts);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   366
        } catch (InterruptedException e) {}
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   367
25759
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   368
        String msg = "frame Open button ";
625be49758c1 8047367: move awt automated tests from AWT_Modality to OpenJDK repository - part 2
avstepan
parents: 25202
diff changeset
   369
        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
   370
                "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
   371
        assertTrue(openLost.flag()== refState, msg);
25202
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   372
    }
a617d3450e3e 8044429: move awt automated tests for AWT_Modality to OpenJDK repository
yan
parents:
diff changeset
   373
}