jdk/test/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 33249 334120f2d641
child 45028 b0ea3c0bfb81
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:
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
     1
33249
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     2
/*
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     3
 * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     5
 *
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     8
 * published by the Free Software Foundation.
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
     9
 *
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    14
 * accompanied this code).
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    15
 *
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    19
 *
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    22
 * questions.
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    23
 */
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    24
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
    25
/*
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
    26
 * @test
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
    27
 * @key headful
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
    28
 * @bug 8079595
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
    29
 * @summary Resizing dialog which is JWindow parent makes JVM crash
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
    30
 * @author Semyon Sadetsky
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33249
diff changeset
    31
 */
33249
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    32
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    33
import javax.swing.*;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    34
import java.awt.*;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    35
import java.awt.event.ActionEvent;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    36
import java.awt.event.ActionListener;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    37
import java.awt.event.InputEvent;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    38
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    39
public class ShowChildWhileResizingTest {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    40
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    41
    private static Window dialog;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    42
    private static Timer timer;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    43
    private static Point point;
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    44
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    45
    public static void main(String[] args) throws Exception {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    46
        dialog = new Frame();
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    47
        dialog.add(new JPanel());
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    48
        dialog.setVisible(true);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    49
        dialog.setBounds(100, 100, 200, 200);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    50
        SwingUtilities.invokeAndWait(new Runnable() {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    51
            @Override
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    52
            public void run() {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    53
                final Window dependentWindow = new JWindow(dialog);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    54
                JPanel panel = new JPanel();
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    55
                panel.add(new JButton("button"));
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    56
                dependentWindow.add(panel);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    57
                dependentWindow.setVisible(true);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    58
                dependentWindow.setBounds(0, 0, 50, 50);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    59
                timer = new Timer(100, new ActionListener() {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    60
                    @Override
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    61
                    public void actionPerformed(ActionEvent e) {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    62
                        dependentWindow
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    63
                                .setVisible(!dependentWindow.isVisible());
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    64
                    }
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    65
                });
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    66
                timer.start();
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    67
            }
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    68
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    69
        });
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    70
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    71
        Robot robot = new Robot();
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    72
        robot.setAutoDelay(5);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    73
        robot.delay(300);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    74
        SwingUtilities.invokeAndWait(new Runnable() {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    75
            @Override
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    76
            public void run() {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    77
                point = dialog.getLocationOnScreen();
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    78
            }
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    79
        });
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    80
        robot.mouseMove(point.x + 200 - dialog.getInsets().right/2,
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    81
                point.y + 200 - dialog.getInsets().bottom/2);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    82
        robot.mousePress(InputEvent.BUTTON1_MASK);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    83
        for(int i = 0; i < 100; i++) {
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    84
            robot.mouseMove(point.x + 200 + i, point.y + 200 + i);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    85
        }
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    86
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    87
        timer.stop();
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    88
        dialog.dispose();
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    89
        System.out.println("ok");
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    90
    }
334120f2d641 8079595: Resizing dialog which is JWindow parent makes JVM crash
ssadetsky
parents:
diff changeset
    91
}