jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShapeDynamicallyAndClick.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 25559 a101ec6ccfd3
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:
25559
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 25559
diff changeset
     2
 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
25559
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     4
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     8
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    13
 * accompanied this code).
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    14
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    18
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    21
 * questions.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    22
 */
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    23
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    24
import java.awt.*;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    25
import java.awt.event.MouseAdapter;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    26
import java.awt.event.MouseEvent;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    27
import java.awt.geom.Area;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    28
import java.awt.geom.GeneralPath;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    29
import java.awt.geom.Rectangle2D;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    30
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    31
/*
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    32
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 25559
diff changeset
    33
 * @key headful
25559
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    34
 * @summary Check if dynamically setting a shape works
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    35
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    36
 * Test Description: Check if PERPIXEL_TRANSPARENT Translucency type is supported
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    37
 *      by the current platform. Proceed if it is supported. Show a window which
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    38
 *      contains some components and apply a shape for the Window when the window
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    39
 *      is visible. Shape should be applied in such a way that some components
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    40
 *      are partially clipped off. Check if the components appear only partially
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    41
 *      and events work correctly for those components - ie, events occur only on
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    42
 *      the areas which appear and do not occur on the clipped off areas. Events
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    43
 *      should be checked by clicking on the visible and clipped regions. Repeat
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    44
 *      this for Window, Dialog and Frame.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    45
 * Expected Result: If PERPIXEL_TRANSPARENT translucency type is supported,
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    46
 *      clicking on clipped region should deliver the event to the background (it
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    47
 *      should be another Window behind the test window)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    48
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    49
 * @author mrkam
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    50
 * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    51
 * @library ../../../../lib/testlibrary
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    52
 * @build Common ExtendedRobot
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    53
 * @run main SetShapeDynamicallyAndClick
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    54
 */
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    55
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    56
public class SetShapeDynamicallyAndClick extends Common {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    57
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    58
    Component south, center, north;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    59
    volatile int clicked;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    60
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    61
    public static void main(String[] args) throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    62
        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    63
            for (Class<Window> windowClass: WINDOWS_TO_TEST)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    64
                new SetShapeDynamicallyAndClick(windowClass).doTest();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    65
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    66
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    67
    public SetShapeDynamicallyAndClick(Class windowClass) throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    68
        super(windowClass);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    69
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    70
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    71
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    72
    public void initBackgroundFrame() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    73
        super.initBackgroundFrame();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    74
        background.addMouseListener(new MouseAdapter() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    75
            @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    76
            public void mouseClicked(MouseEvent e) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    77
                clicked |= 1 << 0;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    78
            }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    79
        });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    80
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    81
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    82
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    83
    public void initGUI() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    84
        if (windowClass.equals(Frame.class)) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    85
            window = new Frame();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    86
            ((Frame) window).setUndecorated(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    87
        } else  if (windowClass.equals(Dialog.class)) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    88
            window = new Dialog(background);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    89
            ((Dialog) window).setUndecorated(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    90
        } else {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    91
            window = new Window(background);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    92
        }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    93
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    94
        window.setLocation(2 * dl, 2 * dl);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    95
        window.setPreferredSize(new Dimension(200, 200));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    96
        window.setLayout(new BorderLayout());
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    97
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    98
        south = new Label("South");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    99
        south.addMouseListener(new MouseAdapter() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   100
            @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   101
            public void mouseClicked(MouseEvent e) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   102
                clicked |= 1 << 3;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   103
            }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   104
        });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   105
        window.add(south, BorderLayout.SOUTH);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   106
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   107
        center = new List(5);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   108
        center.addMouseListener(new MouseAdapter() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   109
            @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   110
            public void mouseClicked(MouseEvent e) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   111
                clicked |= 1 << 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   112
            }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   113
        });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   114
        window.add(center, BorderLayout.CENTER);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   115
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   116
        north = new TextField("North");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   117
        north.addMouseListener(new MouseAdapter() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   118
            @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   119
            public void mouseClicked(MouseEvent e) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   120
                clicked |= 1 << 1;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   121
            }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   122
        });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   123
        window.add(north, BorderLayout.NORTH);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   124
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   125
        window.pack();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   126
        window.setVisible(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   127
        window.toFront();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   128
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   129
        System.out.println("Checking " + window.getClass().getName() + "...");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   130
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   131
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   132
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   133
    public void doTest() throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   134
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   135
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   136
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   137
        Point wls = window.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   138
        Point ls;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   139
        int y;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   140
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   141
        EventQueue.invokeAndWait(this::applyShape);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   142
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   143
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   144
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   145
        ls = north.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   146
        checkClick(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, 1);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   147
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   148
        ls = center.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   149
        checkClick(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, 2);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   150
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   151
        ls = south.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   152
        checkClick(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, 3);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   153
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   154
        ls = center.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   155
        checkClick(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, 2);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   156
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   157
        ls = north.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   158
        y = ls.y + north.getHeight() / 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   159
        checkClick(wls.x + 200 - (y - wls.y), y, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   160
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   161
        EventQueue.invokeAndWait(window::toFront);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   162
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   163
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   164
        ls = center.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   165
        y = ls.y + center.getHeight() / 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   166
        checkClick(wls.x + 200 - (y - wls.y), y, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   167
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   168
        EventQueue.invokeAndWait(window::toFront);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   169
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   170
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   171
        ls = south.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   172
        y = ls.y + south.getHeight() / 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   173
        checkClick(wls.x + 200 - (y - wls.y), y, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   174
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   175
        EventQueue.invokeAndWait(window::dispose);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   176
        EventQueue.invokeAndWait(background::dispose);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   177
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   178
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   179
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   180
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   181
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   182
    public void applyShape() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   183
        Area shape = new Area(new Rectangle2D.Float(0, 0, 200, 200));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   184
        GeneralPath gp;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   185
        gp = new GeneralPath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   186
        gp.moveTo(190, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   187
        gp.lineTo(200, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   188
        gp.lineTo(200, 10);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   189
        gp.lineTo(10, 200);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   190
        gp.lineTo(0, 200);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   191
        gp.lineTo(0, 190);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   192
        gp.closePath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   193
        shape.subtract(new Area(gp));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   194
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   195
        window.setShape(shape);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   196
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   197
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   198
    void checkClick(int x, int y, int flag) throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   199
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   200
        System.out.println("Trying to click point " + x + ", " + y + ", looking for " + flag + " flag to trigger.");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   201
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   202
        clicked = 0;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   203
        robot.mouseMove(x, y);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   204
        robot.click();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   205
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   206
        for (int i = 0; i < 100; i++)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   207
            if ((clicked & (1 << flag)) == 0)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   208
                robot.delay(50);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   209
            else
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   210
                break;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   211
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   212
        if ((clicked & (1 << flag)) == 0)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   213
            throw new RuntimeException("FAIL: Flag " + flag + " is not triggered for point " + x + ", " + y + "!");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   214
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   215
}