jdk/test/javax/swing/JInternalFrame/Test6325652.java
author cl
Fri, 18 Feb 2011 14:23:48 -0800
changeset 8267 6a5f458575cf
parent 5506 202f599c92aa
child 39538 8477ce4d6628
permissions -rw-r--r--
Added tag jdk7-b130 for changeset 8924242a88c8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3502
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     4
 *
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     8
 *
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    13
 * accompanied this code).
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    14
 *
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3502
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3502
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3502
diff changeset
    21
 * questions.
3502
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    22
 */
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    23
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    24
/*
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    25
 * @test
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    26
 * @bug 6325652
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    27
 * @summary Tests keyboard shortcuts
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    28
 * @author Sergey Malenkov
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    29
 * @library ..
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    30
 */
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    31
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    32
import java.awt.AWTException;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    33
import java.awt.Robot;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    34
import java.awt.event.KeyEvent;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    35
import java.beans.PropertyVetoException;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    36
import javax.swing.JDesktopPane;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    37
import javax.swing.JFrame;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    38
import javax.swing.JInternalFrame;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    39
import javax.swing.JTextArea;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    40
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    41
public class Test6325652 {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    42
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    43
    private static final int WIDTH = 300;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    44
    private static final int HEIGHT = 300;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    45
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    46
    public static void main(String[] args) throws Throwable {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    47
        SwingTest.start(Test6325652.class);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    48
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    49
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    50
    private static Robot robot;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    51
    private JInternalFrame internal;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    52
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    53
    public Test6325652(JFrame frame) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    54
        JDesktopPane desktop = new JDesktopPane();
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    55
        desktop.add(create(0));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    56
        desktop.add(this.internal = create(1));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    57
        frame.add(desktop);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    58
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    59
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    60
    public void select() throws PropertyVetoException {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    61
        this.internal.setSelected(true);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    62
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    63
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    64
    public static void stepFirst() throws AWTException {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    65
        robot = new Robot(); // initialize shared static field first time
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    66
        click(KeyEvent.VK_CONTROL, KeyEvent.VK_F9); // iconify internal frame
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    67
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    68
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    69
    public void stepFirstValidate() {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    70
        if (!this.internal.isIcon()) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    71
            throw new Error("frame should be an icon");
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    72
        }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    73
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    74
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    75
    public static void stepSecond() {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    76
        click(KeyEvent.VK_CONTROL, KeyEvent.VK_F6); // navigate to the icon
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    77
        click(KeyEvent.VK_CONTROL, KeyEvent.VK_F5); // restore the icon
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    78
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    79
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    80
    public void stepSecondValidate() {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    81
        if (this.internal.isIcon()) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    82
            throw new Error("frame should not be an icon");
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    83
        }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    84
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    85
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    86
    private static void click(int... keys) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    87
        for (int key : keys) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    88
            robot.keyPress(key);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    89
        }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    90
        for (int key : keys) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    91
            robot.keyRelease(key);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    92
        }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    93
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    94
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    95
    private static JInternalFrame create(int index) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    96
        String text = "test" + index; // NON-NLS: frame identification
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    97
        index = index * 3 + 1;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    98
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    99
        JInternalFrame internal = new JInternalFrame(text, true, true, true, true);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   100
        internal.getContentPane().add(new JTextArea(text));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   101
        internal.setBounds(10 * index, 10 * index, WIDTH, HEIGHT);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   102
        internal.setVisible(true);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   103
        return internal;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   104
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   105
}