test/jdk/java/awt/Window/GetScreenLocation/GetScreenLocationTest.java
author serb
Wed, 21 Feb 2018 12:49:00 -0800
changeset 49096 eaef201ec301
parent 47216 71c04702a3d5
permissions -rw-r--r--
8198333: ProblemList should be updated for headless mode Reviewed-by: psadhukhan, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     1
/*
46151
5fa789776f7d 8185500: [TESTBUG] Add keywords headful/printer in java/awt and javax tests.
goetz
parents: 40161
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     4
 *
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     8
 *
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    13
 * accompanied this code).
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    14
 *
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    18
 *
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    21
 * questions.
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    22
 */
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    23
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    24
/**
49096
eaef201ec301 8198333: ProblemList should be updated for headless mode
serb
parents: 47216
diff changeset
    25
 * @test
eaef201ec301 8198333: ProblemList should be updated for headless mode
serb
parents: 47216
diff changeset
    26
 * @summary setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
46151
5fa789776f7d 8185500: [TESTBUG] Add keywords headful/printer in java/awt and javax tests.
goetz
parents: 40161
diff changeset
    27
 * @key headful
40161
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    28
 * @bug 8036915 8161273
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    29
 * @run main/othervm -Dsun.java2d.uiScale=1 GetScreenLocationTest
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    30
 * @run main/othervm -Dsun.java2d.uiScale=2 GetScreenLocationTest
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    31
 */
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    32
import java.awt.*;
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    33
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    34
public class GetScreenLocationTest {
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    35
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    37
        Robot robot = new Robot();
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    38
        Window frame = null;
40161
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    39
        for(int i = 0; i < 30; i++) {
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    40
            if(frame != null) frame.dispose();
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    41
            frame = new Dialog((Frame)null);
40161
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    42
            frame.setBounds(0, 0, 200, 100);
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    43
            frame.setVisible(true);
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    44
            robot.waitForIdle();
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    45
            robot.delay(200);
40161
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    46
            frame.setLocation(321, 121);
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    47
            robot.waitForIdle();
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    48
            robot.delay(200);
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    49
            Dimension size = frame.getSize();
40161
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    50
            if(size.width != 200 || size.height != 100) {
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    51
                frame.dispose();
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    52
                throw new RuntimeException("getSize() is wrong " + size);
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    53
            }
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    54
            Rectangle r = frame.getBounds();
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    55
            frame.dispose();
40161
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    56
            if(r.x != 321 || r.y != 121) {
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    57
                throw new RuntimeException("getLocation() returns " +
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    58
                        "wrong coordinates " + r.getLocation());
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    59
            }
40161
d1621c3f403c 8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled.
ssadetsky
parents: 39862
diff changeset
    60
            if(r.width != 200 || r.height != 100) {
39862
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    61
                throw new RuntimeException("getSize() is wrong " + r.getSize());
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    62
            }
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    63
        }
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    64
        System.out.println("ok");
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    65
    }
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    66
a3fc74a6c5a3 8036915: setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
ssadetsky
parents:
diff changeset
    67
}