jdk/test/java/awt/Window/ShapedAndTranslucentWindows/SetShape.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.ComponentAdapter;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    26
import java.awt.event.ComponentEvent;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    27
import java.awt.geom.*;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    28
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    29
/*
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    30
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 25559
diff changeset
    31
 * @key headful
25559
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    32
 * @summary Check if a window set with shape appears in the expected shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    33
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    34
 * 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
    35
 *      by the current platform. Proceed if it is supported. Apply different
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    36
 *      types of shapes on a Window. Make it appear with a known background. Use
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    37
 *      get pixel color to check whether it appears as expected. Repeat this for
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    38
 *      Window, Dialog and Frame.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    39
 * Expected Result: If PERPIXEL_TRANSPARENT Translucency type is supported, the
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    40
 *      window should appear with the expected shape.
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    41
 *
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    42
 * @author mrkam
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    43
 * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com)
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    44
 * @library ../../../../lib/testlibrary
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    45
 * @build Common ExtendedRobot
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    46
 * @run main SetShape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    47
 */
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
public class SetShape extends Common {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    50
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    51
    static int[][] pointsToCheck;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    52
    static Shape shape;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    53
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    54
    public static void main(String[] args) throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    55
        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT)) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    56
            for (int i = 0; i < 6; i++) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    57
                System.out.println("Checking shape "+i);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    58
                Area area;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    59
                GeneralPath path;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    60
                switch (i) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    61
                    case 0:
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    62
                        path = new GeneralPath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    63
                        path.moveTo(0, 40);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    64
                        path.lineTo(40, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    65
                        path.lineTo(110, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    66
                        path.lineTo(150, 40);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    67
                        path.lineTo(150, 110);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    68
                        path.lineTo(110, 150);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    69
                        path.lineTo(40, 150);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    70
                        path.lineTo(0, 110);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    71
                        path.closePath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    72
                        shape = path;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    73
                        pointsToCheck = new int[][]{
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    74
                                // inside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    75
                                {230, 240}, {286, 332}, {314, 267}, {220, 327}, {223, 246},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    76
                                {229, 274}, {335, 257}, {231, 278}, {317, 299}, {266, 236},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    77
                                // outside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    78
                                {340, 353}, {373, 320}, {330, 220}, {384, 300}, {349, 406},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    79
                                {213, 355}, {361, 260}, {399, 251}, {201, 374}, {199, 257}
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
                        break;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    82
                    case 1:
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    83
                        area = new Area();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    84
                        area.add(new Area(new Rectangle2D.Float(50, 0, 100, 150)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    85
                        area.add(new Area(new Rectangle2D.Float(0, 50, 200, 50)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    86
                        area.add(new Area(new Ellipse2D.Float(0, 0, 100, 100)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    87
                        area.add(new Area(new Ellipse2D.Float(0, 50, 100, 100)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    88
                        area.add(new Area(new Ellipse2D.Float(100, 0, 100, 100)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    89
                        area.add(new Area(new Ellipse2D.Float(100, 50, 100, 100)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    90
                        shape = area;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    91
                        pointsToCheck = new int[][]{
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    92
                                // inside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    93
                                {306, 314}, {296, 266}, {276, 335}, {380, 253}, {224, 333},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    94
                                {396, 305}, {365, 278}, {214, 331}, {289, 349}, {367, 345},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    95
                                // outside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    96
                                {365, 424}, {391, 391}, {346, 413}, {261, 398}, {348, 399},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
    97
                                {282, 400}, {386, 215}, {399, 369}, {213, 401}, {387, 215}
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
                        break;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   100
                    case 2:
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   101
                        path = new GeneralPath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   102
                        path.moveTo(100, 0);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   103
                        double angle = -Math.PI / 2;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   104
                        double angle_step = Math.PI * 2 / 8;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   105
                        for (int c = 0; c < 8; c++, angle += angle_step) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   106
                            path.lineTo(100 + 100 * Math.cos(angle), 100 + 100 * Math.sin(angle));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   107
                            path.lineTo(100 + 40 * Math.cos(angle + angle_step / 2), 100 + 40 * Math.sin(angle + angle_step / 2));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   108
                        }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   109
                        path.closePath();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   110
                        shape = path;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   111
                        pointsToCheck = new int[][]{
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   112
                                // inside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   113
                                {246, 257}, {300, 314}, {255, 347}, {291, 364}, {287, 320},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   114
                                {319, 276}, {269, 345}, {325, 291}, {289, 271}, {273, 339},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   115
                                // outside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   116
                                {373, 267}, {269, 229}, {390, 326}, {204, 216}, {379, 408},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   117
                                {375, 330}, {296, 213}, {367, 340}, {376, 409}, {378, 308}
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
                        break;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   120
                    case 3:
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   121
                        area = new Area();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   122
                        area.add(new Area(new Rectangle2D.Float(-15, 85, 230, 30)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   123
                        area.transform(AffineTransform.getRotateInstance(-Math.PI / 4, 100, 100));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   124
                        shape = area;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   125
                        pointsToCheck = new int[][]{
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   126
                                // inside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   127
                                {240, 366}, {254, 338}, {342, 244}, {264, 344}, {343, 240},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   128
                                {292, 303}, {225, 374}, {263, 348}, {329, 290}, {278, 327},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   129
                                // outside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   130
                                {353, 289}, {334, 377}, {391, 354}, {266, 358}, {280, 364},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   131
                                {232, 225}, {327, 309}, {375, 208}, {397, 292}, {204, 335}
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   132
                        };
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   133
                        break;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   134
                    case 4:
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   135
                        area = new Area();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   136
                        area.add(new Area(new Arc2D.Float(0, -100, 400, 400, 155, 50, Arc2D.PIE)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   137
                        area.subtract(new Area(new Ellipse2D.Float(70, 115, 20, 20)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   138
                        area.subtract(new Area(new Ellipse2D.Float(30, 90, 18, 18)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   139
                        area.subtract(new Area(new Ellipse2D.Float(17, 50, 30, 30)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   140
                        area.subtract(new Area(new Ellipse2D.Float(26, 124, 26, 26)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   141
                        area.subtract(new Area(new Ellipse2D.Float(100, 85, 25, 25)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   142
                        area.subtract(new Area(new Ellipse2D.Float(135, 100, 14, 14)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   143
                        shape = area;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   144
                        pointsToCheck = new int[][]{
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   145
                                // inside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   146
                                {225, 286}, {296, 276}, {318, 269}, {211, 357}, {295, 327},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   147
                                {207, 300}, {322, 265}, {319, 262}, {259, 294}, {261, 250},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   148
                                // outside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   149
                                {322, 303}, {330, 367}, {302, 395}, {227, 251}, {263, 382},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   150
                                {228, 383}, {280, 366}, {294, 248}, {316, 349}, {313, 294}
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
                        break;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   153
                    case 5:
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   154
                        area = new Area();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   155
                        area.add(new Area(new Rectangle2D.Float(0, 0, 90, 90)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   156
                        area.add(new Area(new Rectangle2D.Float(100, 0, 100, 200)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   157
                        area.add(new Area(new Ellipse2D.Float(0, 100, 100, 100)));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   158
                        shape = area;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   159
                        pointsToCheck = new int[][]{
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   160
                                // inside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   161
                                {275, 345}, {358, 327}, {373, 374}, {273, 331}, {251, 234},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   162
                                {285, 356}, {360, 287}, {319, 343}, {232, 210}, {323, 323},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   163
                                // outside shape
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   164
                                {219, 291}, {270, 302}, {296, 383}, {298, 203}, {228, 293},
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   165
                                {276, 300}, {292, 294}, {293, 216}, {298, 331}, {228, 295}
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   166
                        };
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   167
                        break;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   168
                    default:
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   169
                        break;
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
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   172
                for (Class<Window> windowClass : WINDOWS_TO_TEST) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   173
                    new SetShape(windowClass).doTest();
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
            }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   176
        }
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
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   179
    public SetShape(Class windowClass) throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   180
        super(windowClass);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   181
    }
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
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   184
    public void initGUI() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   185
        if (windowClass.equals(Frame.class)) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   186
            window = new Frame();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   187
            ((Frame) window).setUndecorated(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   188
        } else  if (windowClass.equals(Dialog.class)) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   189
            window = new Dialog(background);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   190
            ((Dialog) window).setUndecorated(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   191
        } else {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   192
            window = new Window(background);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   193
        }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   194
        window.setBackground(FG_COLOR);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   195
        window.addComponentListener(new ComponentAdapter() {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   196
            @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   197
            public void componentResized(ComponentEvent e) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   198
                window.setShape(shape);
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
        });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   201
        window.setSize(200, 200);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   202
        window.setLocation(2*dl, 2*dl);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   203
        window.setVisible(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   204
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   205
        System.out.println("Checking " + window.getClass().getName() + "...");
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   206
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   207
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   208
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   209
    public void doTest() throws Exception {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   210
        robot.waitForIdle();
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
        final int COUNT_TARGET = 10;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   213
        for(int i = 0; i < COUNT_TARGET * 2; i++) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   214
            int x = pointsToCheck[i][0];
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   215
            int y = pointsToCheck[i][1];
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   216
            boolean inside = i < COUNT_TARGET;
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   217
            Color c = robot.getPixelColor(x, y);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   218
            System.out.println("checking " + x + ", " + y + ", color = " + c);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   219
            boolean matchToForeground = FG_COLOR.equals(c);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   220
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   221
            if (!inside && matchToForeground || inside && !matchToForeground) {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   222
                System.err.println("Checking for transparency failed: point: " +
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   223
                        x + ", " + y +
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   224
                        ", color = " + c + (inside ? " is not of " : " is of un") +
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   225
                        "expected foreground color " + FG_COLOR);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   226
                final Frame[] f = new Frame[1];
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   227
                EventQueue.invokeAndWait(() -> {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   228
                    f[0] = new Frame();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   229
                    f[0].setUndecorated(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   230
                    f[0].setBackground(Color.YELLOW);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   231
                    f[0].setPreferredSize(new Dimension(2, 2));
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   232
                    f[0].pack();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   233
                    f[0].setVisible(true);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   234
                });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   235
                robot.delay(1000);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   236
                EventQueue.invokeAndWait(() -> {
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   237
                    f[0].setLocation(x, y);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   238
                });
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   239
                robot.delay(1000);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   240
            }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   241
        }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   242
        EventQueue.invokeAndWait(window::dispose);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   243
        EventQueue.invokeAndWait(background::dispose);
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   244
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   245
        robot.waitForIdle();
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   246
    }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   247
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   248
    @Override
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   249
    public void applyShape() { window.setShape(shape); }
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   250
a101ec6ccfd3 8043131: Move ShapedAndTranslucentWindows and GC functional AWT tests to regression tree
yan
parents:
diff changeset
   251
}