jdk/test/javax/swing/JInternalFrame/Test6325652.java
author ihse
Tue, 09 May 2017 12:57:30 +0200
changeset 45028 b0ea3c0bfb81
parent 39538 8477ce4d6628
child 46151 5fa789776f7d
permissions -rw-r--r--
8179889: Fix typographic errors in copyright headers Reviewed-by: erikj, dholmes
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
/*
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39538
diff changeset
     2
 * Copyright (c) 2009, 2016, 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
39538
8477ce4d6628 8159152: Ctrl+F6, Ctrl+F5 doesn't work for iconified InternalFrame
rchamyal
parents: 5506
diff changeset
    26
 * @bug 6325652 8159152
3502
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
 * @library ..
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    29
 */
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
import java.awt.AWTException;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    32
import java.awt.Robot;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    33
import java.awt.event.KeyEvent;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    34
import java.beans.PropertyVetoException;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    35
import javax.swing.JDesktopPane;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    36
import javax.swing.JFrame;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    37
import javax.swing.JInternalFrame;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    38
import javax.swing.JTextArea;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    39
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    40
public class Test6325652 {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    41
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    42
    private static final int WIDTH = 300;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    43
    private static final int HEIGHT = 300;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    44
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    45
    public static void main(String[] args) throws Throwable {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    46
        SwingTest.start(Test6325652.class);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    47
    }
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
    private static Robot robot;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    50
    private JInternalFrame internal;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    51
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    52
    public Test6325652(JFrame frame) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    53
        JDesktopPane desktop = new JDesktopPane();
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    54
        desktop.add(create(0));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    55
        desktop.add(this.internal = create(1));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    56
        frame.add(desktop);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    57
    }
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
    public void select() throws PropertyVetoException {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    60
        this.internal.setSelected(true);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    61
    }
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
    public static void stepFirst() throws AWTException {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    64
        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
    65
        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
    66
    }
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
    public void stepFirstValidate() {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    69
        if (!this.internal.isIcon()) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    70
            throw new Error("frame should be an icon");
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    71
        }
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
    public static void stepSecond() {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    75
        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
    76
        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
    77
    }
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
    public void stepSecondValidate() {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    80
        if (this.internal.isIcon()) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    81
            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
    82
        }
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
    private static void click(int... keys) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    86
        for (int key : keys) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    87
            robot.keyPress(key);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    88
        }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    89
        for (int key : keys) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    90
            robot.keyRelease(key);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    91
        }
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
    private static JInternalFrame create(int index) {
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    95
        String text = "test" + index; // NON-NLS: frame identification
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    96
        index = index * 3 + 1;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    97
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
    98
        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
    99
        internal.getContentPane().add(new JTextArea(text));
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   100
        internal.setBounds(10 * index, 10 * index, WIDTH, HEIGHT);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   101
        internal.setVisible(true);
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   102
        return internal;
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   103
    }
821e773cae60 6865565: Test failed: /test/closed/javax/swing/JInternalFrame/6325652/bug6325652.java
malenkov
parents:
diff changeset
   104
}