test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java
author psadhukhan
Tue, 04 Jun 2019 14:43:57 +0530
changeset 55361 ed5c7d68ed5a
parent 52739 7199c4da1a6f
permissions -rw-r--r--
8224876: javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java fails on linux-x64 Reviewed-by: serb, jdv
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26601
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 26601
diff changeset
     2
 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
26601
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     4
 *
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     8
 *
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    13
 * accompanied this code).
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    14
 *
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    18
 *
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    21
 * questions.
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    22
 */
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    23
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    24
import java.awt.*;
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    25
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    26
/*
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    27
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 26601
diff changeset
    28
 * @key headful
47831
26ff2d9a753b 8164811: [hidpi]Tests fail with OpenGL and GDI Rendering 8189257: Enabling Translucent Frame with setBackground disables HiDPI
pbansal
parents: 47216
diff changeset
    29
 * @bug 7043845 8164811
26601
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    30
 * @summary Check if shaped and per-pixel translucent window is dragged and
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    31
 *          resized by mouse correctly.
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    32
 * Test Description: Check if PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    33
 *      translucency types are supported on the current platform. Proceed if
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    34
 *      they are supported. Create a window with some components in it, make
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    35
 *      window undecorated, apply shape in componentResized listener. The shape
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    36
 *      should match the window size; apply translucent background of 0 and have
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    37
 *      a gradient painted as background from fully-transparent to fully-opaque
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    38
 *      in componentResized listener. Drag and resize the window using AWT Robot
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    39
 *      and verify that shape and translucency are correctly applied with pixels
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    40
 *      checking. Make the window appear on top of a known background. Repeat
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    41
 *      this for JWindow, JDialog, JFrame.
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    42
 * Expected Result: If PERPIXEL_TRANSLUCENT and PERPIXEL_TRANSPARENT translucency
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    43
 *      types are supported, the window should appear as specified with the
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    44
 *      expected shape and translucency. Window background should have
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    45
 *      translucent gradient in parts that are not clipped by shape, all the
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    46
 *      controls should be opaque.
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    47
 * @author mrkam
52739
7199c4da1a6f 8186549: move ExtendedRobot closer to tests
shurailine
parents: 47831
diff changeset
    48
 * @library /lib/client
26601
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    49
 * @build Common ExtendedRobot
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    50
 * @run main ShapedPerPixelTranslucentGradient
47831
26ff2d9a753b 8164811: [hidpi]Tests fail with OpenGL and GDI Rendering 8189257: Enabling Translucent Frame with setBackground disables HiDPI
pbansal
parents: 47216
diff changeset
    51
 * @run main/othervm -Dsun.java2d.uiScale=1.5 ShapedPerPixelTranslucentGradient
26601
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    52
 */
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    53
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    54
public class ShapedPerPixelTranslucentGradient extends Common {
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    55
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    56
    public static void main(String[] ignored) throws Exception {
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    57
        if (checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    58
            && checkTranslucencyMode(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT))
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    59
            for (Class<Window> windowClass: WINDOWS_TO_TEST)
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    60
                new ShapedPerPixelTranslucentGradient(windowClass).doTest();
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    61
    }
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    62
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    63
    public ShapedPerPixelTranslucentGradient(Class windowClass) throws Exception {
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    64
        super(windowClass, 1.0f, 0f, true);
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    65
    }
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    66
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    67
    public void doTest() throws Exception {
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    68
        robot.waitForIdle(delay);
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    69
        checkDynamic();
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    70
    }
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    71
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    72
    @Override
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    73
    public void applyShape() {
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    74
        applyDynamicShape();
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    75
        gradientWidth = window.getWidth();
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    76
        gradientHeight = window.getHeight();
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    77
    }
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    78
2713482c0fd3 8055360: Move the rest part of AWT ShapedAndTranslucent tests to OpenJDK
dermashov
parents:
diff changeset
    79
}