jdk/test/java/awt/Window/ShapedAndTranslucentWindows/ShapedTranslucentWindowClick.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.*;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    26
import java.awt.geom.Area;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    27
import java.awt.geom.GeneralPath;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    28
import java.awt.geom.Rectangle2D;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    29
import java.util.BitSet;
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 a translucent shaped window trigger events correctly.
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 TRANSLUCENT and PERPIXEL_TRANSPARENT traslucency
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    37
 *      types are supported on the current platform. Proceed if both are
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    38
 *      supported. Create a window with some components in it and a shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    39
 *      applied. Apply the shape such that some components are partially
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    40
 *      clipped. Set an opacity value less than 1. Check if the components
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    41
 *      behave correctly on mouse and key events. Do this test for awt Window.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    42
 * Expected Result: Mouse and key events must work correctly. Only that portion
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    43
 *      of a component within the shape should trigger events. Key events
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    44
 *      should be tested for focus events and TextField/TextArea.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    45
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    46
 * @author mrkam
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    47
 * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    48
 * @library ../../../../lib/testlibrary
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    49
 * @build Common ExtendedRobot
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    50
 * @run main ShapedTranslucentWindowClick
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    51
 */
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    52
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    53
public class ShapedTranslucentWindowClick extends Common {
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
    Component south, center, north;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    56
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    57
    volatile BitSet backgroundFlags = new BitSet(11);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    58
    volatile BitSet southFlags = new BitSet(11);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    59
    volatile BitSet centerFlags = new BitSet(11);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    60
    volatile BitSet northFlags = new BitSet(11);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    61
    static BitSet reference = BitSet.valueOf(new long[] {2047}); // 111 1111 1111
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    62
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    63
    public static void main(String[] ignored) throws Exception{
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    64
        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT) &&
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    65
                checkTranslucencyMode(GraphicsDevice.WindowTranslucency.TRANSLUCENT))
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    66
            new ShapedTranslucentWindowClick(Window.class).doTest();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    67
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    68
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    69
    public ShapedTranslucentWindowClick(Class windowClass) throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    70
        super(windowClass);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    71
        addListeners(south, southFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    72
        addListeners(center, centerFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    73
        addListeners(north, northFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    74
        addListeners(background, backgroundFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    75
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    76
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    77
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    78
    public void initGUI() {
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
        window = new Window(background);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    81
        south = new Button("South Button");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    82
        center = new TextArea("Center Text Area");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    83
        north = new TextField("North Text Field");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    84
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    85
        window.setLocation(250, 250);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    86
        window.setPreferredSize(new Dimension(200, 200));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    87
        window.setOpacity(0.7f);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    88
        applyShape();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    89
        window.setLayout(new BorderLayout());
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    90
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    91
        window.add(south, BorderLayout.SOUTH);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    92
        window.add(center, BorderLayout.CENTER);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    93
        window.add(north, BorderLayout.NORTH);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    94
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    95
        window.pack();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    96
        window.setVisible(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    97
        window.toFront();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    98
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    99
        System.out.println("Checking " + window.getClass().getName() + "...");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   100
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   101
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   102
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   103
    public void doTest() throws Exception {
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
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   106
        robot.mouseMove(background.getLocationOnScreen().x+50, background.getLocationOnScreen().y+50);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   107
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   108
        robot.click();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   109
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   110
        Point wls = window.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   111
        Point ls;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   112
        int y;
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
        robot.waitForIdle();
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
        ls = north.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   117
        checkClickAndType(ls.x + north.getWidth() / 3, ls.y + north.getHeight() / 2, northFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   118
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   119
        ls = center.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   120
        checkClickAndType(ls.x + center.getWidth() / 4, ls.y + center.getHeight() / 4, centerFlags);
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
        ls = center.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   123
        checkClickAndType(ls.x + center.getWidth() * 3 / 4, ls.y + center.getHeight() * 3 / 4, centerFlags);
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
        ls = south.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   126
        checkClickAndType(ls.x + south.getWidth() * 2 / 3, ls.y + south.getHeight() / 2, southFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   127
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   128
        ls = north.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   129
        y = ls.y + north.getHeight() / 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   130
        checkClickAndType(wls.x + 200 - (y - wls.y), y, backgroundFlags);
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
        EventQueue.invokeAndWait(window::toFront);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   133
        robot.waitForIdle();
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
        ls = center.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   136
        y = ls.y + center.getHeight() / 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   137
        checkClickAndType(wls.x + 200 - (y - wls.y), y, backgroundFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   138
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   139
        EventQueue.invokeAndWait(window::toFront);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   140
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   141
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   142
        ls = south.getLocationOnScreen();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   143
        y = ls.y + south.getHeight() / 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   144
        checkClickAndType(wls.x + 200 - (y - wls.y), y, backgroundFlags);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   145
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   146
        EventQueue.invokeAndWait(window::dispose);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   147
        EventQueue.invokeAndWait(background::dispose);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   148
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   149
        robot.waitForIdle();
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
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   152
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   153
    public void applyShape() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   154
        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
   155
        GeneralPath gp;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   156
        gp = new GeneralPath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   157
        gp.moveTo(190, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   158
        gp.lineTo(200, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   159
        gp.lineTo(200, 10);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   160
        gp.lineTo(10, 200);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   161
        gp.lineTo(0, 200);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   162
        gp.lineTo(0, 190);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   163
        gp.closePath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   164
        shape.subtract(new Area(gp));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   165
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   166
        window.setShape(shape);
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
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   169
    void checkClickAndType(int x, int y, BitSet bits){
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   170
        bits.clear(0, 10);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   171
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   172
        robot.mouseMove(x, y);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   173
        robot.click();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   174
        robot.dragAndDrop(MouseInfo.getPointerInfo().getLocation(), new Point(x+5, y));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   175
        robot.mouseWheel(1);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   176
        robot.waitForIdle();
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.type('a');
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
        robot.mouseMove(350, 50);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   181
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   182
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   183
        //robot.delay(20*1000);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   184
        if (!bits.equals(reference)){
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   185
            for( int i = 0; i < 11; i++)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   186
                System.err.print(( bits.get(i) ? 1 : 0 ) + ", ");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   187
            System.err.println();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   188
            throw new RuntimeException("Bit mask is not fully set: "+bits);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   189
        }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   190
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   191
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   192
    static void addListeners(Component component, BitSet bits) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   193
        component.addMouseListener(new MouseListener() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   194
            public void mouseClicked(MouseEvent e) { bits.set(0);}
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   195
            public void mousePressed(MouseEvent e) { bits.set(1); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   196
            public void mouseReleased(MouseEvent e) { bits.set(2); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   197
            public void mouseEntered(MouseEvent e) { bits.set(3); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   198
            public void mouseExited(MouseEvent e) { bits.set(4); }
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
        component.addMouseMotionListener(new MouseMotionListener() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   201
            public void mouseDragged(MouseEvent e) { bits.set(5); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   202
            public void mouseMoved(MouseEvent e) { bits.set(6); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   203
        });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   204
        component.addMouseWheelListener((e) -> bits.set(7));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   205
        component.addKeyListener(new KeyListener() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   206
            public void keyTyped(KeyEvent e) { bits.set(8); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   207
            public void keyPressed(KeyEvent e) { bits.set(9); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   208
            public void keyReleased(KeyEvent e) { bits.set(10); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   209
        });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   210
    };
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   211
}