jdk/test/java/awt/Debug/DumpOnKey/DumpOnKey.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 32294 58789f875b54
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32294
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     1
/*
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     4
 *
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     8
 *
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    13
 * accompanied this code).
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    14
 *
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    18
 *
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    21
 * questions.
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    22
 */
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    23
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    24
import java.awt.AWTException;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    25
import java.awt.Frame;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    26
import java.awt.Robot;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    27
import java.awt.Window;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    28
import java.awt.event.InputEvent;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    29
import java.awt.event.KeyEvent;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    30
import java.io.PrintStream;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    31
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    32
/**
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    33
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 32294
diff changeset
    34
 * @key headful
32294
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    35
 * @bug 4379403
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    36
 * @run main/othervm DumpOnKey false
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    37
 * @run main/othervm DumpOnKey -Dsun.awt.nativedebug=true true
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    38
 * @run main/othervm DumpOnKey -Dsun.awt.nativedebug=true -Dawtdebug.on=true true
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    39
 * @run main/othervm DumpOnKey -Dsun.awt.nativedebug=false -Dawtdebug.on=true false
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    40
 * @run main/othervm DumpOnKey -Dsun.awt.nativedebug=true -Dawtdebug.on=false false
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    41
 * @run main/othervm DumpOnKey -Dsun.awt.nativedebug=false -Dawtdebug.on=false false
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    42
 * @run main/othervm/java.security.policy=dump.policy/secure=java.lang.SecurityManager DumpOnKey -Dsun.awt.nativedebug=true true
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    43
 * @run main/othervm/java.security.policy=dump.policy/secure=java.lang.SecurityManager DumpOnKey -Dsun.awt.nativedebug=true -Dawtdebug.on=false false
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    44
 */
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    45
public final class DumpOnKey {
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    46
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    47
    private static volatile boolean dumped;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    48
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    49
    public static void main(final String[] args) throws AWTException {
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    50
        final boolean dump = Boolean.parseBoolean(args[0]);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    51
        final Window w = new Frame() {
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    52
            @Override
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    53
            public void list(final PrintStream out, final int indent) {
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    54
                super.list(out, indent);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    55
                dumped = true;
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    56
            }
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    57
        };
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    58
        w.setSize(200, 200);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    59
        w.setLocationRelativeTo(null);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    60
        w.setVisible(true);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    61
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    62
        final Robot robot = new Robot();
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    63
        robot.setAutoDelay(50);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    64
        robot.setAutoWaitForIdle(true);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    65
        robot.mouseMove(w.getX() + w.getWidth() / 2,
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    66
                        w.getY() + w.getHeight() / 2);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    67
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    68
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    69
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    70
        robot.keyPress(KeyEvent.VK_CONTROL);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    71
        robot.keyPress(KeyEvent.VK_SHIFT);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    72
        robot.keyPress(KeyEvent.VK_F1);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    73
        robot.keyRelease(KeyEvent.VK_F1);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    74
        robot.keyRelease(KeyEvent.VK_SHIFT);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    75
        robot.keyRelease(KeyEvent.VK_CONTROL);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    76
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    77
        w.dispose();
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    78
        if (dumped != dump) {
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    79
            throw new RuntimeException("Exp:" + dump + ", actual:" + dumped);
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    80
        }
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    81
    }
58789f875b54 4379403: Need to disable the "magic AWT dump key" (CTRL+SHIFT+F1)
serb
parents:
diff changeset
    82
}