jdk/test/java/awt/Window/ChangeWindowResizabilty/ChangeWindowResizabiltyTest.java
author ssadetsky
Tue, 18 Oct 2016 12:43:07 +0300
changeset 41802 89f634379c0c
child 41897 a0c1eae91129
permissions -rw-r--r--
8166897: Some font overlap in the Optionpane dialog. Reviewed-by: azvegint
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41802
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     1
/*
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     4
 *
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     7
 * published by the Free Software Foundation.
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     8
 *
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    13
 * accompanied this code).
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    14
 *
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    18
 *
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    21
 * questions.
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    22
 */
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    23
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    24
/* @bug      8166897
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    25
   @summary  Some font overlap in the Optionpane dialog.
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    26
   @run      main ChangeWindowResizabiltyTest
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    27
*/
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    28
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    29
import java.awt.*;
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    30
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    31
public class ChangeWindowResizabiltyTest {
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    32
    public static void main(String[] args) throws Exception {
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    33
        Robot robot = new Robot();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    34
        for(int i = 0; i < 10; i++) {
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    35
            Dialog dialog = new Dialog((Frame) null);
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    36
            Component panel = new Panel();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    37
            panel.setPreferredSize(new Dimension(200, 100));
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    38
            dialog.add(panel);
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    39
            dialog.pack();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    40
            dialog.setVisible(true);
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    41
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    42
            dialog.setResizable(false);
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    43
            robot.waitForIdle();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    44
            robot.delay(200);
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    45
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    46
            System.out.println(panel.getLocationOnScreen());
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    47
            System.out.println(dialog.getLocationOnScreen());
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    48
            if (panel.getLocationOnScreen().y <
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    49
                       dialog.getLocationOnScreen().y + dialog.getInsets().top) {
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    50
                dialog.dispose();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    51
                throw new RuntimeException(
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    52
                        "Wrong content position after setResizable(false)");
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    53
            }
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    54
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    55
            dialog.setResizable(true);
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    56
            robot.waitForIdle();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    57
            robot.delay(200);
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    58
            System.out.println(panel.getLocationOnScreen());
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    59
            System.out.println(dialog.getLocationOnScreen());
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    60
            if (panel.getLocationOnScreen().y <
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    61
                    dialog.getLocationOnScreen().y + dialog.getInsets().top) {
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    62
                dialog.dispose();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    63
                throw new RuntimeException(
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    64
                        "Wrong content position after setResizable(true)");
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    65
            }
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    66
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    67
            dialog.dispose();
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    68
        }
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    69
    }
89f634379c0c 8166897: Some font overlap in the Optionpane dialog.
ssadetsky
parents:
diff changeset
    70
}