jdk/test/java/awt/Window/MultiWindowApp/MultiWindowAppTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 33507 3b304638a922
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:
33507
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     1
/*
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     4
 *
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     8
 *
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    13
 * accompanied this code).
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    14
 *
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    18
 *
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    21
 * questions.
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    22
 */
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    23
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    24
/**
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    25
 * @test @summary After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 33507
diff changeset
    26
 * @key headful
33507
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    27
 * @bug 8022334
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    28
 * @author Semyon Sadetsky
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    29
 * @run main MultiWindowAppTest
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    30
 */
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    31
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    32
import java.awt.*;
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    33
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    34
public class MultiWindowAppTest {
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    35
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    37
        Window win1 = new Frame();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    38
        Window win2 = new Dialog((Frame) null);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    39
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    40
        win1.setBounds(100, 100, 200, 200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    41
        win1.setBackground(Color.RED);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    42
        win1.setVisible(true);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    43
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    44
        Robot robot = new Robot();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    45
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    46
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    47
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    48
        win2.setBounds(win1.getBounds());
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    49
        win2.setVisible(true);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    50
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    51
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    52
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    53
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    54
        win1.toFront();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    55
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    56
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    57
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    58
        Point point = win1.getLocationOnScreen();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    59
        Color color = robot.getPixelColor(point.x + 100, point.y + 100);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    60
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    61
        if(!color.equals(Color.RED)) {
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    62
            win1.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    63
            win2.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    64
            throw new RuntimeException("Window was not sent to front.");
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    65
        }
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    66
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    67
        win1.toBack();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    68
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    69
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    70
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    71
        color = robot.getPixelColor(point.x + 100, point.y + 100);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    72
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    73
        win1.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    74
        win2.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    75
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    76
        if(color.equals(Color.RED)) {
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    77
            throw new RuntimeException("Window was not sent to back.");
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    78
        }
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    79
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    80
        System.out.println("ok");
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    81
    }
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    82
}