test/jdk/java/awt/Window/MultiWindowApp/MultiWindowAppTest.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:
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
/**
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 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
    27
 * @key headful
33507
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    28
 * @bug 8022334
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    29
 * @author Semyon Sadetsky
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    30
 * @run main MultiWindowAppTest
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
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    33
import java.awt.*;
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    34
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    35
public class MultiWindowAppTest {
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    36
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    37
    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
    38
        Window win1 = new Frame();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    39
        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
    40
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    41
        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
    42
        win1.setBackground(Color.RED);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    43
        win1.setVisible(true);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    44
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    45
        Robot robot = new Robot();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    46
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    47
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    48
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    49
        win2.setBounds(win1.getBounds());
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    50
        win2.setVisible(true);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    51
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    52
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    53
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    54
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    55
        win1.toFront();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    56
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    57
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    58
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    59
        Point point = win1.getLocationOnScreen();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    60
        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
    61
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    62
        if(!color.equals(Color.RED)) {
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    63
            win1.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    64
            win2.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    65
            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
    66
        }
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    67
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    68
        win1.toBack();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    69
        robot.delay(200);
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    70
        robot.waitForIdle();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    71
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    72
        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
    73
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    74
        win1.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    75
        win2.dispose();
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    76
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    77
        if(color.equals(Color.RED)) {
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    78
            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
    79
        }
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    80
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    81
        System.out.println("ok");
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    82
    }
3b304638a922 8022334: After calling frame.toBack() dialog goes to the back on Ubuntu 12.04
ssadetsky
parents:
diff changeset
    83
}